1

I am learning to build a linux from scratch systemd edition, following the instructions at https://www.linuxfromscratch.org/lfs/view/stable-systemd/index.html on VirtualBox 6.1 but when I was booting into the kernel, it gave me the error as Kernel panic - not syncing: No working init found.

[    1.355071] Run /sbin/init as init process
[    1.356040]   with arguments:
[    1.356645]     /sbin/init
[    1.357965]   with environment:
[    1.358614]     HOME=/
[    1.359109]     TERM=linux
[    1.359797]     BOOT_IMAGE=/boot/vmlinuz-5.13.12-lfs-11.0-systemd
[    1.361244] Run /etc/init as init process
[    1.362403]   with arguments:
[    1.363103]     /etc/init
[    1.363741]   with environment:
[    1.364402]     HOME=/
[    1.364949]     TERM=linux
[    1.365571]     BOOT_IMAGE=/boot/vmlinuz-5.13.12-lfs-11.0-systemd
[    1.366633] Run /bin/init as init process
[    1.367359]   with arguments:
[    1.368024]     /bin/init
[    1.368629]   with environment:
[    1.369197]     HOME=/
[    1.369769]     TERM=linux
[    1.370361]     BOOT_IMAGE=/boot/vmlinuz-5.13.12-lfs-11.0-systemd
[    1.371632] Run /bin/sh as init process
[    1.373075]   with arguments:
[    1.373848]     /bin/sh
[    1.374396]   with environment:
[    1.375127]     HOME=/
[    1.375727]     TERM=linux
[    1.376331]     BOOT_IMAGE=/boot/vmlinuz-5.13.12-lfs-11.0-systemd
[    1.377607] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[    1.379913] CPU: 5 PID: 1 Comm: swapper/0 Not tainted 5.13.12 #1
[    1.381342] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[    1.382987] Call Trace:
[    1.383568]  dump_stack+0x64/0x7c
[    1.384258]  ? memcpy_orig+0xd0/0x10f
[    1.385047]  panic+0xf6/0x2b7
[    1.385734]  ? kernel_execve+0x13c/0x1a0
[    1.386571]  ? rest_init+0xa4/0xa4
[    1.387274]  kernel_init+0xf7/0xfc
[    1.387986]  ret_from_fork+0x22/0x30
[    1.389695] Kernel Offset: 0x3a600000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[    1.391756] ---[ end Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---

I have checked /sbin/init and it has been actually there, I have no idea about it. Anybody please help me???

This is my grub.cfg file

# Begin /boot/grub/grub.cfg
set default=0
set timeout=5

insmod ext2
set root=(hd0,2)

menuentry "GNU/Linux, Linux 5.13.12-lfs-11.0-systemd" {
        linux   /boot/vmlinuz-5.13.12-lfs-11.0-systemd root=/dev/sda2 ro
}

And this is /etc/fstab

# Begin /etc/fstab

# file system  mount-point  type     options             dump  fsck
#                                                              order

/dev/sda2     /            ext4    defaults            1     1
/dev/sda1     swap         swap     pri=1               0     0

The shown problem is that the kernel cannot find the /sbin/init program. About the tests done :

  • We have checked, and the /sbin/init link is here and available pointing to /lib/systemd/systemd
  • /lib/systemd/systemd exists, and is a 64-bit ELF application
  • We tried to run the "init=/sbin/init" option from GRUB to no avail
  • We used the GRUB boot console to check that the filesystem is accessible, and those files are visible
  • We tried to run directly /bin/bash, using the init parameter in GRUB, without success
  • Checked permissions, without success.
  • We even tried to upgrade the loglevel to 7, but no additional information is shown.

Of course, we have checked other tutorials and so forth to no avail. In the meantime, building LFS using SysVInit works, as it boots normally.

Now we really feel like the end of the road. Any ideas anyone ?

Edit 1 : Added options to the kernel and getting additional output and errors. Updated grub.cfg

# Begin /boot/grub/grub.cfg
set default=0
set timeout=5

insmod ext2
insmod gzio
insmod part_msdos
insmod msdospart
set root=(hd0,2)

menuentry "GNU/Linux, Linux 5.13.12-lfs-11.0-systemd" {
        linux   /boot/vmlinuz-5.13.12-lfs-11.0-systemd root=UUID=7d13e10f-8433-418c-bcb8-d5e7d272ea25 ro console=ttyS0 console=tty0 ignore_loglevel init=/lib/systemd/systemd
}

Feedback from the kernel :

[    3.847566] Freeing unused kernel image (initmem) memory: 1332K
[    3.854847] Write protecting the kernel read-only data: 20480k
[    3.859289] Freeing unused kernel image (text/rodata gap) memory: 2032K
[    3.865813] Freeing unused kernel image (rodata/data gap) memory: 1100K
[    3.870388] Run /lib/systemd/systemd as init process
[    3.872981]   with arguments:
[    3.874161]     /lib/systemd/systemd
[    3.876099]   with environment:
[    3.878269]     HOME=/
[    3.880556]     TERM=linux
[    3.882003]     BOOT_IMAGE=/boot/vmlinuz-5.13.12-lfs-11.0-systemd
[    3.884611] Kernel panic - not syncing: Requested init /lib/systemd/systemd failed (error -2).
[    3.885531] CPU: 4 PID: 1 Comm: swapper/0 Not tainted 5.13.12 #1
[    3.885531] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[    3.885531] Call Trace:
[    3.885531]  dump_stack+0x64/0x7c
[    3.885531]  ? memcpy_orig+0xd0/0x10f
[    3.885531]  panic+0xf6/0x2b7
[    3.885531]  ? rest_init+0xa4/0xa4
[    3.885531]  kernel_init+0xab/0xfc
[    3.885531]  ret_from_fork+0x22/0x30
[    3.885531] Kernel Offset: 0x3aa00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[    3.885531] ---[ end Kernel panic - not syncing: Requested init /lib/systemd/systemd failed (error -2). ]---

We have been tracing the error code to the kernel headers :

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H

#define EPERM        1  /* Operation not permitted */
#define ENOENT       2  /* No such file or directory */

What kind of additional test can be done from within grub at boot time to check that we have access ? Actually when using the grub console, we can already explore the file system, and list the files... Any suggestion ?

10
  • question 1: insmod ext2 while your fs is ext4? Commented Jan 13, 2022 at 7:52
  • question 2: Why is first partition made as swap, is this a mistake or a fact? Commented Jan 13, 2022 at 7:53
  • regarding the swap partition, I am unsure why pri=1 is used since you have only 1 swap partition, so defining its priority is useless... Commented Jan 13, 2022 at 8:04
  • I think it is neither mistake nor fact, it is maybe up to you want which partition to be swap or primary
    – luanphm
    Commented Jan 13, 2022 at 8:08
  • 1
    I just follow the instruction of the book, and I am not sure any change may cause crash or something, so I just follow exactly what they instruct
    – luanphm
    Commented Jan 13, 2022 at 8:12

1 Answer 1

1

We finally found the problem by using an lfs systemV kernel that was working then by booting this kernel on the systemd instance. It could start systemd and make everything work. We analyzed the boot messages differences, and we noticed that the initial non-working kernel, the SCSI subsystem is not started and the disks not detected, hence the filesystem cannot be used and nothing can be read.

The root cause is certainly due to a wrong 'make def' configuration in the Kernel, but we have to check more in depth. In any case, our first assumption was wrong because at the time of the failure, it is the KERNEL that is trying to access the disk, and no longer GRUB, so whether can or cannot access the disk is not relevant anymore.

We hope that may help anybody building an LFS.

Out of that, thank you everybody for your support.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .