LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Can I put a card in a generic PC to make Linux have a serial console? (https://www.linuxquestions.org/questions/linux-hardware-18/can-i-put-a-card-in-a-generic-pc-to-make-linux-have-a-serial-console-4175528675/)

raindog308 12-18-2014 12:55 PM

Can I put a card in a generic PC to make Linux have a serial console?
 
I have a couple Linux boxes at home, and they're all based on desktop-class machines (i.e., not rackmountable servers). For example, a run of the mill Asus i3 motherboard.

If I have an issue with the system or want to do something in single user mode, I have to drag a monitor/mouse/keyboard over to it and access it that way. I could invest in a KVM setup but that is really overkill - and I couldn't access the console if I was remote anyway.

The boxes don't have serial ports on them (most PCs don't these days, alas) and I'm wondering if I can buy an add-on card and tell Linux "use this serial as your console" so that on boot all input goes there and I can connect to it from another server (via tip/cu).

I also have a USB-to-serial device and am wondering if that is an option. Ideally, I'd have both boxes running their consoles on serial ports, and then those serial ports could be accessed via tip from one server.

Or is this something that needs to be wired into the mobo?

I have a Soekris box (which is a small embedded system) with a serial port, and this is exactly what I do - but that port is directly on the mobo and the BIOS supports it, while my Linux boxes are generic PCs.

onebuck 12-18-2014 02:44 PM

Member response
 
Hi,

If the system are on your LAN then why not use 'ssh' to access for work/maintenance?
Have fun & enjoy!
Hope this helps.
:hattip:

michaelk 12-18-2014 03:09 PM

Yes, you can find lots of info on configuring a serial console but it depends on the distribution / version i.e using inittab or systemd etc. Most recent versions should be able to use a USB adapter but not confirmed.

raindog308 12-18-2014 04:26 PM

Quote:

Originally Posted by onebuck (Post 5287078)
If the system are on your LAN then why not use 'ssh' to access for work/maintenance?

ssh is only available after the network comes up. I'm talking about having the device talk to the serial as a console the moment the kernel starts booting.

This might be useful: http://www.vanemery.com/Linux/Serial...l-console.html

michaelk 12-18-2014 04:36 PM

A bit dated but the basic concept has not changed. We need to know what distribution / version you are running. Many have gone to using systemd or upstart and inittab is not used anymore.

raindog308 12-18-2014 04:39 PM

CentOS 7 and Debian 7, so both systemd and inittab at the moment. Would this only be supported on one or the other?

michaelk 12-18-2014 04:47 PM

Quote:

Would this only be supported on one or the other?
I don't understand your question.

raindog308 12-18-2014 04:56 PM

Sorry, what I meant is "do Centos 7 and Debian 7 both support a serial console"?

I'm assuming they do, though the procedure for getting there is different, given that one is systemd and one is /etc/init.d

michaelk 12-18-2014 05:37 PM

Yes.

raindog308 12-23-2014 03:44 PM

Well I'm a little further along with this but it isn't quite working.

What I'm hoping is that after BIOS, everything from the grub stage on will go to the serial console. I've got the serial console working, but it only seems to come up after boot is finished.

I'm running Debian 7 and was using this guide: http://www.coreboot.org/Serial_console#GRUB2

I put this in /etc/default/grub:

Code:

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=serial
GRUB_TERMINAL_OUTPUT=serial
GRUB_TERMINAL_INPUT=serial
GRUB_SERIAL_COMMAND="serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1"

And then did an update-grub2 but this made no difference. ttyS0 talks fine after boot, but I don't see boot (i.e., the kernel startup messages, the services starting, etc.)

I also tried the 40_custom which was the same.

As I understand things, while I can't get BIOS over serial, I should be able to get everything from grub on forward over serial. What I'm looking for is to have the serial port as the console, not just another login.

raindog308 12-23-2014 05:13 PM

The magic sauce is that this is a two-phase problem. You have to tell grub and the kernel to use ttyS0.

So in addition to the above, you also need:

Code:

GRUB_CMDLINE_LINUX="console=ttyS0,115200"
One final question - once the console is up and running, I see the following on the console (tip'd in from another host). Everything is legible until the boot is finished, then it's garbage. I'm connecting at 115200...is there another setting needed?

Code:

[ ok ] Starting system message bus: dbus.
[ ok ] Starting ACPI services....
[ ok ] Starting network connection manager: NetworkManager.
[ ok ] Starting GNOME Display Manager: gdm3.
~xf~xfx`xf~`ffxf`ffxf~f``fxxffxf~fx``fx``枞`ffxf~fxfff`ffxxf~


michaelk 12-23-2014 05:17 PM

Try adding:
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"

http://wiki.linuxservertech.com/inde...155&artlang=en

onebuck 12-23-2014 05:19 PM

Member response
 
Hi,

From: https://duckduckgo.com/l/?kh=-1&uddg...-4175528157%2F

Looking at this if you have source installed; /usr/source/linux/Documentation/kernel-parameters.txt;

You can also look at: kernel-parameters.txt , you will need to scroll down to console=;
Quote:

console= [KNL] Output console device and options.

tty<n> Use the virtual console device <n>.

ttyS<n>[,options]
ttyUSB0[,options]
Use the specified serial port. The options are of
the form "bbbbpnf", where "bbbb" is the baud rate,
"p" is parity ("n", "o", or "e"), "n" is number of
bits, and "f" is flow control ("r" for RTS or
omit it). Default is "9600n8".

See Documentation/serial-console.txt for more
information. See
Documentation/networking/netconsole.txt for an
alternative.

uart[8250],io,<addr>[,options]
uart[8250],mmio,<addr>[,options]
Start an early, polled-mode console on the 8250/16550
UART at the specified I/O port or MMIO address,
switching to the matching ttyS device later. The
options are the same as for ttyS, above.
hvc<n> Use the hypervisor console device <n>. This is for
both Xen and PowerPC hypervisors..
You would need to pass this to the kernel to set things early.
Hope this helps.
Have fun & enjoy!
:hattip:

onebuck 12-24-2014 09:27 AM

Member response
 
Hi,

One thought that came to mind is what type of cable configuration are you using? Null modem cable for RS232 would be the easiest to setup if you not need handshaking.

raindog308 12-24-2014 10:57 AM

Adding the 'n8' to

Code:

GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
to specify line parameters solved the issue. Thanks to all for your help.


All times are GMT -5. The time now is 11:11 PM.