Enable Serial Console on Boot: Difference between revisions

From Alpine Linux
m (Update referenced extlinux.conf version)
(Added xen serial console config)
Line 38: Line 38:
Notice, if you want to use this for a Xen VM,
Notice, if you want to use this for a Xen VM,
you need to configure the speed at '''115200''' bps and enable the  
you need to configure the speed at '''115200''' bps and enable the  
<pre>serial="pty"
<pre>serial="pty"</pre>
setting in the VM config file.
 
----
 
Xen can be configured to use and log to a serial console by editing /etc/update-extlinux.conf to include the following lines:
<pre>
default_kernel_opts="console=hvc0 earlyprintk=xen nomodeset"
xen_opts="dom0_mem=256M com1=115200,8n1 console=com1"
</pre>
</pre>
setting in the VM config file.
 
See the [http://wiki.xen.org/wiki/Xen_Serial_Console Xen wiki] for more details.


=== Example /boot/extlinux.conf ===
=== Example /boot/extlinux.conf ===

Revision as of 06:23, 11 November 2015

How to Enable the Serial Console on Boot (1.10.x)

When using syslinux to boot, you'll need to modify the syslinux.cfg file in the root directory of the boot device. If using a disk-based Alpine, modify the /boot/extlinux.cfg file.

Add the following:

  • serial 0 9600
  • add console=ttyS0,9600 to the append parameter
  • optionally, remove quiet from the append parameter

Example syslinux.cfg

serial 0 9600
timeout 20
prompt 1
default grsec
label grsec
        kernel /boot/grsec
        append initrd=/boot/grsec.gz alpine_dev=sda1:vfat modules=sd-mod,usb-storage console=ttyS0,9600


extlinux.conf (3.0+)

The /etc/update-extlinux.conf is read by the update-extlinux utility.

To do so, change the default entry:

default_kernel_opts="quiet"

to read like this:

default_kernel_opts="console=ttys0,9600 quiet"

Set the serial port and baud rate to match the default_kernel_opts line above:

serial_port=0
serial_baud=9600

Xen

Notice, if you want to use this for a Xen VM, you need to configure the speed at 115200 bps and enable the

serial="pty"

setting in the VM config file.


Xen can be configured to use and log to a serial console by editing /etc/update-extlinux.conf to include the following lines:

default_kernel_opts="console=hvc0 earlyprintk=xen nomodeset"
xen_opts="dom0_mem=256M com1=115200,8n1 console=com1"

See the Xen wiki for more details.

Example /boot/extlinux.conf

This is a complete file, written by the update-extlinux command.

DEFAULT menu.c32
PROMPT 0
MENU TITLE Alpine/Linux Boot Menu
MENU AUTOBOOT Alpine will be booted automatically in # seconds.
SERIAL 0 9600
TIMEOUT 100
LABEL grsec
  MENU DEFAULT
  MENU LABEL Linux 3.10.33-0-grsec
  LINUX vmlinuz-3.10.33-0-grsec
  INITRD initramfs-3.10.33-0-grsec
  APPEND root=UUID=re-mov-ed-uu-id modules=sd-mod,usb-storage,ext4 console=ttyS0,9600

MENU SEPARATOR

Please: adjust the tty speed to 115200 if needed (Xen!!).

The timeout is given in centiseconds, so this would be a 10 second timeout.

If the file is read by pygrub, the same value is interpreted as seconds, resulting in a 100s bootup delay per VM.

Enabling a login console

This is done in /etc/inittab. There is commented entry for ttyS0. Just enable it.

# Put a getty on the serial port
ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100

I don't know how to restart init on Alpine, so I reboot. Probably there is a a rebootless way for this?