Skip to content

Instantly share code, notes, and snippets.

@pdp7
Created May 20, 2023 18:43
Show Gist options
  • Save pdp7/8d61bafbca55e987b790433c0353831d to your computer and use it in GitHub Desktop.
Save pdp7/8d61bafbca55e987b790433c0353831d to your computer and use it in GitHub Desktop.
linux-riscv reference: buildroot/fs/cpio/init
#!/bin/sh
# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /dev
/bin/mount -t proc proc /proc
/bin/mount -t sysfs sysfs /sys
/bin/mount -t tmpfs tmpfs /run
# 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 test
if (exec 0</dev/console) 2>/dev/null; then
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
fi
echo "############################################"
ls -la /dev/mmcblk0p1
echo "############################################"
#mknod -m 644 /mmc/dev/console c 229 0
mkdir /mmc
/bin/mount -t ext4 /dev/mmcblk0p2 /mmc
/bin/mount -t devtmpfs devtmpfs /mmc/dev
/bin/mount -t proc proc /mmc/proc
/bin/mount -t sysfs sysfs /mmc/sys
/bin/mount -t tmpfs tmpfs /mmc/run
ls -la /mmc
echo "############################################"
#exec /sbin/init "$@"
echo "SWITCHING ROOT............."
exec switch_root /mmc /sbin/init "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment