From: Jan Palus Date: Wed, 28 Sep 2022 20:06:30 +0000 (+0200) Subject: check if /newroot/dev/console creation can succeed X-Git-Tag: 12818^0 X-Git-Url: http://git.pld-linux.org/gitweb.cgi?a=commitdiff_plain;h=9552a28d03e1b9bf8c5fdb933d5fa8464022a219;p=projects%2Fgeninitrd.git check if /newroot/dev/console creation can succeed /newroot is mounted read-only hence by default nothing can be created below it unless /newroot/dev is mounted to something else. unfortunately `test -w /newroot/dev` in initrd does not check whether containing filesystem is mounted read-only --- diff --git a/geninitrd b/geninitrd index 0a422ee..46b2fc6 100755 --- a/geninitrd +++ b/geninitrd @@ -1066,9 +1066,9 @@ initrd_gen_initramfs_switchroot() { kmsg "geninitrd/$VERSION switching root" umount_all - busybox_applet switch_root usleep + busybox_applet switch_root usleep mountpoint add_linuxrc <<-'EOF' - [ ! -e /newroot/dev/console ] && mknod -m 660 /newroot/dev/console c 5 1 + [ ! -e /newroot/dev/console ] && mountpoint -q /newroot/dev && mknod -m 660 /newroot/dev/console c 5 1 # switch root to empty dir will make kernel panic, so sleep 10s before it # switch_root needs to be pid 1, so there's no other way to recover from here