Pain of the LVM and Fix

Problem domain:

I have started to use LVM(2) and converted my system on lvm2 devices. I have noticed that I need to use initrd in order to boot up because all of my partitions were using lvm except /boot. I had 2 versions of debian-netsint on CD. I could boot up with them and with some debian kernel (2.6.8-2)installed from deb, but not the kernel I have complied (2.6.20). I got a kernel panic: missing root device and init: dev/console was missing.

Path to solve:

I realized that I have to try to use udev. I tried to create my initrd with mkinitrd. It was quite flexible with transfering files to my initrd, but it turns to be a dead end.

I have realized that one of the cause was devfs have been removed from the kernel around version 2.6.13-17. Thanks Linus it was a great idea to drop it this point from the 2.6 tree. I have thought that the stable tree is not a playground.

I have switched to mkinitramfs. It looks a bit complicated for the first look. It took some time to hook on. My first advice is use the break option, so it will stop after init-premount level and execute a shell.

Needed things to boot from an LVM root:

  1. Having required kernel features loaded from modules.
  2. Having those disk devices created holding the lvm volumes to boot on
  3. Having and running vgchange -ay

My way:

/etc/initramfs-tools/initramfs.conf:

MODULES=list

BOOT=local

This is my hook script:

/etc/initramfs-tools/hooks/lvm:

#!/bin/sh -e

PREREQS=””

prereqs() { echo “$PREREQS”; }

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

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

copy_exec /lib/lvm-default/lvm /sbin/

/etc/initramfs-tools/scripts/init-premount/my_lvm:

case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac

# Do the work here.

mkdir /dev/mapper
/bin/mknod /dev/hda1 b 3 1
/bin/mknod /dev/hda2 b 3 2
/sbin/lvm vgchange -ay

# Handle an error:
Well, my hook script transfers the actual running lvm to initrd and the script: my_lvm makes the rest of the work.

Have fun! I hope I could save some headaches with this cookbook.

Sponsored Link

2 thoughts on “Pain of the LVM and Fix

  1. don’t know why the manual customization is necessary as i recently switched from yaird to mkinitramfs on a “root on lvm2 over software raid” 2.6.15 and 2.6.18 etch setup, but without any problems.

    (i switched to mkinitramfs as it appears to be the most mature, the ubuntu/debian default, and the long(er)-term solution.)

    the default works but i later customized the configuration to deactivate unnecessary scripts and modules that were being ran/loaded at boot, but that didn’t require anything more than editing config files and removing/renaming scripts.

    i definitely didn’t have to create nor edit any scripts.

  2. I have updated my sid before. It was not working. I’ve put a 2.6.18-4-686 kernel up from deb(debian-testing-i386-netinst.iso) and it still was not working.

    After all I have started to digg into the initrds. I prefer initramfs-tools, its more flexible.

    I’ve installed from the same netinst disk(2.6.18-4-686) to my HP laptop. It was not booting again. :(.

Leave a comment

Your email address will not be published. Required fields are marked *