aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinitramfs-init.in54
1 files changed, 28 insertions, 26 deletions
diff --git a/initramfs-init.in b/initramfs-init.in
index 5f0a5ff..538f286 100755
--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -7,20 +7,6 @@ sysroot=/sysroot
splashfile=/.splash.ctrl
repofile=/tmp/repositories
-/bin/busybox mkdir -p /usr/bin /usr/sbin /proc /sys /dev $sysroot \
- /media/cdrom /media/usb /tmp /run
-/bin/busybox --install -s
-
-# basic environment
-export PATH=/usr/bin:/bin:/usr/sbin:/sbin
-
-# needed devs
-[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
-
-# basic mounts
-mount -t proc -o noexec,nosuid,nodev proc /proc
-mount -t sysfs -o noexec,nosuid,nodev sysfs /sys
-
# some helpers
ebegin() {
last_emsg="$*"
@@ -293,6 +279,34 @@ is_url() {
esac
}
+/bin/busybox mkdir -p /usr/bin /usr/sbin /proc /sys /dev $sysroot \
+ /media/cdrom /media/usb /tmp /run
+
+# Spread out busybox symlinks and make them available without full path
+/bin/busybox --install -s
+export PATH=/usr/bin:/bin:/usr/sbin:/sbin
+
+# Make sure /dev/null is a device node. If /dev/null does not exist yet, the command
+# mounting the devtmpfs will create it implicitly as an file with the "2>" redirection.
+# The -c check is required to deal with initramfs with pre-seeded device nodes without
+# error message.
+[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
+
+mount -t proc -o noexec,nosuid,nodev proc /proc
+mount -t sysfs -o noexec,nosuid,nodev sysfs /sys
+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
+
+# pty device nodes (later system will need it)
+[ -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
+
+# shared memory area (later system will need it)
+[ -d /dev/shm ] || mkdir /dev/shm
+mount -t tmpfs -o nodev,nosuid,noexec shm /dev/shm
+
+
# read the kernel options. we need surve things like:
# acpi_osi="!Windows 2006" xen-pciback.hide=(01:00.0)
set -- $(cat /proc/cmdline)
@@ -356,18 +370,6 @@ for i in ${KOPT_blacklist//,/ }; do
echo "blacklist $i" >> /etc/modprobe.d/boot-opt-blacklist.conf
done
-# setup /dev
-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
-[ -d /dev/pts ] || mkdir -m 755 /dev/pts
-[ -c /dev/ptmx ] || mknod -m 666 /dev/ptmx c 5 2
-# make sure /dev/null is setup correctly
-[ -f /dev/null ] && rm -f /dev/null
-[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
-mount -t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts
-[ -d /dev/shm ] || mkdir /dev/shm
-mount -t tmpfs -o nodev,nosuid,noexec shm /dev/shm
-
# determine if we are going to need networking
if [ -n "$KOPT_ip" ] || [ -n "$KOPT_nbd" ] || \
is_url "$KOPT_apkovl" || is_url "$ALPINE_REPO"; then