View previous topic :: View next topic |
Author |
Message |
willem-jan n00b
Joined: 12 Sep 2021 Posts: 7
|
Posted: Fri Sep 17, 2021 8:59 am Post subject: Kernel panic init error -2 |
|
|
Hi All,
I'm trying to migrate to ZFS on root using EFI stub boot instead of GRUB.
OpenRC 0.43.5, Kernel: 5.14.4, Dracut 053
I have the EFI stub boot working (aka boot without grub), but once I add an initramfs (to add ZFS later) I get a kernel panic when booting saying:
Code: | failed to execute /init (error-2) |
I checked and there is definitely an /init file in the initramfs (using lsinitramfs)
But I cannot find the error code -2 anywhere.
What can be wrong here?
For completeness this is the dracut command I used:
Code: | dracut --force -H --kver 5.14.4-gentoo |
And this the efibootmgr command:
Code: | efibootmgr -c -d /dev/nvme0n1 -p 5 -L "Gentoo" -l '\EFI\gentoo\bzImage.efi' -u 'root=PARTUUID=233200e8-4ba8-2943-869e-9311abe1d556 rw initrd=\EFI\gentoo\initramfs.img net.ifnames=0 biosdevnam=0 ipv6.disable=1 loglevel=8' -v
|
Note1: i copied the generated initramfs to /boot/EFI/gentoo/initramfs, so I am sure the latest dracut generated initram is used.
Note2: the system boots perfectly fine without the initrd kernel parameter / initramfs. But as said, I am migrating to ZFS and need the ZFS kernel module during boot, hence I need an initramfs (unfortunately). |
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Fri Sep 17, 2021 9:29 am Post subject: |
|
|
Quote: |
d /dev/nvme0n1 -p 5 -L "Gentoo"
|
This refers to the efi partition.
Is your efi partition
/dev/nvme0n1p5
?
I strongly advice you to use grub though. _________________
|
|
Back to top |
|
|
willem-jan n00b
Joined: 12 Sep 2021 Posts: 7
|
Posted: Fri Sep 17, 2021 10:03 am Post subject: |
|
|
Yes that is indeed the efi partition that contains the kernel and the initramfs.
The uuid is the root partition. and without the initramfs the system boots fine.
Part of this migration is to actually get rid of grub, hence the EFI stub approach.
Any clue ehat the error code -2 stands for? |
|
Back to top |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Fri Sep 17, 2021 10:34 am Post subject: |
|
|
I use efibootmgr, but I don't use initramfs or dracut, so I probably won't be able to help you... Anyway...
- In your post above, the 'initrd' argument starts with '\EFI\gentoo'. In our handbook, it starts with "\".
Code: | efibootmgr -c -d /dev/sda -p 2 -L "Gentoo" -l "\efi\boot\bootx64.efi" initrd='\initramfs-genkernel-amd64-4.9.16-gentoo' |
I don't say that your command is wrong. But if differs from the example in our handbook.
There's a warning in the handbook:
Quote: | Important:
It is recommended to use genkernel for both, building kernel and initramfs. If you decide to use genkernel only for generating initramfs it is crucial to pass --kernel-config=/path/to/kernel.config to genkernel or generated initramfs may not work with your manually built kernel. |
It probably doesn't apply in your case, since you use dracut - but it could be something similar.
|
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Fri Sep 17, 2021 4:16 pm Post subject: |
|
|
You mention you are in the process of migration to zfs.
What does that mean?
Have you greated the zfs rpool?
If yes you need to pass this kernel parameter
Code: |
root=ZFS=rpool/ROOT/gentoo
|
or similar
How can you do that with efistub?
Can you?
you have
Code: |
root=UUID=xxxxxxxxxxxxx
|
_________________
|
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21619
|
Posted: Sat Sep 18, 2021 1:02 am Post subject: |
|
|
Are you sure about that error message? I can't find it in the kernel source via grep on some likely substrings.
Errno 2 is ENOENT, so it is probably telling you that it cannot find the init file.
Although it would increase kernel size, you could also choose to build the initramfs into the kernel, to avoid dealing with loading it. |
|
Back to top |
|
|
willem-jan n00b
Joined: 12 Sep 2021 Posts: 7
|
Posted: Mon Sep 20, 2021 7:04 am Post subject: |
|
|
Thank you all for your input.
I finally have managed to load the initramfs / init properly. But not with dracut. I now used genkernel (with the --zfs flag), and while I do not know what both exactly do in the background, Genkernel does work.
Also booting my non-ZFS system with the initramfs works. It technically does not need an initramfs since none of the modules are needed to boot my system. I only tried this to make sure I can boot my system with EFI stub and an initramfs prior to the migration to ZFS.
Unfortunately booting into the ZFS root does not seem to work. The kernel just hangs/waits (after the initramfs was loaded and the kernel is active) without displaying an error message.
The partition layout is as follows:
- p1: boot, FAT32, with the kernel and initramfs
- p2: regular swap
- p3: encrypted rpool/ROOT with a root and home dataset
The initram asks me for the password for the pool which indicates that the pool/dataset is found correctly. And yes, the ZFS root is correctly passed to the kernel.
I will do some more digging/testing but am at the point to abandon this route since my boot time is already significantly increased (e.g. one of the additional delays when 'starting udev' is already 5 sec extra) plus I am slightly worried of the 'stability/reliability' of this approach. |
|
Back to top |
|
|
willem-jan n00b
Joined: 12 Sep 2021 Posts: 7
|
Posted: Mon Sep 20, 2021 7:18 am Post subject: |
|
|
Hu wrote: | Are you sure about that error message? I can't find it in the kernel source via grep on some likely substrings.
Errno 2 is ENOENT, so it is probably telling you that it cannot find the init file.
Although it would increase kernel size, you could also choose to build the initramfs into the kernel, to avoid dealing with loading it. |
Ah yes I am.
Also did a quick grep and I think I have found the line: 1516 in init/main.c (kernel 5.14.4)
Code: | grep -rnwi "./" -e "failed to execute"
./init/main.c:1516: pr_err("Failed to execute %s (error %d)\n",
|
Code:
Code: |
if (ramdisk_execute_command) {
ret = run_init_process(ramdisk_execute_command);
if (!ret)
return 0;
pr_err("Failed to execute %s (error %d)\n",
ramdisk_execute_command, ret);
}
|
Quote: | Although it would increase kernel size, you could also choose to build the initramfs into the kernel, to avoid dealing with loading it. |
Ah that indeed sounds as a good option. It works now, but still... It also would give the possibility to sign the kernel and use secure boot. Since one of the caveats of ZFS (as far as I know) is that we cannot encrypt the boot partition. My use case is protect it against malware, virus, trojan, rootkits etc. There is no sensitive data/passwords etc in the initram or kernel. Hence, secureboot might actually make more sense I guess. Any hints/sources you could recommend on how to compile the initramfs into the kernel?
The ultimate solution would be to have ZFS available in the kernel and not as a kernel module. But apparently there seems some license hurdles with Sun. |
|
Back to top |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Mon Sep 20, 2021 12:40 pm Post subject: |
|
|
willem-jan wrote: | The ultimate solution would be to have ZFS available in the kernel and not as a kernel module. But apparently there seems some license hurdles with Sun. |
It's not only the license... See what Linus Torvalds wrote: https://www.phoronix.com/scan.php?page=news_item&px=Linus-Says-No-To-ZFS-Linux
Quote: | Note that "we don't break users" is literally about user-space applications, and about the kernel I maintain.
If somebody adds a kernel module like ZFS, they are on their own. I can't maintain it, and I can not be bound by other peoples kernel changes.
And honestly, there is no way I can merge any of the ZFS efforts until I get an official letter from Oracle that is signed by their main legal counsel or preferably by Larry Ellison himself that says that yes, it's ok to do so and treat the end result as GPL'd.
Other people think it can be ok to merge ZFS code into the kernel and that the module interface makes it ok, and that's their decision. But considering Oracle's litigious nature, and the questions over licensing, there's no way I can feel safe in ever doing so.
And I'm not at all interested in some "ZFS shim layer" thing either that some people seem to think would isolate the two projects. That adds no value to our side, and given Oracle's interface copyright suits (see Java), I don't think it's any real licensing win either.
Don't use ZFS. It's that simple. It was always more of a buzzword than anything else, I feel, and the licensing issues just make it a non-starter for me.
The benchmarks I've seen do not make ZFS look all that great. And as far as I can tell, it has no real maintenance behind it either any more, so from a long-term stability standpoint, why would you ever want to use it in the first place? |
|
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21619
|
Posted: Mon Sep 20, 2021 6:12 pm Post subject: |
|
|
willem-jan wrote: | Hu wrote: | Are you sure about that error message? | Ah yes I am.
Also did a quick grep and I think I have found the line: 1516 in init/main.c (kernel 5.14.4) Code: | grep -rnwi "./" -e "failed to execute"
./init/main.c:1516: pr_err("Failed to execute %s (error %d)\n", |
| I see. In your opening post, you didn't capitalize failed, and I didn't do a case-insensitive search. That's why I couldn't find it. willem-jan wrote: | I get a kernel panic when booting saying: Code: | failed to execute /init (error-2) |
|
willem-jan wrote: | Any hints/sources you could recommend on how to compile the initramfs into the kernel? | Start with the kernel source documentation file Documentation/filesystems/ramfs-rootfs-initramfs.rst, under the section Populating initramfs:. If you need more help, post back and I can try to elaborate. |
|
Back to top |
|
|
|