blob: 8c5678028d9c696fa83d3ee6db18ea7b60179177 [file] [log] [blame]
#!/bin/sh
#
# The initial system boot script. This only does one thing: try to find
# the root filesystem and mount it if possible.
#
mknod /dev/kmsg c 1 11
exec 9>&1 >/dev/kmsg 2>&1
echo "---- initramfs ('$0')"
echo "To bypass this script, use rdinit=/bin/sh"
. /helpers.sh
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
trap 'log FATAL - INIT EXITED - Rebooting.; reboot >&9 2>&1 9>&-' EXIT
# Mount /dev, /proc, /sys
/mounts-sys || die "couldn't mount special purpose directories"
log 'Disable repartitioning'
echo 1 >/proc/sys/dev/repartition/disable
# Initialize any loadable driver modules
for d in /lib/modules/*.ko /lib/modules/*/*.ko; do
[ -e "$d" ] && insmod $d
done
# Mount /rootfs
/mounts-root || die "couldn't mount root filesystems"
read_cmdline
log 'Looking for init in rootfs. To bypass this, use init=/bin/sh'
for init in "$INIT" /sbin/init /linuxrc /bin/sh; do
[ -n "$init" ] || continue
log "Trying '/rootfs$init'"
[ -x "/rootfs$init" ] || continue
case "$init" in
/sbin/init) args=1 ;;
*) args= ;;
esac
cd /rootfs
[ -n "$INIT" ] && exec >&9 2>&1 9>&- # probably a shell; bring back tty
exec switch_root /rootfs "$init" $args
done
die "couldn't switch to root filesystem"