Moving the root filesystem to an LVM volume in etch
What is the problem?
I experienced quite some trouble when migrating etch to an LVM volume. Thus I documented the process below.
Afterwards I found this [http://linux.derkeiler.com/Mailing-Lists/Debian/2006-08/msg01699.html posting], which claims, that it should not be a problem at all, if you start it correctly. Please read that post and try if it works for you, before you continue reading.
Details of migration
split the active raid 1 mirror:
mdadm --fail /dev/md2 /dev/hdb5 mdadm --remove /dev/md2 /dev/hdb5
create a new raid 1 mirror:
mdadm --create /dev/md3 --raid-devices=2 --raid-level=mirror /dev/hdb5 missing
create an LVM physical volume, a volume group and the logical volume:
pvcreate /dev/md3 vgcreate base-lvm /dev/md3 lvcreate -n root -L 5G base-lvm mkfs.ext3 /dev/base-lvm/root
copy the old system to the new volume:
mount /dev/base-lvm/root /mnt cp -axv / /mnt/
backup the current initrd file and the menu.lst:
cp /boot/initrd-XXX /boot/initrd-XXX_before_lvm cp /boot/grub/menu.lst /boot/grub/menu.lst_before_lvm
chroot into the new system on lvm:
mount --bind /dev /mnt/dev mount --bind /boot /mnt/boot chroot /mnt mount /proc mount /sys
change the root filesystem in /etc/fstab:
/dev/base-lvm/root / ext3 noatime,errors=remount-ro 0 1
copy the following script to /usr/share/initramfs-tools/hooks/lvm:
run update-initramfs -u
- change the root device for grub:
update the placeholder in /boot/grub/menu.lst:
# kopt=root=/dev/mapper/base--lvm-root ro
BEWARE: in etch you must use the /dev/mapper/XXXX location (instead of the /dev/vg/lv-style)
update the grub menu file:
update-grub
- reboot
hope for mercy