Commit 7b7035ca authored by Dennis Baurichter's avatar Dennis Baurichter
Browse files

Always enable two serial consoles

Enable ttyS0 and ttyS1 on all systems. Also enable the first serial
console for GRUB.

Still, the virtual consoles (tty1, tty2, ...) are kept as default
consoles. Technically /dev/console remains connected to /dev/tty0, which
in turn is always the currently active virtual console.

You can log in on all of these, but systemd's boot messages only go to
/dev/console. (See https://github.com/systemd/systemd/issues/9899)
parent b3131a0f
......@@ -357,6 +357,20 @@ if [ "$bios" == false ]; then
fi
fi
echo '=> enabling serial consoles'
# This may be useful if IPMI (hardware servers), virt-manager / virsh (VMs) or other access is available.
# Text editors, pagers (like less) etc. get a bit confused because they don't know the size of the terminal [0], but you get other benefits if you choose to use the serial console, like being able to copy-and-paste (and you simply can't get a virtual console like tty1 through IPMI).
# [0] Possible workarounds: https://wiki.archlinux.org/index.php/Working_with_the_serial_console#Resizing_a_terminal
# Still, tty0 ("current virtual console", i.e. whichever out of tty1, tty2, ... is currently active) is left as the "main console" (/dev/console) to get e.g. systemd's boot messages.
kparam=(console=ttyS0,115200 console=ttyS1,115200 console=tty0 ${kparam[@]})
arch-chroot /mnt systemctl enable serial-getty@{ttyS0,ttyS1}.service
sed -i \
-e 's/.*GRUB_TERMINAL_INPUT=.*/GRUB_TERMINAL_INPUT="console serial"/' \
-e 's/.*GRUB_TERMINAL_OUTPUT.*/GRUB_TERMINAL_OUTPUT="gfxterm serial"/' \
-e '/GRUB_TERMINAL_OUTPUT/ a\
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"' \
/mnt/etc/default/grub
case "$bootloader" in
grub)
if [ "$bios" == false ]; then
......
......@@ -157,8 +157,7 @@ install_vm(){
--ram="$VM_RAM" \
--vcpus="$VM_VCPUS" \
--disk path="$VM_DISK".qcow2,bus=virtio \
--graphics none \
--serial pty \
--graphics spice \
--serial pty \
--serial pty \
--cdrom "$VM_CDROM" \
......@@ -178,12 +177,12 @@ create_iso(){
["/root/bootstrap.sh"]="0:0:755"' "$tmpdir/profiledef.sh"
sed -i '3 a\ SERIAL 0 11520' "$tmpdir/syslinux/syslinux.cfg"
sed -i '/^APPEND/ s/$/ console=tty0 console=ttyS0,115200 console=ttyS1,115200 console=ttyS2,115200 console=ttyS3,115200/' "$tmpdir/syslinux/syslinux-linux.cfg"
sed -i '/^options/ s/$/ console=tty0 console=ttyS0,115200 console=ttyS1,115200 console=ttyS2,115200 console=ttyS3,115200/' "$tmpdir/efiboot/loader/entries/archiso-x86_64-linux.conf"
sed -i '/^APPEND/ s/$/ console=ttyS0,115200 console=ttyS1,115200 console=tty0/' "$tmpdir/syslinux/syslinux-linux.cfg"
sed -i '/^options/ s/$/ console=ttyS0,115200 console=ttyS1,115200 console=tty0/' "$tmpdir/efiboot/loader/entries/archiso-x86_64-linux.conf"
mkdir -p "$tmpdir"/airootfs/etc/systemd/system/getty.target.wants/
ln -s /usr/lib/systemd/system/serial-getty@.service "$tmpdir"/airootfs/etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service
ln -s /usr/lib/systemd/system/serial-getty@.service "$tmpdir"/airootfs/etc/systemd/system/getty.target.wants/serial-getty@ttyS1.service
ln -s /usr/lib/systemd/system/serial-getty@.service "$tmpdir"/airootfs/etc/systemd/system/getty.target.wants/serial-getty@ttyS2.service
mkdir -p "$tmpdir"/airootfs/etc/systemd/system/multi-user.target.wants/
mkdir -p "$tmpdir"/airootfs/etc/systemd/system/sockets.target.wants/
......@@ -208,11 +207,11 @@ parted
xfsprogs
EOF
mkdir -p "$tmpdir/airootfs/etc/systemd/system/serial-getty@ttyS0.service.d"
cat > "$tmpdir/airootfs/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf" <<EOF
mkdir -p "$tmpdir/airootfs/etc/systemd/system/getty@tty1.service.d"
cat > "$tmpdir/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf" <<EOF
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin root --keep-baud 115200,57600,38400,9600 %I \$TERM
ExecStart=-/sbin/agetty --autologin root -o '-p -- \\u' --noclear %I $TERM
EOF
mkdir -p "$tmpdir/airootfs/etc/systemd/network"
......@@ -245,7 +244,7 @@ echo
echo "Installing in 3s..."
sleep 3
echo "Installing now..."
/root/bootstrap.sh --hostname "$VM_NAME" --kernel-param console=tty0 --kernel-param console=ttyS0,115200 --kernel-param console=ttyS1,115200 --kernel-param console=ttyS2,115200 ${VM_BOOTSTRAP_PARAMETER[@]}
/root/bootstrap.sh --hostname "$VM_NAME" ${VM_BOOTSTRAP_PARAMETER[@]}
EOF
tmpdir_build="$(mktemp -d --tmpdir tmpdir-archiso-build-XXXXXX)"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment