Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] initramfs -> "cannot initialize crypto backend"
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Jimini
Guru
Guru


Joined: 31 Oct 2006
Posts: 590
Location: Germany

PostPosted: Sat Nov 01, 2014 9:41 pm    Post subject: [solved] initramfs -> "cannot initialize crypto back Reply with quote

Hey there,
I decided to switch from Debian back to Gentoo again, so I set up a system with the following partition layout:
/dev/sda1 -> /boot
/dev/sda2 -> /root (encrypted and mapped as /dev/mapper/root)

At the moment, I am struggling with the needed initramfs. I built it into the kernel, but when I boot up the system, I get the error message "Cannot initialize crypto backend".

I used the following guides and resources:
http://gentoo-en.vfose.ru/wiki/Initramfs
http://wiki.gentoo.org/wiki/Custom_Initramfs
https://forums.gentoo.org/viewtopic-t-909722-start-0.html
http://gentoo-en.vfose.ru/wiki/DM-Crypt_with_LUKS#Creating_initramfs_image
http://gentoo-en.vfose.ru/wiki/Root_filesystem_over_LVM2,_DM-Crypt_and_RAID#Initram

I created the data structure as shown here:
Code:
mkdir /usr/src/initramfs
cd initramfs
mkdir bin dev dev/mapper dev/vc etc newroot proc sys
cp /bin/busybox /sbin/cryptsetup bin/
ln -s busybox bin/cat
ln -s busybox bin/mount
ln -s busybox bin/sh
ln -s busybox bin/switch_root
ln -s busybox bin/umount
ln -s busybox bin/sleep
cp -a /dev/console /dev/sda1 /dev/sda2 /dev/null /dev/random /dev/urandom dev


My init looks like following:
Code:
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
# check if /dev contains the needed devices
ls -l /dev
CMDLINE='cat /proc/cmdline

rescue_shell() {
     echo "Something went wrong. Opening a shell:" >&2'
     /bin/sh </dev/tty1 >/dev/tty1 2>&1
}
cryptsetup luksOpen /dev/sda2 vault || rescue_shell
mount -r /dev/mapper/root /newroot || rescue_shell
CMDLINE=`cat /proc/cmdline`
umount /sys
umount /proc
exec /bin/busybox switch_root /newroot /sbin/init ${CMDLINE}


To me it seems, as if the content of /dev is inaccessible - although "ls -l" shows, that /dev contains the files which I copied there. But it looks as /dev/random and /dev/urandom cannot be used by cryptsetup. It is also not possible to start the rescue shell.

I have tried setting up the initramfs a few times and am now stuck, since I do not know what I could try to get this thing to work. Any help would be _really_ appreciated.

Best regards,
Jimini

Addendum: when "ls -l" shows the content of /dev, the file names are pink. Shouldn't the names be yellow? Perhaps this is a useful hint.
_________________
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)


Last edited by Jimini on Thu Nov 27, 2014 9:42 am; edited 2 times in total
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13842

PostPosted: Sat Nov 01, 2014 10:35 pm    Post subject: Reply with quote

Why are you using a static dev in the initramfs instead of a devtmpfs? You have no tty1 in the static dev, so your rescue shell will not work correctly. Although what you showed can work for an initramfs, it requires root to setup. For compatibility with unprivileged builds, I prefer using the initramfs file list form, where you give the kernel a file which lists what files, directories, and special nodes to place in the generated archive.
Back to top
View user's profile Send private message
Jimini
Guru
Guru


Joined: 31 Oct 2006
Posts: 590
Location: Germany

PostPosted: Sun Nov 02, 2014 5:56 am    Post subject: Reply with quote

Hu, thank you for your reply.

Regarding static /dev vs devtmpfs, I have no personal preference - I just set it up this way because most of the guides describe the procedure like this. You mention a "initramfs file list form", but I could not find any information on that. Could you explain how to set up an initramfs without a static /dev, but with the needed devices? That would be awesome.

Simply mounting a devtmpfs in my initramfs does not solve the problem - I have /dev, but the errors stay the same ("Cannot initialize crypto backend", "Can't access tty; job control turned off").

Edit: nevermind, I had a look at http://wiki.gentoo.org/wiki/Early_Userspace_Mounting#Generating_the_Initramfs and will try this method now.
Edit2: I followed the steps which are described in the link above, the system still does not boot. I am trying to figure out, why.
Edit3: it seems, as if the problem was a missing kernel module. Don't know yet, which one exactly, but my system boots :)

Best regards,
Jimini
_________________
"The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents." (H.P. Lovecraft: The Call of Cthulhu)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum