11.8. Converting a root filesystem to LVM
In this example the whole system was installed in a single root partition with the exception of /boot. The system had a 2 gig disk partitioned as:
The / partition covered all of the disk not used by /boot and swap. An important prerequisite of this procedure is that the root partition is less that half full (so that a copy of it can be created in a logical volume). If this is not the case then a second disk drive should be used. The procedure in that case is similar but there is no need to shrink the existing root partition and /dev/hda4 should be replaced with (eg) /dev/hdb1 in the examples. To do this it is easiest to use GNU parted. This software allows you to grow and shrink partitions that contain filesystems. It is possible to use resize2fs and fdisk to do this but GNU parted makes it much less prone to error. It may be included in your distribution, if not you can download it from ftp://ftp.gnu.org/pub/gnu/parted. Once you have parted on your system AND YOU HAVE BACKED THE SYSTEM UP: 11.8.1. Boot single userBoot into single user mode (type linux S at the LILO prompt) This is important. Booting single-user ensures that the root filesystem is mounted read-only and no programs are accessing the disk. 11.8.2. Run PartedRun parted to shrink the root partition Do this so there is room on the disk for a complete copy of it in a logical volume. In this example a 1.8 gig partition is shrunk to 1 gigabyte This displays the sizes and names of the partitions on the disk
Now resize the partition:
Create a new partition
Quit parted
11.8.4. Verify kernel config optionsMake sure that the kernel you are currently running works with LVM and has CONFIG_BLK_DEV_RAM and CONFIG_BLK_DEV_INITRD set in the config file. 11.8.5. Adjust partition typeChange the partition type on the newly created partition from Linux to LVM (8e). Parted doesn't understand LVM partitions so this has to be done using fdisk.
11.8.6. Set up LVM for the new scheme
11.8.7. Create the FilesystemMake a filesystem in the logical volume and copy the root files onto it.
11.8.8. Update /etc/fstabEdit /mnt/etc/fstab on the new root so that / is mounted on /dev/vg/root. For example:
11.8.9. Create an LVM initial RAM disk
Make sure you note the name that lvmcreate_initrd calls the initrd image. It should be in /boot. 11.8.10. Update /etc/lilo.confAdd an entry in /etc/lilo.conf for LVM. This should look similar to the following:
You should copy this new lilo.conf onto /etc in the new root fs as well.
11.8.12. Reboot to lvmReboot - at the LILO prompt type "lvm" The system should reboot into Linux using the newly created Logical Volume. If that worked then you should make lvm the default LILO boot destination by adding the line
If it did not work then reboot normally and try to diagnose the problem. It could be a typing error in lilo.conf or LVM not being available in the initial RAM disk or its kernel. Examine the message produced at boot time carefully. 11.8.13. Add remainder of diskAdd the rest of the disk into LVM When you are happy with this setup you can then add the old root partition to LVM and spread out over the disk. First set the partition type to 8e(LVM)
Convert it into a PV and add it to the volume group:
Linux HOWTO full list |
|
This document, LDP HOWTO-INDEX, is copyrighted (c) 1995 - 2002 by Tim Bynum, Guylhem Aznar, Joshua Drake and Greg Ferguson. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is available at http://www.gnu.org/copyleft/fdl.html. If you have questions, please contact the LDP.
Web Design Copyright © 1999-2003. Chrisranjana Software Solutions Pvt Ltd. syndicate rss feed |