43 lines
1.2 KiB
Bash
43 lines
1.2 KiB
Bash
|
#!/bin/sh
|
||
|
# nnd-init
|
||
|
# Adapted from mkinitfs of Alpine Linux Project
|
||
|
|
||
|
sysroot=/sysroot
|
||
|
init=/sbin/init
|
||
|
init_args=''
|
||
|
|
||
|
# Set-up basic utilities
|
||
|
/bin/busybox mkdir -p /usr/bin /usr/sbin /proc /sys /dev /tmp $sysroot
|
||
|
/bin/busybox --install -s
|
||
|
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
||
|
|
||
|
# Prepare /dev/null to void unwanted error messages if none are pre-provided by the kernel
|
||
|
[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
|
||
|
|
||
|
# Mount essential filesystems
|
||
|
mount -t devtmpfs -o exec,nosuid,mode=0755,size=2M devtmpfs /dev 2>/dev/null \
|
||
|
|| mount -t tmpfs -o exec,nosuid,mode=0755,size=2M tmpfs /dev
|
||
|
|
||
|
# Prepare kmsg for earlyprintk support
|
||
|
[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
|
||
|
|
||
|
# Prepare pseudo-terminal for any early ttys
|
||
|
[ -c /dev/ptmx ] || mknod -m 666 /dev/ptmx c 5 2
|
||
|
[ -d /dev/pts ] || mkdir -m 755 /dev/pts
|
||
|
mount -t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts
|
||
|
|
||
|
# Set-up rest of filesystems
|
||
|
# These should ideally be carried over in the true root via mount moving
|
||
|
mount -t sysfs -o noexec,nosuid,nodev sysfs /sys
|
||
|
mount -t proc -o noexec,nosuid,nodev,hidepid=2 proc /proc
|
||
|
mount -t tmpfs -o nosuid,nodev none /run
|
||
|
|
||
|
# Provided mounts at this point:
|
||
|
# /dev
|
||
|
# /dev/pts
|
||
|
# /sys
|
||
|
# /proc
|
||
|
# /run
|
||
|
|
||
|
exec sh
|