Discussion:
[gentoo-user] Musl custom initramfs kernel panic
(too old to reply)
efeizbudak
2024-03-09 14:10:02 UTC
Permalink
Hi all,

After updating my musl, my custom initramfs had stopped working. Can
anyone give me a hand with this? I recompiled util-linux and updated the
related files in my initramfs and also tried building it with
static-libs but neither of these helped. On the other hand, the
initramfs I built using genkernel works just fine.

The init error:

Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
/init: 6: cannot create /proc/sys/kernel/printk: Directory nonexistent
Fatal error during RNG initialisation
Cannot initialize crypto RNG backend.
Device /dev/sda3 is not a valid LUKS device.
/init: 8: cannot create /proc/sys/kernel/printk: Directory nonexistent
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
umount: /dev: not mounted.
umount: /proc: not mounted.
umount: /sys: not mounted.
switch_root: failed to mount moving /mnt/root to /: Invalid argument
switch_root: failed. Sorry.
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
Kernel Offset: 0x9000000 from 0xffffffff81000000 (relocation range:
0xffffffff80000000-0xffffffffbfffffff)
---[ end Kernel panic - not syncing: Attempted to kill init!
exitcode+0x00000100 ]---

my init file in my initramfs:

#!/bin/dash

mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys
echo 0 > /proc/sys/kernel/printk
cryptsetup luksOpen --allow-discards /dev/sda3 root
echo 1 > /proc/sys/kernel/printk
mount -o ro /dev/mapper/root /mnt/root
umount /dev /proc /sys
exec switch_root /mnt/root /sbin/init

my initramfs files:

.
├── bin
│   ├── dash
│   ├── mount
│   └── umount
├── dev
│   ├── console
│   ├── null
│   ├── sda3
│   └── tty
├── etc
├── init
├── lib
│   ├── ld-musl-x86_64.so.1
│   ├── libblkid.so.1
│   ├── libcap.so.2
│   ├── libdevmapper.so.1.02
│   ├── libmount.so.1
│   ├── libudev.so.1
│   └── libuuid.so.1
├── lib64
├── mnt
│   └── root
├── proc
├── root
├── run
├── sbin
│   ├── cryptsetup
│   └── switch_root
├── sys
├── trq.map
├── usr
│   ├── bin
│   └── lib
│   ├── libblkid.so.1
│   ├── libc.so
│   ├── libcap.so.2
│   ├── libcryptsetup.so.12
│   ├── libgcrypt.so.20
│   ├── libgpg-error.so.0
│   ├── libjson-c.so.5
│   ├── libmount.so.1
│   ├── libpopt.so.0
│   └── libuuid.so.1
└── var
├── log
└── run

how I update my initramfs:

lddtree.py --copy-to-tree /usr/src/initramfs /bin/mount /sbin/cryptsetup
/bin/dash /sbin/switch_root /bin/umount
cd /usr/src/initramfs
find . -print0 | cpio --null --create --verbose --format=newc >
/boot/custom-initramfs.img
Alexandru N. Barloiu
2024-03-09 16:30:01 UTC
Permalink
can also chroot into the environment where you prepared the initramfs
image to test stuff, which will save you rebooting time.
Post by efeizbudak
Hi all,
After updating my musl, my custom initramfs had stopped working. Can
anyone give me a hand with this? I recompiled util-linux and updated
the related files in my initramfs and also tried building it with
static-libs but neither of these helped. On the other hand, the
initramfs I built using genkernel works just fine.
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
/init: 6: cannot create /proc/sys/kernel/printk: Directory nonexistent
Fatal error during RNG initialisation
Cannot initialize crypto RNG backend.
Device /dev/sda3 is not a valid LUKS device.
/init: 8: cannot create /proc/sys/kernel/printk: Directory nonexistent
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
umount: /dev: not mounted.
umount: /proc: not mounted.
umount: /sys: not mounted.
switch_root: failed to mount moving /mnt/root to /: Invalid argument
switch_root: failed. Sorry.
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
0xffffffff80000000-0xffffffffbfffffff)
---[ end Kernel panic - not syncing: Attempted to kill init!
exitcode+0x00000100 ]---
#!/bin/dash
mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys
echo 0 > /proc/sys/kernel/printk
cryptsetup luksOpen --allow-discards /dev/sda3 root
echo 1 > /proc/sys/kernel/printk
mount -o ro /dev/mapper/root /mnt/root
umount /dev /proc /sys
exec switch_root /mnt/root /sbin/init
.
├── bin
│   ├── dash
│   ├── mount
│   └── umount
├── dev
│   ├── console
│   ├── null
│   ├── sda3
│   └── tty
├── etc
├── init
├── lib
│   ├── ld-musl-x86_64.so.1
│   ├── libblkid.so.1
│   ├── libcap.so.2
│   ├── libdevmapper.so.1.02
│   ├── libmount.so.1
│   ├── libudev.so.1
│   └── libuuid.so.1
├── lib64
├── mnt
│   └── root
├── proc
├── root
├── run
├── sbin
│   ├── cryptsetup
│   └── switch_root
├── sys
├── trq.map
├── usr
│   ├── bin
│   └── lib
│       ├── libblkid.so.1
│       ├── libc.so
│       ├── libcap.so.2
│       ├── libcryptsetup.so.12
│       ├── libgcrypt.so.20
│       ├── libgpg-error.so.0
│       ├── libjson-c.so.5
│       ├── libmount.so.1
│       ├── libpopt.so.0
│       └── libuuid.so.1
└── var
    ├── log
    └── run
