Add unallocated space to lvm

I shrunk my windows partition and now have 10 GB of unallocated space that I now want to use to grow my / partition which is an ext4 in an lvm. I'm running Fedora 12.

I ran system-config-lvm but the "Initialize Entry" button is greyed out.

The unallocated space is not adjacent to the lvm but I cannot move the partitions in GParted like I was able to with ext3 in the past. I cannot create a new partition either as it says it cannot have more than 4 primary partitions. I don't see any option to create an extended partition.

So my question is, how do I add that unallocated space to the lvm so I can grow the size of the / partition?

I don't want to reinstall Fedora.


Solution 1:

Unfortunately, it sounds like you do indeed have four primary partitions -- two for the NTFS partitions, one for your /boot and one for the lvm. Extended partitions lives inside a primary partition dedicated to holding them, so you won't be able to make any.

I'm not sure there's an easy way out for you, other than to find some secondary storage to move data onto while you shuffle partitions. If you decide to do this, you should be able to copy entire logical volumes rather than the contents of the filesystems. Gparted can't cope with lvm, unfortunately, so you may have to copy the contents of the lvm elsewhere, delete that partition, move the others around (you may be able to move the content of the primary partitions into extended partitions, for future flexibility) then recreate the lvm and copy the data back.

That's a lot of work, sorry :(.

Solution 2:

The whole point of LVM is that you CAN resize partitions, use multiple physical disks or partitions as one "logical" partition, etc. In order to utilize the free space you will need to create an additional partition using the free space.

Find out which disk the free space resides on using "fdisk -l", then do "fdisk /dev/hda" replacing hda with whichever disk is correct. Once a partition has been created using the free space we can now create a new physical volume:

pvcreate /dev/hda3

Replace hda3 with whatever the name of the new partition is (available within "fdisk -l"). Now we will extend the Volume Group to the new physical volume like so:

vgextend /dev/VolGroup00 /dev/hda3

Where VolGroup00 is the name of whichever VG exists on your system (available by running "vgdisplay"). Where hda3 is the name of the new partition (again). Once the VG has been extended we can now extend the Logical Volume:

lvextend -L +20G /dev/VolGroup01/LogVol00

Where 20G is changed to the amount of free space available and VG and LV changed to their correct names. Once the Logical Volume has been extended we have to extend the ext4 filesystem within that LV:

resize2fs /dev/VolGroup01/LogVol00

Again, change the names to match your system. You can perform all of this on a running system..including the last command. Extending ext4 on a mounted partition works fine since early versions of the 2.6 kernel.