ref: 6fcf3246530aaadcf397df644ffa3b00053d9018
parent: ac0ad1964bd3fb9a76cba161e09ef18de29d49c2
parent: 22d33fbc42cad72f2667a6fe05ea7034a96ac1e7
author: Natanael Copa <ncopa@alpinelinux.org>
date: Tue Dec 22 05:43:36 CST 2020
Merge branch 'github/fork/reidrankin/dev-kmsg-progress' into 'master' Output init progress to /dev/kmsg See merge request alpine/mkinitfs!61
--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -10,6 +10,7 @@
# some helpers
ebegin() {
last_emsg="$*"
+ echo "$last_emsg..." > /dev/kmsg
[ "$KOPT_quiet" = yes ] && return 0
echo -n " * $last_emsg: "
}
@@ -16,10 +17,12 @@
eend() {
local msg
if [ "$1" = 0 ] || [ $# -lt 1 ] ; then
+ echo "$last_emsg: ok." > /dev/kmsg
[ "$KOPT_quiet" = yes ] && return 0
echo "ok."
else
shift
+ echo "$last_emsg: failed. $*" > /dev/kmsg
if [ "$KOPT_quiet" = "yes" ]; then
echo -n "$last_emsg "
fi
@@ -191,7 +194,7 @@
echo "ERROR: DHCP requested but not present in initrd"
return 1
fi
- ebegin "Obtaining IP via DHCP ($device)..."
+ ebegin "Obtaining IP via DHCP ($device)"
ifconfig "$device" 0.0.0.0
udhcpc -i "$device" -f -q
eend $?
@@ -198,7 +201,7 @@
else
# manual configuration
[ -n "$client_ip" -a -n "$netmask" ] || return
- ebegin "Setting IP ($device)..."
+ ebegin "Setting IP ($device)"
if ifconfig "$device" "$client_ip" netmask "$netmask"; then
[ -z "$gw_ip" ] || ip route add 0.0.0.0/0 via "$gw_ip" dev "$device"
fi
@@ -316,11 +319,16 @@
# 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
+# Make sure /dev/kmsg is a device node. Writing to /dev/kmsg allows the use of the
+# earlyprintk kernel option to monitor early init progress. As above, the -c check
+# prevents an error if the device node has already been seeded.
+[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
+
+mount -t proc -o noexec,nosuid,nodev proc /proc
# 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
@@ -363,6 +371,7 @@
done
done
+echo "Alpine Init $VERSION" > /dev/kmsg
[ "$KOPT_quiet" = yes ] || echo "Alpine Init $VERSION"
# enable debugging if requested