lddtree.py --copy-to-tree /usr/src/initramfs /bin/mount
/sbin/cryptsetup /bin/dash /sbin/switch_root /bin/umount
cd /usr/src/initramfs
find . -print0 | cpio --null --create --verbose --format=newc >
/boot/custom-initramfs.img
Alexandru N. Barloiu
2024-03-09 16:30:01 UTC
Permalink
clearly mount is using a symbol not provided by one of those shared
libraries, but no clue which it is. However you dont need dash and mount
and umount. Reason its working for genkernel is because its using
busybox instead of normal system mount/umount/dash. Might want to try
that. Smaller too.
Post by efeizbudak
Hi all,
After updating my musl, my custom initramfs had stopped working. Can
anyone give me a hand with this? I recompiled util-linux and updated
the related files in my initramfs and also tried building it with
static-libs but neither of these helped. On the other hand, the
initramfs I built using genkernel works just fine.
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
/init: 6: cannot create /proc/sys/kernel/printk: Directory nonexistent
Fatal error during RNG initialisation
Cannot initialize crypto RNG backend.
Device /dev/sda3 is not a valid LUKS device.
/init: 8: cannot create /proc/sys/kernel/printk: Directory nonexistent
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
umount: /dev: not mounted.
umount: /proc: not mounted.
umount: /sys: not mounted.
switch_root: failed to mount moving /mnt/root to /: Invalid argument
switch_root: failed. Sorry.
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
0xffffffff80000000-0xffffffffbfffffff)
---[ end Kernel panic - not syncing: Attempted to kill init!
exitcode+0x00000100 ]---
#!/bin/dash
mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys
echo 0 > /proc/sys/kernel/printk
cryptsetup luksOpen --allow-discards /dev/sda3 root
echo 1 > /proc/sys/kernel/printk
mount -o ro /dev/mapper/root /mnt/root
umount /dev /proc /sys
exec switch_root /mnt/root /sbin/init
.
├── bin
│   ├── dash
│   ├── mount
│   └── umount
├── dev
│   ├── console
│   ├── null
│   ├── sda3
│   └── tty
├── etc
├── init
├── lib
│   ├── ld-musl-x86_64.so.1
│   ├── libblkid.so.1
│   ├── libcap.so.2
│   ├── libdevmapper.so.1.02
│   ├── libmount.so.1
│   ├── libudev.so.1
│   └── libuuid.so.1
├── lib64
├── mnt
│   └── root
├── proc
├── root
├── run
├── sbin
│   ├── cryptsetup
│   └── switch_root
├── sys
├── trq.map
├── usr
│   ├── bin
│   └── lib
│       ├── libblkid.so.1
│       ├── libc.so
│       ├── libcap.so.2
│       ├── libcryptsetup.so.12
│       ├── libgcrypt.so.20
│       ├── libgpg-error.so.0
│       ├── libjson-c.so.5
│       ├── libmount.so.1
│       ├── libpopt.so.0
│       └── libuuid.so.1
└── var
    ├── log
    └── run
