summaryrefslogtreecommitdiff
path: root/packages/slugos-init/files
diff options
context:
space:
mode:
Diffstat (limited to 'packages/slugos-init/files')
-rw-r--r--packages/slugos-init/files/boot/disk9
-rw-r--r--packages/slugos-init/files/functions13
-rw-r--r--packages/slugos-init/files/turnup6
3 files changed, 21 insertions, 7 deletions
diff --git a/packages/slugos-init/files/boot/disk b/packages/slugos-init/files/boot/disk
index d47be54c37..63370ce340 100644
--- a/packages/slugos-init/files/boot/disk
+++ b/packages/slugos-init/files/boot/disk
@@ -38,12 +38,13 @@ then
# is attempted.
if test -n "$UUID" &&
mount "$@" UUID="$UUID" /mnt ||
- mount "$@" -U "$UUID" /mnt ||
mount "$@" "$device" /mnt
then
- # checkmount checks for sh, chroot, init
- # and /mnt (i.e. /mnt/mnt in this case)
- if checkmount /mnt
+ # checkmount checks for sh, chroot, init, /dev
+ # and /mnt (i.e. /mnt/mnt in this case).
+ # minimaldevnodes checks (and creates if required)
+ # a few mandatory /dev nodes we may need.
+ if checkmount /mnt && minimaldevnodes /mnt
then
# pivot to /initrd if available, else /mnt
cd /
diff --git a/packages/slugos-init/files/functions b/packages/slugos-init/files/functions
index 18f4009ee7..5b6b40b091 100644
--- a/packages/slugos-init/files/functions
+++ b/packages/slugos-init/files/functions
@@ -173,6 +173,7 @@ checkmount(){
# basic test for init (the kernel will try to load this)
# but require a shell in bin/sh too
test \( -d "$1/mnt" \) -a \
+ \( -d "$1/dev" \) -a \
\( -x "$1/bin/sh" -o -h "$1/bin/sh" \) -a \
\( -x "$1/usr/sbin/chroot" -o -h "$1/usr/sbin/chroot" -o \
-x "$1/sbin/chroot" -o -h "$1/sbin/chroot" \) -a \
@@ -181,6 +182,18 @@ checkmount(){
-x "$1/bin/init" -o -h "$1/bin/init" \)
}
#
+# minimaldevnodes "mountpoint"
+# tests an already mounted mountpoint to see if a very minimal
+# set of devices exists or can be created in dev, and returns
+# failure if not. This is required for booting to an nfsroot
+# with an empty dev directory, as commonly occurs when the rootfs
+# is created from a tar.gz image. This is also required for mdev.
+minimaldevnodes(){
+ [ -c "$1/dev/console" ] || mknod -m 600 "$1/dev/console" c 5 1 || return 1
+ [ -c "$1/dev/null" ] || mknod -m 666 "$1/dev/null" c 1 3 || return 1
+ return 0
+}
+#
# swivel "new root" "old root"
# NOTE: the arguments must be paths relative to /, bad things
# will happen if the arguments themselves start with /
diff --git a/packages/slugos-init/files/turnup b/packages/slugos-init/files/turnup
index 4aa1fba3ed..2bbc9024ef 100644
--- a/packages/slugos-init/files/turnup
+++ b/packages/slugos-init/files/turnup
@@ -578,7 +578,7 @@ disk() {
fso="$(fsoptions "$@")"
if if test -n "$uuid"
then
- mount "$@" UUID="$uuid" "$new" || mount "$@" -U "$uuid" "$new"
+ mount "$@" UUID="$uuid" "$new"
else
mount "$@" "$device" "$new"
fi
@@ -591,7 +591,7 @@ disk() {
if test -n "$fst" &&
if test -n "$uuid"
then
- mount -t "$fst" -o "$fso" UUID="$uuid" "$new" || mount -t "$fst" -o "$fso" -U "$uuid" "$new"
+ mount -t "$fst" -o "$fso" UUID="$uuid" "$new"
else
mount -t "$fst" -o "$fso" "$device" "$new"
fi
@@ -633,7 +633,7 @@ disk() {
then
echo " options used: -t $fst -o $fso [error in this script]" >&2
test -n "$uuid" &&
- echo " uuid: $uuid (passed with UUID= or -U)" >&2
+ echo " uuid: $uuid (passed with UUID=<uuid>)" >&2
fi
fi