Discussion:
grub2 + serial redirect
Lev Lvovsky
2010-02-04 17:44:47 UTC
Permalink
Hello,

So after 12+ years of using lilo on my server, I've decided that it might be time to upgrade my boot loader. With lilo I'm using the standard serial redirect since I'm running a headless box (more specifically it's a guest of a VirtualBox host).

With Grub2, I've been able to get the standard serial redirect working with the following in my /etc/default/grub:

---
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600"
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1"
---

This works fine once the kernel is booted (it redirects output to my serial port). I am not able to see the boot menu with this new configuration however - it appears on the "video" portion of the screen, and I'm able to select a kernel that way, but the serial ouput gets nothing. With Grub v.1 on other machines with serial redirect, I've been able to get the menu. Is there some option that I'm missing?

Additionally, IIRC, the GRUB_CMDLINE_LINUX option above is conditional, meaning that if I want video vs. serial redirection while booting, I need to swap the two 'console' directives. Given that there's only one way I can specify the linux command line option, how would I go about doing this?

thanks!
-lev
Tom H
2010-02-04 20:14:56 UTC
Permalink
So after 12+ years of using lilo on my server, I've decided that it might be time to upgrade my boot loader.  With lilo I'm using the standard serial redirect since I'm running a headless box (more specifically it's a guest of a VirtualBox host).
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600"
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1"
This works fine once the kernel is booted (it redirects output to my serial port).  I am not able to see the boot menu with this new configuration however - it appears on the "video" portion of the screen, and I'm able to select a kernel that way, but the serial ouput gets nothing.  With Grub v.1 on other machines with serial redirect, I've been able to get the menu.  Is there some option that I'm missing?
Additionally, IIRC, the GRUB_CMDLINE_LINUX option above is conditional, meaning that if I want video vs. serial redirection while booting, I need to swap the two 'console' directives.  Given that there's only one way I can specify the linux command line option, how would I go about doing this?
Here's a WAG:

Change
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600"
to
GRUB_CMDLINE_LINUX="console=ttyS0,9600"
and run
update-grub
and reboot to see if you have the serial output (and still have the
console output).
Matt Zagrabelny
2010-02-04 21:28:52 UTC
Permalink
Post by Tom H
Post by Lev Lvovsky
So after 12+ years of using lilo on my server, I've decided that it might be time to upgrade my boot loader. With lilo I'm using the standard serial redirect since I'm running a headless box (more specifically it's a guest of a VirtualBox host).
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600"
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1"
This works fine once the kernel is booted (it redirects output to my serial port). I am not able to see the boot menu with this new configuration however - it appears on the "video" portion of the screen, and I'm able to select a kernel that way, but the serial ouput gets nothing. With Grub v.1 on other machines with serial redirect, I've been able to get the menu. Is there some option that I'm missing?
Additionally, IIRC, the GRUB_CMDLINE_LINUX option above is conditional, meaning that if I want video vs. serial redirection while booting, I need to swap the two 'console' directives. Given that there's only one way I can specify the linux command line option, how would I go about doing this?
Change
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600"
to
GRUB_CMDLINE_LINUX="console=ttyS0,9600"
and run
update-grub
and reboot to see if you have the serial output (and still have the
console output).
Here is mine and I have the same problem as the OP.

% cat /etc/default/grub
# This file is sourced by update-grub, and its variables are propagated
# to its children in /etc/grub.d/
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX="rootdelay=15 console=ttyS0,9600"
GRUB_TERMINAL=serial


Note the GRUB_CMDLINE_LINUX line, it includes console=ttyS0,9600.

Perhaps it is time to file a bug report against grub-pc?
--
Matt Zagrabelny - ***@d.umn.edu - (218) 726 8844
University of Minnesota Duluth
Information Technology Systems & Services
PGP key 4096R/42A00942 2009-12-16
Fingerprint: 5814 2CCE 2383 2991 83FF C899 07E2 BFA8 42A0 0942

He is not a fool who gives up what he cannot keep to gain what he cannot
lose.
-Jim Elliot
Tom H
2010-02-04 23:20:25 UTC
Permalink
Post by Matt Zagrabelny
Post by Tom H
Change
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600"
to
GRUB_CMDLINE_LINUX="console=ttyS0,9600"
and run
update-grub
and reboot to see if you have the serial output (and still have the
console output).
Here is mine and I have the same problem as the OP.
% cat /etc/default/grub
# This file is sourced by update-grub, and its variables are propagated
# to its children in /etc/grub.d/
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX="rootdelay=15 console=ttyS0,9600"
GRUB_TERMINAL=serial
That answers my WAG, in the negative...
Lev Lvovsky
2010-02-04 23:26:51 UTC
Permalink
Matt,
Post by Matt Zagrabelny
Note the GRUB_CMDLINE_LINUX line, it includes console=ttyS0,9600.
Perhaps it is time to file a bug report against grub-pc?
After your explaining how to do this privately, I dug through the existing bug reports, and found this:

