- Debian Admin - http://www.debianadmin.com -

Pain of the LVM and Fix

Posted By phoenixlpr On 5th March 2007 @ 06:23 In General | 2 Comments

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

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.

Tags: , , ,

You may also be interested in...


Article printed from Debian Admin: http://www.debianadmin.com

URL to article: http://www.debianadmin.com/lvm_vs_udev.html

Click here to print.