3

I am using grub2 on CentOS 7. I would like to know if it's possible to display output to both serial (ttyS0) and console (tty1) when I attempt to boot into single user mode. The ultimate goal is to have a permanent "single user" grub menu item entry that I can select to boot into and I may be on serial or I may be on console.

Displaying output to both console and serial simultaneously works when the system boots under 'normal' conditions. Meaning, just a standard linux kernel boot line that grub2 would generate. My /etc/default/grub file looks like:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
GRUB_CMDLINE_LINUX="rd_NO_LUKS rd_NO_LVM rd_NO_DM crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,115200"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_LINUX_LABLE=true

After running grub2-mkconfig, my grub "linux16" line looks like:

linux16 /vmlinuz-3.10.0-693.2.2.el7.x86_64 root=UUID=ea3ace60-3b6f-4be1-beaa-fcab95e66bb1 ro rd_NO_LUKS rd_NO_LVM rd_NO_DM crashkernel=auto rhgb quiet console=tty1 console=ttyS0,115200

The kernel parameter that gets me to a shell without requiring a password is: rd.break (seems like there are many ways to boot into single-user mode so I chose this one but I can be convinced to use another method).

So, if I boot the system using

linux16 /vmlinuz-3.10.0-693.2.2.el7.x86_64 root=UUID=ea3ace60-3b6f-4be1-beaa-fcab95e66bb1 ro rd_NO_LUKS rd_NO_LVM rd_NO_DM crashkernel=auto rhgb quiet console=tty1 console=ttyS0,115200 rd.break

I get to a shell prompt but only over serial.

I have gotten single-user mode to display on tty1 (by putting console=tty1 at the end of the line) and not serial but I'd like to have both.

Is this possible? What combination of kernel parameters would work?

(If you have docs going into detail explaining why it's not possible I'll happily look them over. I can only guess that single-user mode only initiates the bare minimum and this includes virtual terminals???)

  • rd.break does not enter single user mode. Aside from the fact that single user mode hasn't been a mode since 1995 when it was split into two modes, rd.break is simply inserting a breakpoint, not actually changing to emergency or rescue mode. – JdeBP Dec 13 '17 at 21:41
  • Sometimes I learn bad habits when I read a blog post about something and it seems to work for me. Thanks for pointing that out. Both "rescue" and "emergency" modes show me a login prompt so I'm unsure how to proceed when I'm at a login prompt if I don't know my login. I may be facing problems with the "mode" I'm booting into and the "failed console redirection" (this question). Perhaps the break point is failing to let tty attach to both consoles? – harperville Dec 13 '17 at 21:50
  • This will work: Set console={tty1,ttyS0} – antonio Aug 9 '18 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.