Conversion of the root fs to LVM on woody
Hi,
Two days ago I converted the root filesystem of my newly installed woody
to LVM. It was an exciting procedure. The steps are listed below which
might be a reference for those who are interested.
Information about the original system, 3 partitions: /dev/hda6 24MB ext2
mounted as /boot, /dev/hda7 128MB as swap, /dev/hda8 14GB (used
1GB) reiserfs as /.
General steps: resize the reiserfs, resize the partition hda8, split
the partition hda8 to hda8 and hda9, create VG on hda9, create
LV_root on VG, mkreiserfs on LV_root, copy / from hda8 to LV_root, change
/etc/fstab on LV_root, create initrd-lvm-xxx.gz, add new entry in the
menu.lst of GRUB, reboot to the system based on LV_root, add hda8 to VG.
Detailed steps:
1. Create a bootable floppy containing "resize_reiserfs" and "fdisk" from
rip-10.exe (http://www.tux.org/pub/people/kent-robotti/looplinux/rip/).
Don't use the working system because it's dangerous to resized the mounted
partition. So a bootable tool disk is needed, on which only two tools are
needed, i.e., resize_reiserfs and fdisk. It's recommended to use cfdisk.
However, rip-10 only contains fdisk. It's also possible to use Linuxcare
BBC.
2. Backup the original system. I installed woody one week ago. So this
step is skipped.
3. Boot the computer by the bootable floppy.
Resize the reiserfs on hda8 :
# resize_reiserfs -s -5G /dev/hda8
You can confirm the change by:
# mount /dev/hda8 /mnt
# df
# umount
Run fdisk to resize the partition hda8:
# fdisk
First delete the partition hda8, then create a partition with size
larger than the resized reiserfs, here 11GB is used for safe. Keep
the SAME value for START cylinder. Then create new partition hda9
using the remaining space. Mark partition hda9 as 8e (Linux LVM).
Write the partition table.
4. Boot the computer into woody as before.
Install reiserfsprogs and lvm10:
# apt-get install reiserfsprogs lvm10
5. Create volume group vg00:
# pvcreate /dev/hda9
# vgcreate vg00 /dev/hda9
Create logical volume root:
# lvcreate -L2G -n root vg00
Make reisers for LV root:
# mkreiserfs /dev/vg00/root
6. Copy the / to newly created LV root:
# mount /dev/vg00/root /mnt
# find / -xdev |cpio -pvmd /mnt
7. Modify /mnt/etc/fstab:
#vi /mnt/etc/fstab
Replace the content in fstab: /dev/hda8 to /dev/vg00/root
8. Create initrd image:
# lvmcreate_initd
File /boot/initrd-lvm-2.4.18-bf2.4.gz are created.
9. Add an entry in the /boot/grub/menu.lst:
#-------------------------
title=LVM Debian 2.4.18-bf2.4
root (hd0,5)
kernel /vmlinuz-2.4.18-bf2.4 root=3a00 ramdisk=8192
initrd /initrd-lvm-2.4.18-bf2.4.gz
#-------------------------
Note that grub uses Major/Minor hex code to specify the LV.
Use "ls -l /dev/vg00/root" to find that the Major/Minor numbers are
58:0 (in hex 3a:00).
10. Restart the computer, choose to boot by LVM Debian 2.4.18-bf2.4. Any
error might be solved by booting into the original system.
11. When the system based on LVM works well, take back the partition hda8:
Mark the partition hda8 as 8e by fdisk
Then create PV on /dev/hda8:
# pvcreate /dev/hda8
Add hda8 to volume group vg00:
# vgextend vg00 /dev/hda8
The conversion is finished. It's time to create LVs for /home,
/var, etc. Everything is flexible now.
At the end, there are two exllent LVM documents:
1. LVM-howto, http://www.tldp.org/HOWTO/LVM-HOWTO.html
2. Learning Linux LVM, by Daniel Robbins,
http://www-106.ibm.com/developerworks/linux/library/l-lvm/index.html
http://www-106.ibm.com/developerworks/library/l-lvm2.html
One good article for Grub:
The GNU GRUB Boot Loader, by Jaswinder Singh Kohi,
http://www.linuxgazette.com/issue64/kohli.html
Hope I don't forget anything and it's useful to you.
Good luck,
Qian
Reply to: