I recently started moving from Fedora 9 to Ubuntu 10.04. Both file systems live in logical volumes. Fedora 9 is in /dev/VolGroup00/fedora9-root (10G) and /dev/VolGroup00/fedora9-home (75G) and Ubuntu 10.04 is in /dev/VolGroup00/ubuntu-10.04-root (10G) and /dev/VolGroup00/ubuntu-10.04-home (52G).
My migration strategy is to leave Fedora alone for the rest of the family and use the new Ubuntu installation myself until I’m confident everything is set up correctly. I’ve been moving things from my Fedora home to my Ubuntu home as I need them. Unfortunately, I’ve run out of room on the Ubuntu home logical volume and there’s no more room on the LVM or physical disks.
I need to shrink the Fedora home and expand the Ubuntu home. A nice summary of the commands used here is on Fedora Daily Package.
First, I need to know how much space I can grab from the Fedora home:
$ sudo mount /mnt/fedora9-home $ df -h /mnt/fedora9-home Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-fedora9--home 74G 29G 42G 41% /mnt/fedora9-home $ sudo umount /mnt/fedora9-home
This tells me the file system needs 29G and there’s 42G available. Since it’s still being used, I don’t want to take all the space, so I’ll leave a few gigabytes. I’ll make it 32G, freeing up 39G. To make all these changes to the file systems, they can’t be mounted. Use the Ubuntu 10.04 Alternate installation disc, which supports LVM. When booting, choose “Rescue a broken system”, tell it not to use a root file system and run a shell in the installer environment.
Activate the logical volumes:
# lvm vgscan # lvm vgchange -ay
Check the LVM sizes:
# lvm lvs
Shrink Fedora home:
# e2fsck -f /dev/VolGroup00/fedora9-home # resize2fs /dev/VolGroup00/fedora9-home 31G # lvm lvresize VolGroup00/fedora9-home --size 32G # resize2fs /dev/VolGroup00/fedora9-home
This sequence makes sure nothing gets clipped by rounding. The file system is shrunk to 31G, then the volume is resized to 32G. Lastly, the file system is resized to use all the space in the volume.
Now add the space to Ubuntu home:
# lvm lvresize VolGroup00/ubuntu-10.04-home --size 91G # resize2fs /dev/VolGroup00/ubuntu-10.04-home # e2fsck /dev/VolGroup00/ubuntu-10.04-home