Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problems with an encrypted root partition and genkernel
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
GOS
Tux's lil' helper
Tux's lil' helper


Joined: 09 Sep 2010
Posts: 102
Location: Germany

PostPosted: Sun Feb 11, 2018 4:44 pm    Post subject: Problems with an encrypted root partition and genkernel Reply with quote

Hello,

on my laptop, I use the following hdd-setup:

Code:
sda1 = efi-partition
sda2 = boot-partition
sda3 = luks-partition


On the luks-partition resides the lvm-volume-group vg0. vg0 is divided into swap and root

I made an initramfs via genkernel with "genkernel --luks --lvm --symlink initramfs". (Tried this also with genkernel-next)

Now, grub calls

Code:
set root=hd0,2
linux /boot/KernelImage
initrd /boot/initramfs
crypt_root=/dev/sda3 dolvm root=/dev/mapper/vg0-root


The result (and the problem) is that the initramfs does not ask for a password:

Code:

>> Loading modules

blabla

   :: Loading from crypto:
   :: Loading from virtio:
>> Initializing root device...
!! Could not find the root block device in .
!! Please specify another value or:

blabla


What I am doing wrong?

PS: Without the luks-thing the whole efi-thing and my kernel works well.
PPS: If I go into generkel's shell, the cryptsetup luksOpen /dev/sdb3 luks-dev seems to work
PPPS: Also with UUID's there is no success
Back to top
View user's profile Send private message
GOS
Tux's lil' helper
Tux's lil' helper


Joined: 09 Sep 2010
Posts: 102
Location: Germany

PostPosted: Sat Feb 17, 2018 10:00 pm    Post subject: Reply with quote

Weather genkernel nor dracut works for me.

Now, I use a custom initramfs which does the trick. The following script creates the initramfs:

Code:

#!/bin/bash

#----------------------------------------------------------------------
# Generate neccessary directories and copy necessary files
#----------------------------------------------------------------------

mkdir -p /var/tmp/BuildInitramfs/{bin,dev,etc/lvm,lib,lib64,mnt/root,proc,root,run/blkid,run/lock/lvm,run/lvm,run/cryptsetup,sbin,sys,usr}
cp /bin/busybox /var/tmp/BuildInitramfs/bin
cp /sbin/lvm.static /var/tmp/BuildInitramfs/sbin
cp /sbin/cryptsetup /var/tmp/BuildInitramfs/sbin


#---------------------------
# Generate etc/lvm/lvm.conf
#---------------------------

cat << EOF > /var/tmp/BuildInitramfs/etc/lvm/lvm.conf
global {
   use_lvmetad = 0
}

activation {
   udev_sync = 0
   udev_rules = 0
}

devices {
   issue_discards = 1
}

EOF


#--------------------------
# Generate the init-script
#--------------------------

cat << EOF > /var/tmp/BuildInitramfs/init
#!/bin/busybox sh

# Define the rescue_shell
rescue_shell(){
   echo "Es gab Funktionsprobleme. Oeffne die Notfall Shell."
   busybox --install -s
   exec /bin/sh
}


# Mount /dev, /proc and /sys filesystems
mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys

# Deactivate useless kernel messages
echo 0 > /proc/sys/kernel/printk

# Decrypt the drive
echo ""
echo "======================"
echo " Decrypt HDD for boot"
echo "======================"
echo ""
cryptsetup --allow-discards luksOpen /dev/sdb3 CryptoDev1
wait

# Activate the lvm volume group
lvm.static vgscan --mknodes
lvm.static lvchange -a ly CryptoVg1/root
lvm.static vgscan --mknodes
wait

# Mount the root-partition
mount -o ro /dev/mapper/CryptoVg1-root /mnt/root || rescue_shell
wait

# Clean up
echo 1 > /proc/sys/kernel/printk
mount --move /proc /mnt/root/proc
mount --move /sys /mnt/root/sys
mount --move /dev /mnt/root/dev
wait

# Switcheroo
exec switch_root /mnt/root /sbin/init

EOF

chmod a+rx /var/tmp/BuildInitramfs/init


#-----------------------
# Build the Initramfs
#-----------------------

cd /var/tmp/BuildInitramfs
find . -print0 | cpio --null -ov --format=newc | gzip -9 > /boot/Initramfs.cpio.gz
cd /

#--------------------------------
# Delete temporary files
#--------------------------------

rm -rf /var/tmp/BuildInitramfs

exit
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