Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4451

Compute Module • Kernel Panic on exec switch_root

$
0
0
I'm using cmprovision to write an image to a CM4 (eMMC).

There are two partitions, a boot partition with an initramfs and an "appfs" partition.

On boot I would like to encrypt the contents of the "appfs" partition and then load it as the root partition.

This is the contents of the /init in the initramfs.

Code:

#!/bin/sh# devtmpfs does not get automounted for initramfs/bin/mount -t devtmpfs devtmpfs /dev# use the /dev/console device node from devtmpfs if possible to not# confuse glibc's ttyname_r().# This may fail (E.G. booted with console=), and errors from exec will# terminate the shell, so use a subshell for the testif (exec 0</dev/console) 2>/dev/null; then    exec 0</dev/console    exec 1>/dev/console    exec 2>/dev/consolefirpi-otp-private-key -b > key.binif cryptsetup open --type=luks2 --key-file key.bin /dev/mmcblk0p2 appfs; then    mkdir /media/mmcblk0p2    mount /dev/mapper/appfs /media/mmcblk0p2else    mkdir /media/mmcblk0p2    mount /dev/mmcblk0p2 /media/mmcblk0p2    mkdir /root/mmcblk0p2    cp -r /media/mmcblk0p2/* /root/mmcblk0p2/    umount /media/mmcblk0p2    cryptsetup -q luksFormat --type=luks2 --key-file=key.bin --pbkdf argon2id /dev/mmcblk0p2    cryptsetup open --type=luks2 --key-file key.bin /dev/mmcblk0p2 appfs    mkfs -t ext4 /dev/mapper/appfs    mount /dev/mapper/appfs /media/mmcblk0p2    cp -r /root/mmcblk0p2/* /media/mmcblk0p2/fiexec switch_root /media/mmcblk0p2/ /sbin/init
I've also had `exec /sbin/init "$@"` in the `else` and manually running the commands and then on reboot expecting the if to succeed and load the "appfs" partition as the root filesystem.

On boot I see

Code:

EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.device-mapper: ioctl: 4.45.0-ioctl (2021-03-22) initialised: dm-devel@redhat.comKernel panic - not syncing: Attempting to kill init! exitcode=0x00000100# multi screen backtrace
Last screen of the backtrace.
Image

Statistics: Posted by BerryPiUser — Tue Mar 05, 2024 4:50 pm — Replies 0 — Views 16



Viewing all articles
Browse latest Browse all 4451

Trending Articles