The initial situation: Fedora Core 6 basic desktop installation with default partitioning
  • A /boot partition of about 100 MiB
  • The rest of disk space set up as a LVM physical volume containing
    • 2xRAM size of swap space
    • the rest filled by the / logical volume

(click for a full-size image)

The goal: shrink / to allow creation of separate logical volumes for e.g. /home, /tmp or other uses.

Step 1: Starting the rescue mode Because mounted ext3 filesystems can't be reduced, we must boot the machine in rescue mode. You can use either the first install CD, the install DVD or the separate rescue CD, and boot with the "linux rescue" command.

First the rescue environment asks you to pick your language and keyboard layout. Choose the ones matching your Fedora system. You can skip the networking setup, it's not needed in this process.

Let the rescue system mount your Fedora installation, this ensures that the LVM system is correctly initialized, all necessary modules are loaded and the /dev entries for LVM volumes are created.

If everything is OK, you will see this screen, and pressing Enter will start the rescue mode Bash shell.

Step 2: Preparations Start with checking the disk information, the command "mount" shows you the name of the / logical volume, now mounted as /mnt/sysimage. "df -h" shows the disk usage. Write down the device name of the volume you are going to resize and the amount of used space on that volume, in the example it's /dev/VolGroup00/LogVol00 with 2.0 GiB in use.

Unmount everything under /mnt/sysimage and finally /mnt/sysimage itself. Use the "-l" option for umount if you get complaints about busy devices.

Step 3: Shrinking the filesystem Before you can resize the filesystem you must run "e2fsck -f" on it. Resize2fs will complain and refuse to work if you forget to run e2fsck.
There are two things you must remember when choosing the new size of your filesystem:
  • LVM allocates space in 32MiB chunks by default, the new size must be a multiple of the LVM extent size.
  • The filesystem mustn't be too full after resizing or you may have problems when restarting the system. Try to leave at least 20% free space on the volume.

The resize2fs program will take a while to run. You can add "-p" option to its command line to see a progress bar.

Step 4: Shrinking the logical volume The rescue disc has only the "lvm" command shell instead of separate commands for each LVM operation. While in the lvm shell, you can use the "help" command to display information such as a list of commands and options available for each command. Shrink the volume to the same size you specified in the previous step for the filesystem. Use "exit" or "quit" to leave the lvm shell.

Step 5: Reboot The command "exit" will leave the rescue mode and reboot the machine. Remove the rescue disc from the drive and the system should boot normally to the GUI mode.

Checking the result Compare the graphical LVM status to the initial version and you see the unused space available for creating new logical volumes.
(click for a full-size image)