http://www.mail-archive.com/debian-bugs-***@lists.debian.org/msg685989.html

This looks sort of similar to the related problem, although oddly enough even specifying serial doesn't get the menu on the serial console. I have to see what the video output looks like once booting...

thanks,
-lev
Lev Lvovsky
2010-02-04 21:55:31 UTC
Permalink
Hi Tom,
Post by Tom H
Change
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600"
to
GRUB_CMDLINE_LINUX="console=ttyS0,9600"
and run
update-grub
and reboot to see if you have the serial output (and still have the
console output).
I'm not at the machine right now (don't have access to see how the video looks), but this should only change the operation of the booting of the kernel, rather than the availability of the Grub menu. On machines which use grub1, I have the following:

"terminal --timeout=1 serial console"

currently, for grub2, I have:

"terminal serial"

no timeout value, and no option to pass both serial and console in - apparently grub2 does not support the timeout option for that line.

thanks,
-lev
Tom H
2010-02-04 23:18:05 UTC
Permalink
Post by Tom H
Change
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600"
to
GRUB_CMDLINE_LINUX="console=ttyS0,9600"
and run
update-grub
and reboot to see if you have the serial output (and still have the
console output).
It was just a WAG...
Lev Lvovsky
2010-02-04 23:23:07 UTC
Permalink
Hey Tom,
Post by Tom H
It was just a WAG...
and much appreciated - usually if I write something out like that, it might help me sort out where else to look (http://c2.com/cgi/wiki?RubberDucking)

thanks,
-lev
Tom H
2010-02-05 05:56:04 UTC
Permalink
Post by Lev Lvovsky
Post by Tom H
It was just a WAG...
and much appreciated - usually if I write something out like that, it might help me sort out where else to look (http://c2.com/cgi/wiki?RubberDucking)
You're welcome. Sorry it was useless...
Andrew Malcolmson
2010-02-05 15:21:37 UTC
Permalink
Post by Lev Lvovsky
Hello,
[snip.
Post by Lev Lvovsky
This works fine once the kernel is booted (it redirects output to my serial port).  I am not able to see the boot menu with this new configuration however - it appears on the "video" portion of the screen, and I'm able to select a kernel that way, but the serial ouput gets nothing.  With Grub v.1 on other machines with serial redirect, I've been able to get the menu.  Is there some option that I'm missing?
I was working on this a few weeks ago and AFAICK I needed the
following in grub.cfg to serial the grub menu over serial:

terminal_input serial
terminal_output serial
Post by Lev Lvovsky
Additionally, IIRC, the GRUB_CMDLINE_LINUX option above is conditional, meaning that if I want video vs. serial redirection while booting, I need to swap the two 'console' directives.  Given that there's only one way I can specify the linux command line option, how would I go about doing this?
According to the following bug report (which is also where I saw an
example using the two above lines in grub.cfg), concurrent output is
coming:

http://old.nabble.com/-bug--28628--Concurrent-console-and-serial-access-td27186757.html
Lev Lvovsky
2010-02-05 16:59:32 UTC
Permalink
Andrew,
Post by Andrew Malcolmson
Post by Lev Lvovsky
Hello,
[snip.
Post by Lev Lvovsky
This works fine once the kernel is booted (it redirects output to my serial port). I am not able to see the boot menu with this new configuration however - it appears on the "video" portion of the screen, and I'm able to select a kernel that way, but the serial ouput gets nothing. With Grub v.1 on other machines with serial redirect, I've been able to get the menu. Is there some option that I'm missing?
I was working on this a few weeks ago and AFAICK I needed the
terminal_input serial
terminal_output serial
Thanks, I'll give this a shot tonight, if it works, I'm assuming that this is an upstream patch to the update-grub script?

-lev
Andrew Malcolmson
2010-02-06 15:14:03 UTC
Permalink
Post by Lev Lvovsky
Thanks, I'll give this a shot tonight, if it works, I'm assuming that this is an upstream patch to the update-grub script?
Sorry for wasting your time. I've retested my original setup both
over a serial cable to a single-board computer and by booting an image
file on my PC with 'kvm -nographic'. I get the same issue you did:
no Grub menu over serial but shows fine over console.

I'm recompiling grub from the source in Sid with an explicit
'--enable-serial' configure option. I'll let you know if I turn up
anything worthwhile.

Loading...