Enable serial console


Userlevel 5
Please, enable serial console in Cumulus VX (console=ttyS0 console=tty0 on kernel command-line + /etc/inittab)

19 replies

Userlevel 3
Thanks to@vince2_ for tweeting this request:

https://twitter.com/vince2_/status/629282273037275136
Userlevel 2
+1 for sure.... Would be nice to console in via the GNS3 GUI 🙂
Userlevel 2
Working on this myself, since the Cumulus folks haven't responding to this yet (yes, I know you guys are quite busy 😉

The first thing I tried to enable the serial console worked - uncomment the following line in /etc/inittab and then reboot:
S0:3:respawn:/sbin/getty -L $(get-cmdline-console) vt100
After doing this, i could start the VX VM in GNS3, then right-click and select "Console", and it would connect but show nothing until the VM had substantially booted all the way, but then I did get the 'cumulus login: ' prompt, whereupon I could log in and do all the things.

My second edit to allow the kernel messages to be output to the console did not work; in this case I edited '/etc/default/grub'and made the following changes:
# Commented out next two lines due to kernel serial console output test below -=-=- #GRUB_CMDLINE_LINUX_DEFAULT="quiet"
#GRUB_CMDLINE_LINUX=""

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# Added to test kernel serial console output -=-=-=-=-=-=-
GRUB_TERMINAL=console
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1"
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="text console=tty0 console=ttyS0,9600n8"
Then I saved that file and ran 'update-grub' and rebooted, but sadly, no kernel messages were output to the serial console.

I'll keep trying, and report back if I get it, but for now, at least I have a working console connection in GNS3 🙂
Userlevel 2
OK, figured it out, here's the scoop...

Trying to edit /etc/default/grub and then run update-grub is the "right" way to update your /boot/grub/grub.cfg file, but (for reasons unknown) it does not work on VX - it only creates an incomplete /boot/grub/grub.cfg.new file... So, despite the warning out there to "never edit your grub.cfg file directly" (usually a good idea, because it should get built by update-grub) it's the only way to get things working on VX.

So, VERY CAREFULLY make the following edits to /boot/grub/grub.cfg on your VX host:

1) Delete the line:
terminal_output gfxterm
and replace it with the following lines:
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal_input serial
terminal_output serial

2) Add the following parameters:
text console=ttyS0,9600n8
to the end of the line that reads:
linux /bzImage root=/dev/sda2
so that the whole line reads as follows:
linux /bzImage root=/dev/sda2 text console=ttyS0,9600n8

3) Reboot and profit!

Please note: you still have to uncomment the line in /etc/inittab as detailed above to get a login prompt on the serial console.
Userlevel 1
update-grub failing on VX is a known issue. There is a script that is run as part of the process which fails as it can't properly detect the switching platform. This is hopefully something we'll be able to address in future releases.

Thanks for the instructions though; we'll have to see if there's any way we can roll the inittab & Grub changes into the standard VX image so that the console Just Works in GNS3.
Thanks for this Dennis! Helped me out a lot. BTW I tested this with 38400 and it still works, this will look a bit closer to a physical CL/ONIE box from my experience.
Can someone from Cumulus provide guidance on getting this to work with 3.1? Is update-grub normal behavior enabled now? If not can you please advise on how to do this trick in 3.x releases?

Thanks!
I tried this:

sudo sed -i 's/#GRUB_TERMINAL=console/GRUB_TERMINAL=console/g' /etc/default/grub
sudo sed -i 's/#GRUB_TIMEOUT=5/GRUB_TIMEOUT=0/g' /boot/grub/grub.cfg

But I do not see any messages in the console until this pops up towards the end of the boot process:

[ 5.443610] piix4_smbus 0000:00:07.0: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr[ 5.488252] platform microcode: firmware: failed to load intel-ucode/06-3d-04 (-2)

I must be missing something to enable the redirection of the console prior to that part of the boot. Any ideas what that might be?
I tried this:

sudo sed -i 's/#GRUB_TERMINAL=console/GRUB_TERMINAL=console/g' /etc/default/grub
sudo sed -i 's/#GRUB_TIMEOUT=5/GRUB_TIMEOUT=0/g' /etc/default/grub

But I do not see any messages in the console until this pops up towards the end of the boot process:

[ 5.443610] piix4_smbus 0000:00:07.0: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr[ 5.488252] platform microcode: firmware: failed to load intel-ucode/06-3d-04 (-2)

I must be missing something to enable the redirection of the console prior to that part of the boot. Any ideas what that might be?
Userlevel 5
Josh,

