base/init.sh: error out early, if /dev, /proc or /sys cannot be mounted

master
Harald Hoyer 2012-07-03 13:14:12 +02:00
parent 194b80f974
commit c204501e3e
1 changed files with 20 additions and 5 deletions

View File

@ -20,14 +20,22 @@ export PATH
RD_DEBUG="" RD_DEBUG=""
. /lib/dracut-lib.sh . /lib/dracut-lib.sh


trap "emergency_shell Signal caught!" 0

# mount some important things # mount some important things
[ ! -d /proc/self ] && \ [ ! -d /proc/self ] && \
mount -t proc -o nosuid,noexec,nodev proc /proc >/dev/null 2>&1 mount -t proc -o nosuid,noexec,nodev proc /proc >/dev/null

if [ "$?" != "0" ]; then
echo "Cannot mount proc on /proc! Compile the kernel with CONFIG_PROC_FS!"
exit 1
fi


[ ! -d /sys/kernel ] && \ [ ! -d /sys/kernel ] && \
mount -t sysfs -o nosuid,noexec,nodev sysfs /sys >/dev/null 2>&1 mount -t sysfs -o nosuid,noexec,nodev sysfs /sys >/dev/null

if [ "$?" != "0" ]; then
echo "Cannot mount sysfs on /sys! Compile the kernel with CONFIG_SYSFS!"
exit 1
fi


if [ -x /lib/systemd/systemd-timestamp ]; then if [ -x /lib/systemd/systemd-timestamp ]; then
RD_TIMESTAMP=$(/lib/systemd/systemd-timestamp) RD_TIMESTAMP=$(/lib/systemd/systemd-timestamp)
@ -42,6 +50,11 @@ if ! ismounted /dev; then
mount -t devtmpfs -o mode=0755,nosuid,strictatime devtmpfs /dev >/dev/null mount -t devtmpfs -o mode=0755,nosuid,strictatime devtmpfs /dev >/dev/null
fi fi


if ! ismounted /dev; then
echo "Cannot mount devtmpfs on /dev! Compile the kernel with CONFIG_DEVTMPFS!"
exit 1
fi

# prepare the /dev directory # prepare the /dev directory
[ ! -h /dev/fd ] && ln -s /proc/self/fd /dev/fd >/dev/null 2>&1 [ ! -h /dev/fd ] && ln -s /proc/self/fd /dev/fd >/dev/null 2>&1
[ ! -h /dev/stdin ] && ln -s /proc/self/fd/0 /dev/stdin >/dev/null 2>&1 [ ! -h /dev/stdin ] && ln -s /proc/self/fd/0 /dev/stdin >/dev/null 2>&1
@ -66,6 +79,8 @@ if ! ismounted /run; then
rm -fr /newrun rm -fr /newrun
fi fi


trap "emergency_shell Signal caught!" 0

[ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs [ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs


UDEVVERSION=$(udevadm --version) UDEVVERSION=$(udevadm --version)