View previous topic :: View next topic |
Author |
Message |
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Wed Feb 21, 2024 9:30 am Post subject: [SOLVED] EFI Stub + custom Initramfs: Attempted to kill Init |
|
|
Hello.
This is my first time writing a post on this forum (and on any Linux-related forum in general), I'm writing 'cause I never struggled so badly in my entire lifebeing. So I gently ask for your assistance and patience.
I was building a kernel with this setup in mind: LUKS + Secure Boot + LVM + EFI Stub + Custom initramfs built-in kernel, according to Gentoo documentation, ofc. And if I successfully completed the first mentioned trio, the latter two got me really stuck.
I have the following problem:
Attempted to kill init, busybox not tainted, busybox used greatest stack depth.
Attaching the image of kernel boot problem:
https://mega.nz/file/WqJ1GIDB#pMEnVxaWswEeeQsSCNybFKEX06PVbLaZaLUsv9v6JCk
What I tried to do:
– Adding /dev/null and /dev/console to /dev/ folder inside initramfs (also it takes forever to copy /dev/console, I wonder why's that).
– Enforcing/disabling SElinux in /etc/selinux/config according to: https://stackoverflow.com/questions/12867591/ddg#19839356
– Adjusting initramfs script (adding /dev/console to switch_root statement e.g.).
– Modifying kernel boot parameters with efibootmgr (How to load microcode in EFI Stub early on boot? I saw usages like initrd=/early_ucode.cpio, adding the cpio boot archive there, but it didn't work)
– Modifying kernel .config file.
None of these helped.
ldd says:
Code: | ldd: /bin/busybox: Not a valid dynamic program
ldd: /sbin/cryptsetup: Not a valid dynamic program |
Thus, busybox and cryptsetup are statically linked and no additional libraries to include at boot are required.
.config file:
https://dpaste.com/5E8EYMV4U.txt
Initramfs Script:
https://bpa.st/raw/EBCA
EFI directory tree:
https://bpa.st/XVIA
Would be glad of any help. If you need any further info for troubleshooting, let me know.
Regards.
Last edited by KZQN7737 on Wed Mar 06, 2024 6:42 pm; edited 1 time in total |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1569 Location: South America
|
Posted: Wed Feb 21, 2024 1:00 pm Post subject: |
|
|
It looks like the /init script from the initramfs exited with an error code. Since it runs as process 1, that results in a kernel panic.
The initramfs' init script must be in /. Did you put it in /sbin?
Also, if you are only having busybox and a couple of other programs in the initramfs, you can't use commands like mount, sleep, etc., unless you know that they are BusyBox shell builtins. You either call them as e. g. busybox mount (with an appropriate value of PATH; I don't remember if the BusyBox shell has a default one), or you create a symlink to the busybox program in the initramfs (e. g. /bin/mount —> busybox).
Although I seem to remember that there was a compile-time option in BusyBox that told the shell implementation to try using compiled-in applets before looking for executables in the filesystem.
KZQN7737 wrote: | ldd says:
Code: | ldd: /bin/busybox: Not a valid dynamic program
ldd: /sbin/cryptsetup: Not a valid dynamic program |
Thus, busybox and cryptsetup are statically linked and no additional libraries to include at boot are required. |
/sbin/lvm must be as well. _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 4413 Location: Bavaria
|
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Wed Feb 21, 2024 2:53 pm Post subject: |
|
|
Hi and thanks GDH.
GDH-gentoo wrote: | The initramfs' init script must be in /. Did you put it in /sbin? |
Indeed. It was the case. I wonder why it was there and why it should be in root directory of initramfs instead. It's just the default location where EFI Stub kernel searches for the script or is there another explanation?
KZQN7737 wrote: | ldd says:
Code: | ldd: /bin/busybox: Not a valid dynamic program
ldd: /sbin/cryptsetup: Not a valid dynamic program |
|
GDH-gentoo wrote: | /sbin/lvm must be as well. |
It is. But for some reason lvm is named lvm.static.
Code: | ldd: /sbin/lvm.static: Not a valid dynamic program
ldd: cannot load /sbin/lvm: No such file or directory
|
GDH-gentoo wrote: | you can't use commands like mount, [...], unless you know that they are BusyBox shell builtins. |
Probably a noob question, but how do I check if they're builtins or not?
Quote: | You either call them as e. g. busybox mount (with an appropriate value of PATH; I don't remember if the BusyBox shell has a default one), |
I know of existence of path variable, but unfortunately I fail to see how it's applied here in context of Busybox. Could you please clarify?
Code: | echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin |
Quote: | or you create a symlink to the busybox program in the initramfs
(e. g. /bin/mount —> busybox). |
If I understood you correctly, I should do something like:
Code: | ln -s /bin/mount /boot/efi/initramfs/bin/busybox
ln: failed to create symbolic link '/boot/efi/initramfs/bin/busybox': File exists
|
Last edited by KZQN7737 on Mon Feb 26, 2024 11:34 am; edited 1 time in total |
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Wed Feb 21, 2024 3:28 pm Post subject: |
|
|
Hi pietinger and thanks.
Answering your question, it is built as an embedded initramfs.
pietinger wrote: | Your exit of init is wrong: exec switch_root -c /dev/console /newroot /sbin/init
It must be: exec switch_root /mnt/root /sbin/init .... or in your case: exec switch_root /newroot /sbin/init
|
I added -c /dev/console only recently (saw this usage somewhere on the Internet forums, maybe Gentoo as well) and it did not change the error.
Here is my boot entry command:
Code: | efibootmgr -d /dev/nvme0n1 -p 1 -c -l "\efi\EFI\bzImageSign.efi" -L "Gentoo EFI STUB Signed TEST" -u "rd.luks/name=23c82627-a379-4ca9-83bf-72c4bcd4ba87=cryptroot root=/dev/mapper/vg-root initrd=/early_ucode.cpio selinux=0" |
|
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 4413 Location: Bavaria
|
Posted: Wed Feb 21, 2024 3:35 pm Post subject: |
|
|
KZQN7737 wrote: | Here is my boot entry command:
Code: | efibootmgr -d /dev/nvme0n1 -p 1 -c -l "\efi\EFI\bzImageSign.efi" -L "Gentoo EFI STUB Signed TEST" -u "rd.luks/name=23c82627-a379-4ca9-83bf-72c4bcd4ba87=cryptroot root=/dev/mapper/vg-root initrd=/early_ucode.cpio selinux=0" |
|
This will not work because of: "intrd=/..." It must be: "initrd=\..." IF using an external CPIO archive. When using an embedded initrmafs it is not necessary (because you will not have an external CPIO). But please check:
Code: | CONFIG_INITRAMFS_SOURCE="/boot/efi/initramfs/sbin/" |
Maybe you want:
Code: | CONFIG_INITRAMFS_SOURCE="/boot/efi/initramfs/" |
_________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 4413 Location: Bavaria
|
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1569 Location: South America
|
Posted: Wed Feb 21, 2024 5:00 pm Post subject: |
|
|
KZQN7737 wrote: | Indeed. It was the case. I wonder why it was there and why it should be in root directory of initramfs instead. It's just the default location where EFI Stub kernel searches for the script or is there another explanation? |
It's simply that the kernel is programmed to look for a file named init in the root directory of the initramfs and execute it as root.
KZQN7737 wrote: | Probably a noob question, but how do I check if they're builtins or not? |
The list of BusyBox shell builtins is documented I think, I'll see where it is later.
KZQN7737 wrote: | I know of existence of path variable, but unfortunately I fail to see how it's applied here in context of Busybox. Could you please clarify? |
When a shell script contains a command like:
Code: | mount -t sysfs sys /sys |
or
Code: | busybox mount -t sysfs sys /sys |
what happens is that a file with the same name as the first word of the command ("mount" in the first case and "busybox" in the second) will be searched in the directories specified by the value of PATH, in the order specified. The first one found is executed. If no such file is found, the command fails.
The same happens with the /init script, but with the initramfs as the root filesystem for that search.
I believe that BusyBox has a default value of PATH, that starts with /sbin:/usr/sbin:/bin:/usr/bin.
KZQN7737 wrote: | If I understood you correctly, I should do something like:
Code: | ln -s /bin/mount /boot/efi/initramfs/bin/busybox
ln: failed to create symbolic link '/boot/efi/initramfs/bin/busybox': File exists
|
|
Yes, but the correct command would be ln -s busybox /boot/efi/initramfs/bin/mount. _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
Last edited by GDH-gentoo on Wed Feb 21, 2024 11:00 pm; edited 2 times in total |
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Wed Feb 21, 2024 6:07 pm Post subject: |
|
|
Dear pietinger,
pietinger wrote: | This will not work because of: "intrd=/..." It must be: "initrd=\..." IF using an external CPIO archive. When using an embedded initrmafs it is not necessary (because you will not have an external CPIO). |
I wanted to load intel microcode cpio archive on boot alongside with embedded initramfs kernel, that's why I've put initrd in boot parameters. For a millisecond it outputted a screen before ("failed to open initrd"), and proceeded to load "Attempted to kill init", but now I've got this parameter off.
Quote: |
But please check:
Code: | CONFIG_INITRAMFS_SOURCE="/boot/efi/initramfs/sbin/" |
Maybe you want:
Code: | CONFIG_INITRAMFS_SOURCE="/boot/efi/initramfs/" |
|
Thank you for noticing /sbin/ in config_initramfs_source, I totally forgot about that, it was for testing purposes.
I moved init to its proper place (/boot/efi/initramfs/init), changed CONFIG_INITRAMFS_SOURCE, recompiled the kernel, moved the kernel image to the proper directory and signed, but the problem is still persistent. |
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Wed Feb 21, 2024 6:32 pm Post subject: |
|
|
Dear GDH,
Thank you for the explanations.
When I try to run:
Code: | ln -s busybox /boot/efi/initramfs/bin/mount |
I stumble upon permission error:
Code: | ln: failed to create symbolic link '/boot/efi/initramfs/bin/mount': Operation not permitted |
Even though:
Code: | drwxr-xr-x 2 root root 4096 Feb 2 14:38 bin |
I've tried to modify permissions with chmod, but no luck.
I had the very same error previously when I attempted to copy /dev/null and /dev/console into initramfs' /dev/ directory. It was solved by itself (Idk magic perhaps ). |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54423 Location: 56N 3W
|
Posted: Wed Feb 21, 2024 6:47 pm Post subject: |
|
|
KZQN7737,
It time to add some debug to your initramfs init script.
Add the function Code: | rescue_shell() {
echo "$@"
echo "Something went wrong. Dropping you to a shell."
# The symlinks are not required any longer
# but it helps tab completion
/bin/busybox --install -s
exec /bin/sh
} | to the top of the script.
Now you can do things like
Code: | /sbin/lvm vgscan || rescue_shell "vgscan failed" |
Code: | # Mount the root filesystem and other LVM logical volumes for different folders.
mount /dev/mapper/vg-home /newroot/home
mount /dev/mapper/vg-root /newroot
mount /dev/mapper/vg-var /newroot/var |
Order matters Code: | mount /dev/mapper/vg-root /newroot | must be first as the other mount points will not exist until that works.
Code: | mount /dev/mapper/vg-root /newroot || rescue_shell "Failed to mount vg-root" |
and so on may be more useful
When it fails now, you know where and can look around to see why.
It's also possible to try commands by hand.
You don't have /sbin/lvm, it will be /sbin/lvm.static
Use /sbin/lvm.static or add a symlink. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 4413 Location: Bavaria
|
Posted: Wed Feb 21, 2024 7:28 pm Post subject: |
|
|
KZQN7737 wrote: | I wanted to load intel microcode cpio archive on boot alongside with embedded initramfs kernel, [...] |
When using an embedded initramfs, include the microcode into your kernel (together with your used firmware files); TODAY it is easier than you think:
https://forums.gentoo.org/viewtopic-t-1065464.html
(This is my line: CONFIG_EXTRA_FIRMWARE="i915/adls_dmc_ver2_01.bin intel-ucode/06-b7-01 rtl_nic/rtl8125b-2.fw i915/tgl_guc_70.bin i915/tgl_huc.bin" ) _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1569 Location: South America
|
Posted: Wed Feb 21, 2024 8:03 pm Post subject: |
|
|
KZQN7737 wrote: | When I try to run:
Code: | ln -s busybox /boot/efi/initramfs/bin/mount |
|
The pathname (and earlier output of tree) is suspicious, is /boot/efi/initramfs on the FAT filesystem of the EFI System Partition? If yes, FAT doesn't support symlinks, build the initramfs elsewhere. _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Thu Feb 22, 2024 10:38 am Post subject: |
|
|
Dear everyone,
TYSM for the answers.
I gotta report about my actions.
1. According to NeddySeagoon,
NeddySeagoon wrote: | Order matters Code: | mount /dev/mapper/vg-root /newroot |
must be first as the other mount points will not exist until that works.
Code: | mount /dev/mapper/vg-root /newroot || rescue_shell "Failed to mount vg-root" |
|
I changed the order of mounting directories and added a rescue shell (but it still didn't drop me there).
Maybe it's because I added the function after shebang. Should I add the script even before script declaration (shebang !#/bin/busybox sh)? Seems counter-intuitive to do so.
Modified initramfs script:
https://bpa.st/HUSCQ
2. I followed pietinger's advice.
And figured out my cpu's model hex. value and included microcode inside the kernel according to the given link.
Unsure whether the microcode works, because the boot screen is running quite fast, so I'm unable to see whether there was a message about microcode loading. However, I have no previous screen appearing with an error of "initrd not found".
3. According to GDH,
GDH-gentoo wrote: | If yes, FAT doesn't support symlinks, build the initramfs elsewhere. |
Yes, it's on the separate /dev/nvme1p1 unencrypted boot EFI partition vfat (FAT32 specifically). I've read abt smth like that while I was trying to resolve problem with copying /dev/{null,console}.
I moved initramfs folder to somewhere else, in my case to /usr/src/ and was successfully able to create a soft link for busybox mount and for /sbin/lvm.static.
I yet remain uncertain about how the kernel is able to read initramfs script in RAM from an encrypted volume.
Same goes for the Secure Boot keys, but they're stored somewhere in UEFI's CMOS, I suppose.
After that, my boot proceeded a bit further, although, "Attempted to kill init" is persistent.
Attaching image of the new kernel error message:
https://mega.nz/file/nzxgEaya#Jjb67MZpmPoF4okMfR-wMSHGbguovaltwb_yBL_xzPs
It's more like a kernel/hardware issue, so it seems to me. Kernel waits for some abstract /dev/sda1, doesn't find it, and thus, panics.
When I detach USB, it doesn't even reach searching for /dev/sda1 and when it doesn't find the USB, panics.
What's even more interesting, when I attach SCSI external drive, then it searches for /dev/sdb1 after /dev/sda1, doesn't find it and panics.
Why it that? Why are they required to boot?
I checked my /etc/fstab and it's basically all commented and empty. But I'm unsure what mountpoint should I specify for EFI Stub partition /dev/nvme0n1p1.
/dev/nvme1p2 is encrypted, so it's unable to automount without initramfs. |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1569 Location: South America
|
Posted: Thu Feb 22, 2024 12:30 pm Post subject: |
|
|
The last call to switch_root should be exec switch_root /newroot /sbin/init, that is, the init program or script in the /sbin directory of the filesystem in /dev/mapper/vg-root is what should be run as process 1 after switching the rootfs.
KZQN7737 wrote: | I yet remain uncertain about how the kernel is able to read initramfs script in RAM from an encrypted volume. |
I does not. You have an embedded initramfs, so it is contained in bzImageSign.efi. The initramfs directory in /usr/src is only used at kernel build time to generate the real embedded initramfs.
KZQN7737 wrote: | Same goes for the Secure Boot keys, but they're stored somewhere in UEFI's CMOS, I suppose. |
Yes, they are stored in a nonvolatile storage device on your motherboard that its UEFI firmware can access.
The message is slightly different. The /init script still seems to exit, but with a different error code (0). If the LUKS container is opened with a passphrase, are you prompted for one? Is the "Hello World." message ever displayed? _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Thu Feb 22, 2024 2:35 pm Post subject: |
|
|
GDH-gentoo wrote: | That is, the init program or script in the /sbin directory of the filesystem in /dev/mapper/vg-root is what should be run as process 1 after switching the rootfs. |
Thanks. I got it. I'll modify this one and I'll answer once I'll be able to modify.
Quote: | the LUKS container is opened with a passphrase, are you prompted for one? Is the "Hello World." message ever displayed? |
No, for each and every question. |
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Sat Feb 24, 2024 7:18 pm Post subject: |
|
|
UPD: I've changed last line of my initramfs init script from /init to /sbin/init and nothing has changed.
2 variants of booting:
1. The booting process is stuck on the line "Attached SCSI removable disk" and doesn't move further.
And "Attempted to kill init!" doesn't appear no matter for how long you wait.
2. Now, instead of "busybox not tainted" it's printing "sh not tainted".
Every other time. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54423 Location: 56N 3W
|
Posted: Sat Feb 24, 2024 7:34 pm Post subject: |
|
|
KZQN7737,
I suspect that Code: | /sbin/lvm vgscan || rescue_shell "vgscan failed" | nevor fails, even if nothing is found.
Add The rescue_shell call, with a useful error message, after
Code: | /sbin/lvm vgchange -ay
mount /dev/mapper/vg-root /newroot
mount /dev/mapper/vg-home /newroot/home
mount /dev/mapper/vg-var /newroot/var | too.
I do in like Initramfs - make your own _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Sun Feb 25, 2024 3:36 pm Post subject: |
|
|
Hi, NeddySeagoon.
If I got you right and did as you told:
NeddySeagoon wrote: |
Add The rescue_shell call, with a useful error message, after
Code: | /sbin/lvm vgchange -ay
mount /dev/mapper/vg-root /newroot
mount /dev/mapper/vg-home /newroot/home
mount /dev/mapper/vg-var /newroot/var | too.
|
Here's my initramfs script:
Code: |
#!/bin/busybox sh
# Call the busybox shell.
rescue_shell() {
echo "$@"
echo "Something went wrong. Dropping you to a shell."
# The symlinks are not required any longer
# But it helps tab completion.
/bin/busybox --install -s
exec /bin/sh
}
# Mount temporary filesystems.
mount -t procfs proc /proc
mount -t sysfs sys /sys
mount -t devtmpfs udev /dev
# Custom message.
echo "Hello World."
# Attempt to open the encrypted root file system (Prompt for a password).
# -T 5 equals --tries 5
/sbin/cryptsetup -T 5 luksOpen /dev/nvme0n1p2 cryptfs
# Wait for password prompt to appear on the screen.
sleep 10
# LVM: enable partitions.
/sbin/lvm vgscan || rescue_shell "vgscan failed"
/sbin/lvm vgchange -ay || rescue_shell "vgchange failed"
sleep 10
# Mount the root filesystem and other LVM logical volumes for different folders.
mount /dev/mapper/vg-root /newroot || rescue_shell "root mount failed"
mount /dev/mapper/vg-home /newroot/home || rescue_shell "home mount failed"
mount /dev/mapper/vg-var /newroot/var || rescue_shell "var mount failed"
sleep 10
# Clean up.
umount -l /proc
umount -l /sys
umount -l /dev
# Switch from initramfs to actual root file system.
exec switch_root /newroot /sbin/init
|
Here are the screens of messages I get on booting:
https://mega.nz/file/r6oRAbhR#FA8cMBsU3ZCYFuPxoqdNlD4gGFkXnC5bln7DQTVPeVQ
https://mega.nz/file/evAxUIQI#ZhL2zmjICKLw8hfR9-yJq1sngHFx2poOiTGm2d7PjPk |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 21867
|
Posted: Sun Feb 25, 2024 4:53 pm Post subject: |
|
|
KZQN7737 wrote: | Code: | # Attempt to open the encrypted root file system (Prompt for a password).
# -T 5 equals --tries 5 |
| cryptsetup understands --tries, so you could remove the comment and use the long form option to make it self-documenting. KZQN7737 wrote: | Code: | # Wait for password prompt to appear on the screen.
sleep 10 |
| The password prompt is written by cryptsetup, which does not return until you enter the password. Therefore, this sleep is too late and serves only to delay scanning for the LVM devices.This sleep appears to be unnecessary, except perhaps for debugging. Personally, I would prefer set -x over counting how long the various sleep calls took. KZQN7737 wrote: | Code: | # Mount the root filesystem and other LVM logical volumes for different folders.
mount /dev/mapper/vg-root /newroot || rescue_shell "root mount failed"
mount /dev/mapper/vg-home /newroot/home || rescue_shell "home mount failed"
mount /dev/mapper/vg-var /newroot/var || rescue_shell "var mount failed" |
| Typically, you would mount root as read-only, and let the system init scripts mount home and var. |
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Sun Feb 25, 2024 8:32 pm Post subject: |
|
|
Hello, Hu,
I followed your recommendations as well.
If my initramfs is embedded in the kernel, I don't need to re-compile the kernel with make each time when I make adjustments in initramfs' script, amiright?
I've re-compiled and re-signed. Now SCSI disk message is gone. The problem returned to the state it was initially.
I think the problem may be concluded in "sh not tainted" message. My old boot entry message from directory /boot/efi/initramfs changed from "busybox not tainted" to "sh not tainted" as well until I've deleted this boot entry.
Perhaps the reason is that I don't have /bin/sh in my tree structure and it should be there?
Also, in root filesystem there's no init in /sbin/ directory. Strange. How do I get one?
Code: |
ls: cannot access '/sbin/init': No such file or directory.
|
Tree:
https://bpa.st/KWLWI
Initramfs:
https://bpa.st/IQPKQ
Message:
https://mega.nz/file/ziAyxRKT#I0W7thNpC07I_nxjm8OgL5GcdFHmgU593IJIYyTqUe8
.config:
https://dpaste.com/G869KXGMY
UPD: I also wonder what's the purpose of initramfs_list and if it's needed in my case.
https://wiki.gentoo.org/wiki/Early_Userspace_Mounting
Last edited by KZQN7737 on Sun Feb 25, 2024 9:04 pm; edited 1 time in total |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54423 Location: 56N 3W
|
Posted: Sun Feb 25, 2024 9:03 pm Post subject: |
|
|
KZQN7737'
Code: | ├── sbin
│ ├── cryptsetup -> /sbin/cryptsetup
│ └── lvm.static -> /sbin/lvm.static |
and Code: | /sbin/lvm vgscan || rescue_shell "vgscan failed"
/sbin/lvm vgchange -ay || rescue_shell "vgchange failed" |
are not consistent.
Either you need Code: | lvm -> /sbin/lvm.static | so that the lvm command exists or you need to use /sbin/lvm.static as the command.
It's probably time to add
Code: | rescue_shell "Stopping for diagnostics" | just above so you can see whats what and try commands by hand. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
KZQN7737 n00b
Joined: 13 Feb 2024 Posts: 27
|
Posted: Sun Feb 25, 2024 9:25 pm Post subject: |
|
|
Hi, NeddySeagoon,
Thanks for noticing.
Done:
Code: |
#!/bin/busybox sh
# Call the busybox shell.
rescue_shell() {
echo "$@"
echo "Something went wrong. Dropping you to a shell."
# The symlinks are not required any longer
# But it helps tab completion.
/bin/busybox --install -s
exec /bin/sh
}
# Tracking script traces, print the next command before execution.
set -x
# Mount temporary filesystems.
mount -t procfs proc /proc || rescue_shell "mounting procfs failed"
mount -t sysfs sys /sys || rescue_shell "mounting sysfs failed"
mount -t devtmpfs udev /dev || rescue shell "mounting devtmpfs failed"
# Custom message.
echo "Hello World."
set -x
# Attempt to open the encrypted root file system (Prompt for a password).
/sbin/cryptsetup --tries 5 luksOpen /dev/nvme0n1p2 cryptfs || rescue_shell "launching cryptsetup failed"
set -x
# LVM: enable partitions.
/sbin/lvm.static vgscan || rescue_shell "vgscan failed"
/sbin/lvm.static vgchange -ay || rescue_shell "vgchange failed"
set -x
# Mount the root filesystem LVM (home and var in root script).
mount -o ro /dev/mapper/vg-root /mnt/root || rescue_shell "root mount failed"
set -x
rescue_shell "Stopping for diagnostics."
# Clean up.
umount -l /proc || rescue_shell "umounting procfs failed"
umount -l /sys || rescue_shell "umounting sysfs failed"
umount -l /dev || rescue_shell "umounting devfs failed"
set -x
# Switch from initramfs to actual root file system.
exec switch_root /mnt/root /sbin/init
|
No changes to boot process:
https://mega.nz/file/SvIX2TCS#gTxN40hwqj-KfiqnUau0C3QOtEqWojVChJe_zMV60pM |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54423 Location: 56N 3W
|
Posted: Sun Feb 25, 2024 9:55 pm Post subject: |
|
|
KZQN7737
That sh should not be there.
Does it ever ask you for your password, or is the init script skipped entirely?
As written the init script either does something or gives you a busybox shell.
The kernel never tries to mount root. The init script does and invokes the rescue_shell if it fails.
Thus the kernel cannot panic.
If
invokes the shell, which then does nothing, the init script would be skipped and the kernel would indeed fall off the end of init, init being reduced to a busybox shell call.
The message at 5.150002 says . It should say init or maybe /init ? _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 21867
|
Posted: Sun Feb 25, 2024 10:58 pm Post subject: |
|
|
KZQN7737 wrote: | If my initramfs is embedded in the kernel, I don't need to re-compile the kernel with make each time when I make adjustments in initramfs' script, amiright? | If the initramfs is embedded in the kernel, and you did not rebuild and reinstall the kernel, how would your adjustments to the script be incorporated into a subsequent boot? KZQN7737 wrote: | Also, in root filesystem there's no init in /sbin/ directory. Strange. How do I get one? Code: | ls: cannot access '/sbin/init': No such file or directory. |
| You need to install a package which provides one. Despite everything you posted, it looks like you have not shown emerge --info yet, so I cannot tell whether this is an openrc system or a systemd system. That may affect the answer to your question.
You misunderstood use of set -x. It is not something you need to keep reapplying. As a shell set, it persists until revoked.
Your mega.nz links fail for me. mega.nz is known to have problems with JavaScript. I cannot see any pictures you host there. |
|
Back to top |
|
|
|