Unterschiede zwischen den Revisionen 1 und 2
Revision 1 vom 2008-12-28 19:02:51
Größe: 1941
Autor: lars
Kommentar: init
Revision 2 vom 2008-12-28 19:05:14
Größe: 2884
Autor: lars
Kommentar: added the script
Gelöschter Text ist auf diese Art markiert. Hinzugefügter Text ist auf diese Art markiert.
Zeile 41: Zeile 41:
 * copy the following script to ''/usr/share/initramfs-tools/hooks/lvm'':  * copy the following script to ''/usr/share/initramfs-tools/hooks/lvm'': {{{
#!/bin/sh

PREREQ=""

prereqs()
{
        echo "$PREREQ"
}

case $1 in
prereqs)
        prereqs
        exit 0
        ;;
esac

if [ ! -x /sbin/lvm ]; then
        exit 0
fi

. /usr/share/initramfs-tools/hook-functions

if [ -e /etc/lvm/lvm.conf ]; then
        mkdir -p ${DESTDIR}/etc/lvm
        cp /etc/lvm/lvm.conf ${DESTDIR}/etc/lvm/
fi

copy_exec /sbin/lvm /sbin
# this is the self-made stuff to get it running under etch ...
cp -a /sbin/lv* $DESTDIR/sbin
cp -a /sbin/vg* $DESTDIR/sbin
cp -a /sbin/pv* $DESTDIR/sbin
cp -a /lib/lvm-200 $DESTDIR/lib
cp -a /lib/lvm-default $DESTDIR/lib
# also copy the required libraries
ldd /lib/lvm-200/lvm | cut -f 1 -d " " | cut -f 2 | sed s#^l#/lib/l# | while read fname
  do test -e $DESTDIR$fname || cp "$fname" $DESTDIR$fname
 done

for x in dm_mod dm_snapshot dm_mirror; do
        manual_add_modules ${x}
done
}}}
  * the script is heavily based

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:

    PREREQ=""
    
    prereqs()
    {
            echo "$PREREQ"
    }
    
    case $1 in
    prereqs)
            prereqs
            exit 0
            ;;
    esac
    
    if [ ! -x /sbin/lvm ]; then
            exit 0
    fi
    
    . /usr/share/initramfs-tools/hook-functions
    
    if [ -e /etc/lvm/lvm.conf ]; then
            mkdir -p ${DESTDIR}/etc/lvm
            cp /etc/lvm/lvm.conf ${DESTDIR}/etc/lvm/
    fi
    
    copy_exec /sbin/lvm /sbin
    # this is the self-made stuff to get it running under etch ...
    cp -a /sbin/lv* $DESTDIR/sbin
    cp -a /sbin/vg* $DESTDIR/sbin
    cp -a /sbin/pv* $DESTDIR/sbin
    cp -a /lib/lvm-200 $DESTDIR/lib
    cp -a /lib/lvm-default $DESTDIR/lib
    # also copy the required libraries
    ldd /lib/lvm-200/lvm | cut -f 1 -d " " | cut -f 2 | sed s#^l#/lib/l# | while read fname
      do    test -e $DESTDIR$fname || cp "$fname" $DESTDIR$fname
     done
    
    for x in dm_mod dm_snapshot dm_mirror; do
            manual_add_modules ${x}
    done
    • the script is heavily based
  • 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 :)

FaxeMoveRootToLVMinEtch (zuletzt geändert am 2012-06-13 21:26:25 durch anonym)


Creative Commons Lizenzvertrag
This page is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.