aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--defaults/initrd.defaults1
-rw-r--r--defaults/initrd.scripts15
-rw-r--r--defaults/linuxrc1
3 files changed, 16 insertions, 1 deletions
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index 7ee78e9..c9e956a 100644
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -56,7 +56,6 @@ ROOT_LINKS='bin sbin lib lib32 lib64 boot usr opt emul'
ROOT_TREES='etc root home var'
REAL_ROOT=''
-CONSOLE='/dev/console'
NEW_ROOT='/newroot'
no_umounts='/newroot|/mnt/aufs-dev|/mnt/aufs-rw-branch|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino'
ROOTDELAY=5
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index c133282..505ca02 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2722,6 +2722,21 @@ setup_unionfs() {
fi
}
+get_active_console() {
+ local active_console=console
+
+ while [ -f /sys/class/tty/${active_console}/active ]
+ do
+ active_console=$(cat /sys/class/tty/${active_console}/active)
+
+ # last console will be the active one,
+ # see https://www.kernel.org/doc/html/latest/admin-guide/serial-console.html
+ active_console=${active_console##* }
+ done
+
+ echo ${active_console}
+}
+
get_mounts_list() {
awk '
/^[[:blank:]]*#/ { next }
diff --git a/defaults/linuxrc b/defaults/linuxrc
index f20d606..37a8dfa 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -21,6 +21,7 @@
[ ! -e /dev/zero ] && mknod /dev/zero c 1 5
# Take control
+CONSOLE="/dev/$(get_active_console)"
exec 0<>${CONSOLE} 1<>${CONSOLE} 2<>${CONSOLE}
if [ "$$" != '1' ]