Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
dracut failed, droped to shell how to finish booting?[solved
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
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1696

PostPosted: Sun Oct 27, 2024 6:17 am    Post subject: dracut failed, droped to shell how to finish booting?[solved Reply with quote

Update for anyone else the answer is you simply type
Code:
exit
and dracut continues booting
:D
Greetings Gentooers
I am setting up a new Gentoo system (on bare metal) and usually make a initrd by hand for encrypted root but its been quite a few years and hand rolling was always tedious compiling stuff with static-libs then recompiling without so figured I'd try out Dracut.
This install has a encrypted root inside an LVM logical volume. I know the volume and encrypted root are good because I can mount them from the live USB. And I do realize this is the reverse of the Gentoo way of putting lvm in the encrypted drive, but this is just a router appliance and I digress.
Things have not gone very smoothly with Dracut, at first I assumed dracut would copy over the needed kernel modules but it does not seem to do that.
Also it throws allot of systemd-cryptsetup not found errors even after I configured it
Code:
hostonly="yes"
# Equivalent to -a "module"
add_dracutmodules+=" lvm crypt " # Note leading and trailing spaces
omit_drivers+=" systemd systemd-cryptsetup bluetooth "

After I reconfigured the kernel like I used to with all the Lvm and Crypt stuff BLK_DEV_CRYPTOLOOP CONFIG_DM_CRYPT ... compiled into the kernel (not as modules but compiled in) Dracut was getting closer telling me my /dev/mapper/gentoo_root does not exist.
After somehow dropping to the Dracut rescue shell (which is apparently not busybox?) I can poke around and see something named my /dev/mappter/gentoo_root something slightly different, it prefixed the logical volume name.
So I was finally able to manually unlock my root partition and mount it under /sysroot
Poking around I could see it mounted and my files were there.
I then tried
Code:
exec switch_root /sysroot /sbin/init
with no dice.
I possibly forgot to unmount proc sys and dev
So my question, how to you , finish booting from a Dracut rescue shell?
Should
Code:
exec switch_root /sysroot /sbin/init
work?
Thanks in advance

Docs I have used now and in the past:
https://wiki.gentoo.org/wiki/Dracut
https://wiki.gentoo.org/wiki/Dm-crypt
https://wiki.gentoo.org/wiki/LVM
https://wiki.gentoo.org/wiki/Custom_Initramfs
_________________
Donate to Gentoo


Last edited by turtles on Sun Oct 27, 2024 9:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3759
Location: Rasi, Finland

PostPosted: Sun Oct 27, 2024 8:53 am    Post subject: Reply with quote

Does the switch_root command give you any errors?
IIRC switch_root won't work unless it was exec'd from PID 1. And in case of busybox, I remember it didn't print any useful information if it failed in such way.
If you exit the rescue shell and you don't get kernel panic, it means it wasn't PID 1, and thus you cannot switch_root from there. Then you need to set the environment as such that dracut can continue booting (which is a limitation in my opinion).

BTW, if you want, you could try using my cinitramfs, which helps you create your own initramfs image (no static binaries needed necessarily).
It's very much WIP still. It works by reading a list of files, modules, etc from standard input and the outputs a cpio image. It handles most of the dependencies for C programs and modules at least. The extras directory contains example initramfs init script too. But you can write your own.
I'm using cinitramfs on all of my Gentoo setups which all use lvm/device mapper, but no ecryption. But it should work if you include all the commands required to unlock the filesystem.

_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!


Last edited by Zucca on Sun Oct 27, 2024 3:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1935

PostPosted: Sun Oct 27, 2024 1:37 pm    Post subject: Reply with quote

turtles wrote:
Code:
omit_drivers+=" systemd systemd-cryptsetup bluetooth "

This line is wrong. omit_drivers is for kernel modules when you are listing dracut modules.
Perhaps you mean omit_dracutmodules instead.

I cannot comment on other crypt stuff though.
Back to top
View user's profile Send private message
zen_desu
n00b
n00b


Joined: 25 Oct 2024
Posts: 35

PostPosted: Sun Oct 27, 2024 4:13 pm    Post subject: Reply with quote

Have you tried following this guide or using ugrd? It should handle lvm under luks with no config.

https://wiki.gentoo.org/wiki/Rootfs_encryption#UGRD
https://wiki.gentoo.org/wiki/Rootfs_encryption#Dracut
Back to top
View user's profile Send private message
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1696

PostPosted: Sun Oct 27, 2024 5:26 pm    Post subject: Reply with quote

Zucca wrote:
Does the switch_root command give you any errors?
IIRC switch_root won't work unless it was exec'd from PID 1. And in case of busybox, I remember it didn't print any useful information if it failed in such way.
If you exit the rescue shell and you don't get kernel panic, it means it wasn't PID 1, and thus you cannot switch_root from there. Then you need to set the environment as such that dracut can continue booting (which is a limitation in my opinion).

OK just tried it again
This time I confirmed my /root partition got opened by cryptsetup but again got named based on its uuid and dracut failed to mount it.
I got dropped to the dracut shell (which I am not sure what keys to press to get to)
I mounted my root partition at /sysroot
then ran
Code:
umount /proc
umount /sys
umount /dev
exec switch_root /sysroot /sbin/init

Then dracut goes into a infinate loop I had to snap a photo with my phone to catch the error
Code:

/lib/dracut-lib.sh: line 201 dracut-getarg: command not found
/lib/dracut-lib.sh: line 72: /dev/kmsg: No such file or directory


I am sure I'll figure out the weird naming issue it like dracut needs a cryptab file, its not getting the setting correct.
But I am just currious for me in the future and other users is it possible to continue booting from the dracut cmd line?
Like when grub fails you can get into the grub cmd line and fix a issue keep booting.
Thanks

Zucca wrote:

BTW, if you want, you could try using my cinitramfs, which helps you create your own initramfs image (no static binaries needed necessarily).

Thanks I'll check that out
I am curious about Dracut as I'll need to use it at work also
_________________
Donate to Gentoo
Back to top
View user's profile Send private message
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1696

PostPosted: Sun Oct 27, 2024 5:29 pm    Post subject: Reply with quote

grknight wrote:
turtles wrote:
Code:
omit_drivers+=" systemd systemd-cryptsetup bluetooth "

This line is wrong. omit_drivers is for kernel modules when you are listing dracut modules.
Perhaps you mean omit_dracutmodules instead.

I cannot comment on other crypt stuff though.


Thank you that eliminited the systemd errors when dracut ran.
Which eliminated that as a possible issue.
Its an openRC system, so no systemd stuff.
_________________
Donate to Gentoo
Back to top
View user's profile Send private message
zen_desu
n00b
n00b


Joined: 25 Oct 2024
Posts: 35

PostPosted: Sun Oct 27, 2024 5:33 pm    Post subject: Reply with quote

turtles wrote:
Zucca wrote:
Does the switch_root command give you any errors?
IIRC switch_root won't work unless it was exec'd from PID 1. And in case of busybox, I remember it didn't print any useful information if it failed in such way.
If you exit the rescue shell and you don't get kernel panic, it means it wasn't PID 1, and thus you cannot switch_root from there. Then you need to set the environment as such that dracut can continue booting (which is a limitation in my opinion).

OK just tried it again
This time I confirmed my /root partition got opened by cryptsetup but again got named based on its uuid and dracut failed to mount it.
I got dropped to the dracut shell (which I am not sure what keys to press to get to)
I mounted my root partition at /sysroot
then ran
Code:
umount /proc
umount /sys
umount /dev
exec switch_root /sysroot /sbin/init

Then dracut goes into a infinate loop I had to snap a photo with my phone to catch the error
Code:

/lib/dracut-lib.sh: line 201 dracut-getarg: command not found
/lib/dracut-lib.sh: line 72: /dev/kmsg: No such file or directory


I am sure I'll figure out the weird naming issue it like dracut needs a cryptab file, its not getting the setting correct.
But I am just currious for me in the future and other users is it possible to continue booting from the dracut cmd line?
Like when grub fails you can get into the grub cmd line and fix a issue keep booting.
Thanks



You can't manually switch_root in most cases because it must be executed as PID1, if your shell is not the init process, this will not function.

I'm pretty sure the crypttab stuff requires systemd integration. If you do not have systemd modules in Dracut, that will not be processed. Dracut generally relies on luks volume info being passed in the kernel command line.
_________________
µgRD dev
Wiki writer
Back to top
View user's profile Send private message
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1696

PostPosted: Sun Oct 27, 2024 9:44 pm    Post subject: Reply with quote

zen_desu wrote:

You can't manually switch_root in most cases because it must be executed as PID1, if your shell is not the init process, this will not function.

OK yeah you can't manually from the Dracut shell (which i am still not sure what shell its using) but I was able to enter the shell and manually mount my crypt root the way dracut named it.
Then I had to create a symlink to /dev/mapper/gentoo_root from the /dev/mapper/luks-<uuid> Dracut and or udev gave me.
Then instead of running
Code:
exe switch_root
from the Dracut shell I just typed
Code:
exit
and Dracut switched root successfully.
zen_desu wrote:

I'm pretty sure the crypttab stuff requires systemd integration. If you do not have systemd modules in Dracut, that will not be processed.

Yeah no it works fine without systemd
_________________
Donate to Gentoo
Back to top
View user's profile Send private message
zen_desu
n00b
n00b


Joined: 25 Oct 2024
Posts: 35

PostPosted: Sun Oct 27, 2024 10:56 pm    Post subject: Reply with quote

turtles wrote:
zen_desu wrote:

You can't manually switch_root in most cases because it must be executed as PID1, if your shell is not the init process, this will not function.

OK yeah you can't manually from the Dracut shell (which i am still not sure what shell its using) but I was able to enter the shell and manually mount my crypt root the way dracut named it.
Then I had to create a symlink to /dev/mapper/gentoo_root from the /dev/mapper/luks-<uuid> Dracut and or udev gave me.
Then instead of running
Code:
exe switch_root
from the Dracut shell I just typed
Code:
exit
and Dracut switched root successfully.
zen_desu wrote:

I'm pretty sure the crypttab stuff requires systemd integration. If you do not have systemd modules in Dracut, that will not be processed.

Yeah no it works fine without systemd


What config are you currently using?

https://wiki.gentoo.org/wiki/Rootfs_encryption#Initramfs_configuration

I recently updated this a bit, it should contain everything you need. If you use dracut with hostonly mode you may have better results.

Currently ugrd only supports LVM under LUKS, but I added this toggle if you'd like to try: https://github.com/desultory/ugrd/pull/95
_________________
µgRD dev
Wiki writer
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3759
Location: Rasi, Finland

PostPosted: Sun Oct 27, 2024 11:28 pm    Post subject: Reply with quote

I came back to this topic in intention of recommending ugrd, since it seem to support encrypted volumes.
But I was too late. ;)
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1696

PostPosted: Mon Oct 28, 2024 2:07 am    Post subject: Reply with quote

Zucca wrote:
I came back to this topic in intention of recommending ugrd, since it seem to support encrypted volumes.
But I was too late. ;)

Never too late I'll check it out:
https://wiki.gentoo.org/wiki/UgRD
_________________
Donate to Gentoo
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