Results 1 to 6 of 6
We have a VDS (virtual dedicated server) running centos.
this virtual machine has 10 GB HDD space. but the available image which installed has only 5GB spcae. we want to ...
- 09-08-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 2
How to Extend a lvm type partition in centos?
We have a VDS (virtual dedicated server) running centos.
this virtual machine has 10 GB HDD space. but the available image which installed has only 5GB spcae. we want to extned it to full 10GB , I tried some solutions but couldnt give any result.
Please let me know the best & complete instructions to do that.
- 09-08-2011 #2
Use yum to install the system lvm configuration tool - I think it's in its own package, so 'yum install system-config-lvm' should do it. You can make changes using that tool, just run it from the command line as the root user.
Linux user #126863 - see http://linuxcounter.net/
- 09-08-2011 #3Just Joined!
- Join Date
- Sep 2011
- Posts
- 2
Already i've installed lvm .
but i dont know how i use lvm commands to do that.
lvm commands : centos.org/docs/5/html/Deployment_Guide-en-US/s1-disk-storage-lvm.html
someone please help me wit a step by step and full instruction
- 09-09-2011 #4
Not going to reinvent that wheel for you, there are too many good tutorials if you search. But basically you need to create a partition on the unused 5Gb space with parted or gparted, then use system-config-lvm to add it to the volume group, then you can extend the LV. Then you have to resize the filesystem. There are variations on how to use the unpartitioned 5Gb, but that scenario fits what you seem to be asking.
- 09-09-2011 #5Just Joined!
- Join Date
- Dec 2009
- Location
- California
- Posts
- 69
Login to machine as root:
-bash-3.2# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 6030784 3450956 2268532 61% /
/dev/sda1 101086 36330 59537 38% /boot
tmpfs 517564 0 517564 0% /dev/shm
Now I'm going to increase root. I can either add a second disk and
then add that to the volume group, or I can increase the size of
sda2 stretching the partition into unused space.
I'm going to assume I've got (or can get) extra disk space on /dev/sda.
My machine was a VM, so I just used vmware console to make the disk bigger. (bumped from 8 to 10 GB).
In the VM, fdisk /dev/sda still has the old size of 8 GB, so reboot (init 6)
After reboot, fdisk /dev/sda shows the new size.
**********************
-bash-3.2# fdisk /dev/sda
The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM
**********************
Delete the LVM partition and re-create it using the same start cyl and
the different end cylinder.
REMEMBER to SET the TYPE of the partition to "Linux LVM" == 8e
***********************
Command (m for help): p
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM
***********************
Write the settings (w)
Then reboot. (init 6)
Now, let the LV system know that the Physical volume has increased in size:
# pvresize /dev/sda2
Now, extend the logical volume:
# lvextend /dev/mapper/VolGroup00-LogVol00 /dev/sda2
NOTE: if that doesn't seem to work, use lvresize instead
Now, resize the file system:
# resize2fs /dev/mapper/VolGroup00-LogVol00
That's it. No reboot required
You could also add a second disk then reboot
Then add it to the volume group
create a partition:
# fdisk /dev/sdb
assign it a type of 8e - Linux LVM
Create a physical volume for the VG
# pvcreate /dev/sdb1
Add it to the volume group
# vgextend VolGroup00 /dev/sdb1
Add it to the lv
# lvextend /dev/mapper/VolGroup00-LogVol00 /dev/sdb1
Now, resize the file system:
# resize2fs /dev/mapper/VolGroup00-LogVol00Last edited by abarclay; 09-09-2011 at 03:10 PM. Reason: spelling mistake "bitter" -> "bigger"
- 09-09-2011 #6
^Just make sure you don't do that "w" in fdisk before you recreate the partition! If you do you'll be reinstalling or recovering from backup.
Also note that at least some fdisk manpages say:
I always just add a new partition on the unused space when I've used an image smaller than the system disk AND the system is LVM based. Add it to the volume group and the rest of the steps look the same. "Stretching" the existing partition is not necessary with LVM, I do that only when I'm working with a filesystem-on-partition scenario.fdisk is a buggy program that does fuzzy things -
usually it happens to produce reasonable results. Its single advantage
is that it has some support for BSD disk labels and other non-DOS par‐
tition tables. Avoid it if you can.


Reply With Quote