Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've been using Fedora 15 on a VMWare virtual machine. Over time, the disk space I initially allocated for the file system began to run out, only 12GB left. I've expanded the disk space an extra 25GB.

Problem is, I need to expand the file system to take what is now 25GB of free space on the virtual disk.

I tried GParted, but it doesn't support LVM2. Does anyone know of any utilities or the commands needed to expand my filesystem?

Disk info: ![Logical Volume Group][1]

![Hard Disk][2]

![GParted][3]

Just tried this command:

[root@localhost /]# lvextend -L+10G /dev/VolGroup/lv_root 
Extending logical volume lv_root to 54.38 GiB
Insufficient free space: 320 extents needed, but only 0 available

Obviously it didn't work. How do I get at that unallocated disk space?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted
  1. Create an extended partition spanning the new free space, and create a logical partition inside it. (You could create a primary partition, but that would reduce your options later, because of the limit of 4 primary partitions or 3 primary and one extended.) You can do this with fdisk or cfdisk or parted. Set the type of the new partition to 8e (“Linux LVM”).

  2. Create a new LVM physical volume in that new partition.

    pvcreate /dev/sda5
    
  3. Add the new physical volume to your volume group.

    vgextend VolGroup /dev/sda5
    
  4. Extend the logical volume containing the filesystem you want to extend.

    lvextend -l +100%FREE VolGroup/name_of_logical_volume
    
  5. Extend the filesystem inside the volume. Use the command designed for that filesystem, e.g. resize2fs.

Instead of steps 1–3, you can extend the existing sda2 partition with Parted, then call pvresize /dev/sda2 to enlarge the existing physical volume. This may make management slightly easier afterwards, but it's more error-prone.

share|improve this answer
    
You want to expand the existing pv, not make a new one on another partition, and parted doesn't resize filesystems, just partitions ( it used to be able to resize hfs, fat and ext2, but that support was removed in parted 3 since it had been rotting for years ). –  psusi Feb 20 '12 at 2:18
    
How do I add give my new partition the 0x8E flag? See update. –  sj755 Feb 20 '12 at 2:34
1  
@seljuq70 You still need to create a logical partition on the extended partition (with fdisk, use the n command and select l for logical, and use all the available space; then use the t command to set the type of the newly created logical partition). –  Gilles Feb 20 '12 at 2:42
    
Could you elaborate on that last part, about resize2fs. I managed to unify the logical volumes, but physical volumes are still separate. –  sj755 Feb 20 '12 at 3:01
2  
@seljuq70 Once you have one big logical volume, the last step is to make the filesystem use all of it. If the filesystem is ext2/ext3/ext4, call resize2fs /dev/VolGroup/name_of_logical_volume, and the filesystem will be extended to occupy the whole volume that contains it (i.e. the LVM logical volume). –  Gilles Feb 20 '12 at 3:06
show 1 more comment

You're using LVM, the logical volume manager. This gives you a lot more flexibility than you would get with simple partitions, but you need to understand how everything fits together. I would start first at the LVM page on Wikipedia, paying special attention to the diagram that shows all the parts.

LVM is a stack, with your physical block devices -- usually disks or disk partitions -- at the bottom, and logical volumes at the top. Your root filesystem is on a logical volume, and you have increased the size of the underlying physical block device. There are some intermediate steps you need to take:

  • Because you're using disk partitions instead of whole disks, your new space is effectively "invisible" to Linux, because the existing partition for /dev/sda2 stops at the boundary of the disk prior to adding the new space. So you'll first have to extend the partition.

  • Now that you've extended the partition, you need to make the LVM subsystem aware of the additional space. Run pvresize /dev/sda2. This will allocate the additional space to the physical volume, making it available to your VolGroup volume group.

  • Now that the volume group has additional space, you can run our lvextend or lvresize command to grow the logical volume and extend the filesystem.

Read the LVM HOWTO for more information.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.