In the recent past I have been doing more with virtual machines. I had setup a VM of Fedora for a colleague and had set the disk size of this at about 13GB, time passes and this doesn’t satisfy a new set of applications.
To expand the disks I thought it would be a simple case of creating a new blank larger disk through the VirtualBox application, as you are making a new machine but not installing anything to it. I created a disk of about 38GB and attached this disk to the existing Fedora VM and booted it with the Clonezilla iso in the virtual optical disk drive, I could then use device to device in Clonezilla to copy the Fedora VM leaving about 25GB unallocated at the end of the disk. ( Instead of Clonezilla you can also use the command line VBoxManage with the clonehd option to achieve the same ).
I thought the next step would be to use gparted to expand the root partition on the new disk, so I attempted to use a Gparted live disk but when you see the root and swap partition of the Fedora VM it is an LVM2 filesystem which can’t be resized or moved by gparted. I began to do a bit of research and got quite confused regarding physical and logical volumes and the various command line tools. The solution I used in the end was to attach the expanded Fedora VM disk to an existing Ubuntu VM and booting into Ubuntu create an extended partition using gparted for the unallocated 25GB, then load the Logical Volume Management ( system-config-lvm easily available through the Ubuntu Software Center ) tool, this allows that extended partition to be initialised and then added to the volume group that the root partition is on and then you can migrate the root partition to the 25GB volume. You then have to run lvextend giving the number of extents free on that partition and after that run e2fsck and resize2fs, so the filesystem is aware of the extension. It’s not too tricky once you work how the tools can be used together, but it is hard to get my head around after being used to ordinary ext2 filesystems.
Briefer description using a Fedora live CD, lvm tools didn’t come with my Fedora 15 live CD and I have issues installing software with the livecd running behind a proxy hence the Ubuntu VM install.