lddtree.py --copy-to-tree /usr/src/initramfs /bin/mount
/sbin/cryptsetup /bin/dash /sbin/switch_root /bin/umount
cd /usr/src/initramfs
find . -print0 | cpio --null --create --verbose --format=newc >
/boot/custom-initramfs.img
efeizbudak
2024-03-09 18:00:01 UTC
Permalink
How could I go about finding which library it is? lddtree is only giving
me libblkid and libmount, both of which are already inside the
initramfs. I will try to learn about busybox. Thank you.
Post by Alexandru N. Barloiu
clearly mount is using a symbol not provided by one of those shared
libraries, but no clue which it is. However you dont need dash and
mount and umount. Reason its working for genkernel is because its using
busybox instead of normal system mount/umount/dash. Might want to try
that. Smaller too.
Post by efeizbudak
Hi all,
After updating my musl, my custom initramfs had stopped working. Can
anyone give me a hand with this? I recompiled util-linux and updated
the related files in my initramfs and also tried building it with
static-libs but neither of these helped. On the other hand, the
initramfs I built using genkernel works just fine.
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
/init: 6: cannot create /proc/sys/kernel/printk: Directory nonexistent
Fatal error during RNG initialisation
Cannot initialize crypto RNG backend.
Device /dev/sda3 is not a valid LUKS device.
/init: 8: cannot create /proc/sys/kernel/printk: Directory nonexistent
Error relocating /bin/mount: mnt_context_enable_noautofs: symbol not
found
Error relocating /bin/mount: mnt_context_enable_onlyonce: symbol not
found
umount: /dev: not mounted.
umount: /proc: not mounted.
umount: /sys: not mounted.
switch_root: failed to mount moving /mnt/root to /: Invalid argument
switch_root: failed. Sorry.
Kernel panic - not syncing: Attempted to kill init!
exitcode=0x00000100
0xffffffff80000000-0xffffffffbfffffff)
---[ end Kernel panic - not syncing: Attempted to kill init!
exitcode+0x00000100 ]---
#!/bin/dash
mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys
echo 0 > /proc/sys/kernel/printk
cryptsetup luksOpen --allow-discards /dev/sda3 root
echo 1 > /proc/sys/kernel/printk
mount -o ro /dev/mapper/root /mnt/root
umount /dev /proc /sys
exec switch_root /mnt/root /sbin/init
.
├── bin
│ ├── dash
│ ├── mount
│ └── umount
├── dev
│ ├── console
│ ├── null
│ ├── sda3
│ └── tty
├── etc
├── init
├── lib
│ ├── ld-musl-x86_64.so.1
│ ├── libblkid.so.1
│ ├── libcap.so.2
│ ├── libdevmapper.so.1.02
│ ├── libmount.so.1
│ ├── libudev.so.1
│ └── libuuid.so.1
├── lib64
├── mnt
│ └── root
├── proc
├── root
├── run
├── sbin
│ ├── cryptsetup
│ └── switch_root
├── sys
├── trq.map
├── usr
│ ├── bin
│ └── lib
│ ├── libblkid.so.1
│ ├── libc.so
│ ├── libcap.so.2
│ ├── libcryptsetup.so.12
│ ├── libgcrypt.so.20
│ ├── libgpg-error.so.0
│ ├── libjson-c.so.5
│ ├── libmount.so.1
│ ├── libpopt.so.0
│ └── libuuid.so.1
└── var
├── log
└── run
lddtree.py --copy-to-tree /usr/src/initramfs /bin/mount
/sbin/cryptsetup /bin/dash /sbin/switch_root /bin/umount
cd /usr/src/initramfs
find . -print0 | cpio --null --create --verbose --format=newc >
/boot/custom-initramfs.img
Hoël Bézier
2024-03-10 00:50:01 UTC
Permalink
Post by efeizbudak
How could I go about finding which library it is? lddtree is only giving
me libblkid and libmount, both of which are already inside the
initramfs. I will try to learn about busybox. Thank you.
You can try to run mount with strace on your host, and see which shared
libraries are opened.

Loading...