ref: 22d33fbc42cad72f2667a6fe05ea7034a96ac1e7
parent: 961726b6aeb8e12176009675f22ed0ffc2b26e14
author: Reid Rankin <reidrankin@gmail.com>
date: Thu Jan 16 11:23:23 CST 2020
Output init progress to /dev/kmsg This enables debug of early-init problems via the use of the earlyprintk kernel parameter.
--- 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
@@ -190,7 +193,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 $?
@@ -197,7 +200,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
@@ -311,11 +314,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
@@ -353,6 +361,7 @@
done
done
+echo "Alpine Init $VERSION" > /dev/kmsg
[ "$KOPT_quiet" = yes ] || echo "Alpine Init $VERSION"
# enable debugging if requested