Check your order. It needs to be in an order the kernel can read to push the output to the correct place. See this example:

# sed -i 's/^#//' /etc/default/grub.d/00-installer-defaults.cfg
# sed -r -i '/^GRUB_CMDLINE_LINUX=/ s/(console=ttyS0,115200n8) (console=tty0)/\2 \1/' /etc/default/grub
# update-grub
Thanks Scott!

I did the following:

echo 'cumulus ALL=NOPASSWD: ALL' > cumuluschmod 440 cumulus
echo 'CumulusLinux!' | sudo -S cp cumulus /etc/sudoers.d/cumulus
sudo chown root.root /etc/sudoers.d/cumulus

# enable console
sudo sed -i 's/^#//' /etc/default/grub.d/00-installer-defaults.cfg
sudo sed -r -i '/^GRUB_CMDLINE_LINUX=/ s/(console=ttyS0,115200n8) (console=tty0)/ /' /etc/default/grub
sudo /usr/sbin/update-grub

sudo rm /var/lib/dhcp/dhclient.eth0.leases
sudo rm /etc/resolv.conf

The serial port is enabled but when I access the port I only see the following:

Loading Linux 4.1.0-cl-2-amd64 ...
Loading initial ramdisk ...

There is nothing else, however in the graphical terminal in vbox I see additional output leading up to the login prompt.
Userlevel 5
Try reversing the (console=ttyS0,115200n8) (console=tty0) to look like this:

# enable console
sudo sed -i 's/^#//' /etc/default/grub.d/00-installer-defaults.cfg
sudo sed -r -i '/^GRUB_CMDLINE_LINUX=/ s/(console=tty0) (console=ttyS0,115200n8)/ /' /etc/default/grub
sudo /usr/sbin/update-grub
That helped, I get to the console now but I don't see the boot log:

Loading Linux 4.1.0-cl-2-amd64 ...Loading initial ramdisk ...
[ 4.969896] piix4_smbus 0000:00:07.0: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr
[ 5.065692] platform microcode: firmware: failed to load intel-ucode/06-3d-04 (-2)

Debian GNU/Linux 8 cumulus ttyS0

cumulus login:

Meanwhile in the vbox gui I can see the various boot messages scrolling by. Any way to get those into the serial port as well?
Userlevel 5
Josh Saul wrote:

That helped, I get to the console now but I don't see the boot log:

Loading Linux 4.1.0-cl-2-amd...

Check the output of cat /proc/cmdline
Josh Saul wrote:

That helped, I get to the console now but I don't see the boot log:

Loading Linux 4.1.0-cl-2-amd...

cat /proc/cmdlineBOOT_IMAGE=/boot/vmlinuz-4.1.0-cl-2-amd64 root=UUID=25837788-5da4-4d90-ad31-7dfa7bf0ff33 ro cl_platform=cumulus_vx console=ttyS0,115200n8 console=tty0 quiet
Userlevel 5
Josh Saul wrote:

That helped, I get to the console now but I don't see the boot log:

Loading Linux 4.1.0-cl-2-amd...

The boot messages can only go one place or the other but not both (i.e. visual console -- tty0 or the serial console -- ttyS0). So someone is inevitably unhappy with the default, you can change them by modifying the /boot/grub/grub.cfg file or the files which are used to generate that file.
Josh Saul wrote:

That helped, I get to the console now but I don't see the boot log:

Loading Linux 4.1.0-cl-2-amd...

I want the messages to only go to the serial port (I am doing serial redirect for VX so I want it to look like a physical console port).

I don't follow what you are suggesting I change it to for this effect.
Userlevel 5
Josh Saul wrote:

That helped, I get to the console now but I don't see the boot log:

Loading Linux 4.1.0-cl-2-amd...

Looks like there was an error with the sed syntax provided above. The commands to fix it on my box were:
sudo sed -i 's/^#//' /etc/default/grub.d/00-installer-defaults.cfg
sudo sed -i 's/console=tty0/console=new/' /etc/default/grub
sudo sed -i 's/console=ttyS0,115200n8/console=tty0/' /etc/default/grub
sudo sed -i 's/console=new/console=ttyS0,115200n8/' /etc/default/grub
sudo /usr/sbin/update-grub

Not the prettiest group of commands but this should provide the behavior you're looking for, (it did in my tests).
Josh Saul wrote:

That helped, I get to the console now but I don't see the boot log:

Loading Linux 4.1.0-cl-2-amd...

That works perfectly! Thanks.

Reply