You are not logged in.

#1 2008-09-26 17:59:45

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

dm_crypt + lvm -> kinit: Cannot open root device dm-0(254,0)

Hi, I just installed Arch 2008-06 x86_64 on my macbook pro.  Until today this box ran ubuntu with a setup like this:
* sda3 -> boot
* sda4-> dm_crypt -> 1 Lvm volumegroup -> several lvm logical volumes (with filesystems root,home etc).
I wanted to get this 'lvm on top of dm_crypt' setup running with arch, so I followed http://wiki.archlinux.org/index.php/Using_DM-Crypt closely:
I said 'yes i need support for booting from lvm and encrypted fs'.  I think i might also have said yes to support for booting from softraid.  this doesn't mean it *needs* softraid and fails to boot otherwise, right?
I think I configured grub correctly (note: grub is installed on sda3, not in the MBR), I checked mkinitcpio.conf etc.
I used hardware autodetection during installation
1 exception I made off the tutorial: I want lvm on top of dm_crypt, not the other way around (that way it's easier to manage: just 1 key, I can easily grow etc)

The thing is, after (re)booting grub works, the initrd seems to work, etc. here is exactly all the output before it fails:

:: Loading keymap....done.
:: Running Hook [encrypt]
device-mapper: uevent: version 1.0.3
device-mapper: ioctl: 4.13.0-ioctl (2007-10-18) initialised: dm-devel@redhat.com

A password is required to access the root volume:
Enter LUKS passphrase:
key slot 0 unlocked.
:: Running hook [lvm2]
mknod: File exists - /dev/mapper/control
Scanning logical volumes...
    Reading al physical volumes.  This may take a while...
    found volume group "lvmpool" using metadata type lvm2
Activating logical volumes...
    4 logical volume(s) in volume group "lvmpool" now active
:: Running Hook [filesystems]
:: Loading root filesystem module...lvm2
Waiting for devices to settle...done.
:: Initramfs completed - control passing to kinit
IP-Config: no devices to configure
Waiting 0 s before mounting root device...
kinit: cannot open root device dm-0(254,0)
kinit: init not found!
Kernel panic - not syncing: Attempt to kill init!

so it looks like it thinks it needs to look for a softraid volume or something, completely not like it should?
I also have this with the fallback image btw


My mkinitcpio.conf looks like this:

MODULES="pata_acpi ata_generic scsi_mod ata_piix"
BINARIES=""
FILES=""
HOOKS="base udev autodetect pata scsi sata usbinput keymap encrypt lvm2 filesystems"

(Note: I didn't need to change a thing during installation, arch figured this out by itself apparently?)

My grub/menu.lst:

title Arch Linux
root (hd0,2)
kernel /vmlinuz26 root=/dev/sda4 ro
initrd /kernel26.img

title Arch Linux Fallback
root (hd0,2)
kernel /vmlinuz26 root=/dev/sda4 ro
initrd /kernel26-fallback.img

My fstab:

(blah blah)
/dev/mapper/lvmpool-home /home ext3 defaults 0 1
/dev/mapper/lvmpool-root / ext3 defaults 0 1
/dev/mapper/lvmpool-swap swap swap defaults 0 0
/dev/mapper/lvmpool-tmp /tmp ext3 defaults 01 
UUID=<...> /boot ext3 defaults 0 1

PS: I've found 2 similar hits on the forums. but they aren't of much help..
http://bbs.archlinux.org/viewtopic.php?id=37154&p=2 -> bug fixed by tpowa in 2007,
http://bbs.archlinux.org/viewtopic.php?id=26118 -> reinstall fixed it magically o_O

PPS: If the solution includes regenerating the images, be specific please smile.  I can boot the livecd, get the volumes up and know how to chroot, but I have very little experience with initramfs/mkinitcpio

Last edited by Dieter@be (2008-09-26 20:20:58)


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#2 2008-09-26 20:32:14

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: dm_crypt + lvm -> kinit: Cannot open root device dm-0(254,0)

I just tried changing the root kernel parameter to root=/dev/mapper/lvmpool-root ro (instead of /dev/sda4) as suggested by http://wiki.archlinux.org/index.php/Con … #Using_lvm
That gave me a console called 'ramfs$' o_O


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#3 2008-09-26 21:58:06

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: dm_crypt + lvm -> kinit: Cannot open root device dm-0(254,0)

Omg... I just noticed that at the very end there of http://wiki.archlinux.org/index.php/Usi … vm_on_luks there is a section called '/ on lvm on luks'.  the one caveat is apparently you need to pass the kernel parameters like this : "root=/dev/mapper/vg-arch cryptdevice=/dev/sda4:vg".

Guess what... It worked smile
Frankly I still don't understand why it was looking for a dm device before (??) and the fact that when you just dm_crypt you should specify the real physical partition (eg /dev/sda4)  but in the case of lvm/ lvm on dm_crypt not stil confuses me, but hey...


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#4 2008-11-22 04:47:26

kludge
Member
Registered: 2008-08-03
Posts: 294

Re: dm_crypt + lvm -> kinit: Cannot open root device dm-0(254,0)

Dieter@be wrote:

Guess what... It worked smile
Frankly I still don't understand why it was looking for a dm device before (??) and the fact that when you just dm_crypt you should specify the real physical partition (eg /dev/sda4)  but in the case of lvm/ lvm on dm_crypt not stil confuses me, but hey...

i spent a most of this afternoon screwing around inside the initcpio hooks today.

i think it was looking for dm-0 because it was pulling from /sys.  i.e.: on my system, /dev/mapper/root is also /sys/block/dm-0 and /sys/dev/block/254:0/.  (i *do* *not* comprehend /sys... i've spent hours banging around in there and all i get is a headache.)  i had a very similar error today, ( http://bbs.archlinux.org/viewtopic.php?id=26118 ) and no solid idea of what caused it.

as to your second question, check out /lib/initcpio/hooks/encrypt:

if [ -n "${cryptdevice}" ]; then
            set -- $(/bin/replace "${cryptdevice}" ':'); cryptdev="$1"; cryptname="$2";
        else
            cryptdev="${root}"
            cryptname="root"
        fi
...

so, without cryptdevice, the hook de-crypts device pointed to by $root from the kernel command line and creates a mapping to /dev/mapper/root.  later we get this:

if [ -e "/dev/mapper/${cryptname}" ]; then
                if [ "${cryptname}" = "root" ]; then
                    export root="/dev/mapper/root"
                fi
...

so /dev/mapper/root replaces whatever you specified on the kernel command line.  if you're using lvm on top of the encrypted partition, that probably isn't what you want.

the [lvm2] hook finds and activates the lvm completely without reference to $root.  so it succeeds, and init moves on to the [filesystems] hook.  check this out:

:: Running Hook [filesystems]
:: Loading root filesystem module...lvm2

lvm2 is *not* the filesystem that you installed / on; your /etc/fstab clearly shows ext3.  however, [filesystems] doesn't throw an error because it looks at the block device indicated by $root.  if it finds a valid filesystem (in this case Linux LVM, a.k.a. 8e), it spits it out:

if [ -e "${root}" ]; then
eval $( /bin/fstype < "${root}" )
...
kinit_params="${kinit_params} rootfstype=${FSTYPE}"
/sbin/modprobe -q "${FSTYPE}" >/dev/null 2>&1

actually, modprobe *did* throw an error--there is no lvm2 module--but the author told it to STFU.

when $cryptdevice does get set at the kernel command-line, $cryptname gets the actual device, $root gets the proper mapping (via $cryptname, taken from the part after the ':') and then gets left alone, and [filesystems] picks it up and passes it on properly.

looks like it's time for a bug report.  you wanna, or shall i? big_smile

Last edited by kludge (2008-11-22 05:01:59)


[23:00:16]    dr_kludge | i want to invent an olfactory human-computer interface, integrate it into the web standards, then produce my own forked browser.
[23:00:32]    dr_kludge | can you guess what i'd call it?
[23:01:16]    dr_kludge | nosilla.
[23:01:32]    dr_kludge | i really should be going to bed.  i'm giggling madly about that.

Offline

#5 2008-12-30 09:50:32

dejot
Member
From: Osnabruck
Registered: 2007-04-02
Posts: 12

Re: dm_crypt + lvm -> kinit: Cannot open root device dm-0(254,0)

I have a similar problem, but the other way round.
My Layout is the following:
/dev/sda2 reiserfs /boot
/dev/sda3 LVM2 lvm
--> /dev/lvm/root (encrypted, name is "root" again, so should go to /dev/mapper/root)
--> /dev/lvm/home (doesnt really matter at this point)
--> /dev/lvm/swap (on-the-fly encrypted every boot via crypttab)

So i got a big LVM volume and three logical volumes in it, of which one is the supposed-to-be root, where i installed arch.
Now, my lines in the grub menu.lst look like the following:

root (hd0,1)
kernel /vmlinuz26 root=/dev/lvm/root ro [blabla...]
[etc]

in the /etc/fstab:

/dev/mapper/root  /  reiserfs defaults 0 1

in mkinitcpio.conf is the order "lvm2 encrypt filesystems".

So far I see nothing wrong. When booting, I'm being asked for the luks password and after entering it, the system tells me, that it loaded the reiserfs module for root partition. Ok. But then there's the exact same kernel panic as the opening poster got (somehow):

:: Running hook [lvm2]
mknod: File exists - /dev/mapper/control
Scanning logical volumes...
    Reading al physical volumes.  This may take a while...
    found volume group "lvm" using metadata type lvm2
Activating logical volumes...
    3 logical volume(s) in volume group "lvm" now active
:: Running Hook [encrypt]
A password is required to access the root volume:
Enter LUKS passphrase:
key slot 0 unlocked.
:: Running Hook [filesystems]
:: Loading root filesystem module...reiserfs
Waiting for devices to settle...done.
:: Initramfs completed - control passing to kinit
IP-Config: no devices to configure
Waiting 0 s before mounting root device...
kinit: cannot open root device dm-3(254,3)
kinit: init not found!
Kernel panic - not syncing: Attempt to kill init!

(this is as far as i remember correctly, forgot to take a shot, but why is it dm-3?)

I hope, someone knows, where I got it all wrong ... smile
Greetz,
Joe

EDIT: failed to mention that i use a 2008.06 usb image for ftp install w/o testing

Last edited by dejot (2008-12-30 13:56:04)

Offline

#6 2008-12-30 19:21:57

kludge
Member
Registered: 2008-08-03
Posts: 294

Re: dm_crypt + lvm -> kinit: Cannot open root device dm-0(254,0)

trying adding 

PS1="ramfs$ " /bin/sh -i

right before

exec /bin/kinit ...

(the last line) in /lib/initcpio/init.

when you get to the shell, run:

udevadm info --query=all --path=/block/dm-3

when i run this on my system, my equivalent of /dev/lvm/root doesn't show up anywhere.  instead, i see (among other helpful and/or insteresting tidbits):

E: DEVNAME=/dev/mapper/lvm-root

if your results are similar, try setting 'root' in the kernel boot-line to that path instead of /dev/lvm/root.

i'm not sure when the /dev/lvm/logical_volumes devices get created, but it appears that udev doesn't know about them.  and as far as i understand, kinit uses udev to find the actual device to mount as /.


[23:00:16]    dr_kludge | i want to invent an olfactory human-computer interface, integrate it into the web standards, then produce my own forked browser.
[23:00:32]    dr_kludge | can you guess what i'd call it?
[23:01:16]    dr_kludge | nosilla.
[23:01:32]    dr_kludge | i really should be going to bed.  i'm giggling madly about that.

Offline

#7 2008-12-31 10:01:23

dejot
Member
From: Osnabruck
Registered: 2007-04-02
Posts: 12

Re: dm_crypt + lvm -> kinit: Cannot open root device dm-0(254,0)

hehe, got to the ramfs prompt by replacing /dev/lvm/root in the kernel line with /dev/mapper/root and did the udevadm magic wink
funny fact: devname for dm-0 is /dev/dm-0, dm-3 doesnt exist.

Now i tried kernel /vmlinuz26 root=/dev/dm-0 with no other consequence than being not asked for the luks password but getting the kernel panic instantly big_smile
I slowly get how it all works, but no matter what i try, it stays nearly the same. I'm thinking of giving lvm inside a big cryptdevice a try. seems a bit more flexible to me anyway. after i (or you) have figured out, what's wrong with the present configuration smile

Offline

#8 2008-12-31 21:28:49

kludge
Member
Registered: 2008-08-03
Posts: 294

Re: dm_crypt + lvm -> kinit: Cannot open root device dm-0(254,0)

@dejot: this is a new install, right?  you ran (or the installer ran) mkinitcpio from within a chroot right?

well, take a look at the other thread linked to in my first post in this thread.  then, boot from an arch livecd, mount and chroot to this system.  *make* *sure* you mount /sys *within* the chroot.  then run mkinitcpio with -k matched to the chroot's kernel.  then try again.

grasping at straws, but it's worth a try.


[23:00:16]    dr_kludge | i want to invent an olfactory human-computer interface, integrate it into the web standards, then produce my own forked browser.
[23:00:32]    dr_kludge | can you guess what i'd call it?
[23:01:16]    dr_kludge | nosilla.
[23:01:32]    dr_kludge | i really should be going to bed.  i'm giggling madly about that.

Offline

Board footer

Powered by FluxBB