Ubuntu Serial Console Login

|  |  |  | Remember Me | Forgot your password?

User login
07/08/2013 20:36:09

- 1
- 2
- 3

Replay

Networking
More

Hardware
More

Software
More

Consultation
More

## Ubuntu Serial Console Login

If you have a headless machine, as is the case with many serviers, it is often nice to be able to see what's going on without having to connect a monitor and a keyboard to the system. In this short tutorial we'll show you how to configure the serial port on your server, or Desktop, machine to allow you to view the console though it.

Assumptions

- You have enabled the serial console in your BIOS
- The serial connection is being made at 115200 baud 8n1, on first serial port, called /dev/ttyS0 in linux (9600 8n1 is the default fall back if your hardware does not support 115200 baud)
- You are comfortable editing critical system files such as /etc/inittab, /boot/grub/menu.lst
- You are using a serial (null modem) cable. It is also possible to use a USB to Serial adaptor, but the tty* must be changed to reflect your hardware.

Configuring the console login process

Newer Ubuntu systems use Upstart, that is what we will be configuring first.

If you look in `/etc/init` you will see the other terminal services they have names like `tty1.conf`. We are simply going to make a copy of on of these files:

    cp /etc/init/tty1.conf /etc/init/ttyS0.conf

Next we edit the file, making the following changes:

Change

    # tty1 - getty

To

    # ttyS0 - getty

Change

    # This service maintains a getty on tty1 from the point the system is

To

    # This service maintains a getty on ttyS0 from the point the system is

Change

    exec /sbin/getty -8 38400 tty1

To

    exec /sbin/getty -L 115200 ttyS0 vt102

Strictly speaking the changes to the comments are not necessary but should still be done.

When your done the file should look like:

    # ttyS0 - getty
    #
    # This service maintains a getty on ttyS0 from the point the system is
    # started until it is shut down again.

    start on stopped rc RUNLEVEL=[2345]
    stop on runlevel [!2345]

    respawn
    exec /sbin/getty -L 115200 ttyS0 vt102

At this point simply start the service:

    sudo start ttyS0

DONE!

Configuring grub

What happens if things go wrong before a login is available, it would be nice to be able to see what is going on during start up at well. That's what we'll do in this section.

To that end let's edit `/etc/default/grub` and add the following lines:

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

When were done the file should look like:

    # If you change this file, run 'update-grub' afterwards to update
    # /boot/grub/grub.cfg.
    # For full documentation of the options in this file, see:
    #   info -f grub -n 'Simple configuration'

    GRUB_DEFAULT=0
    #GRUB_HIDDEN_TIMEOUT=0
    GRUB_HIDDEN_TIMEOUT_QUIET=true
    GRUB_TIMEOUT=2
    GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    GRUB_CMDLINE_LINUX_DEFAULT="quiet"
    GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"

    # Uncomment to enable BadRAM filtering, modify to suit your needs
    # This works with Linux (no patch required) and with any kernel that obtains
    # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
    #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

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

    # The resolution used on graphical terminal
    # note that you can use only modes which your graphic card supports via VBE
    # you can see them in real GRUB with the command `vbeinfo'
    #GRUB_GFXMODE=640x480

    # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
    #GRUB_DISABLE_LINUX_UUID=true

    # Uncomment to disable generation of recovery mode menu entries
    #GRUB_DISABLE_RECOVERY="true"

    # Uncomment to get a beep at grub start
    #GRUB_INIT_TUNE="480 440 1"

Instead of:

    # If you change this file, run 'update-grub' afterwards to update
    # /boot/grub/grub.cfg.
    # For full documentation of the options in this file, see:
    #   info -f grub -n 'Simple configuration'

    GRUB_DEFAULT=0
    #GRUB_HIDDEN_TIMEOUT=0
    GRUB_HIDDEN_TIMEOUT_QUIET=true
    GRUB_TIMEOUT=2
    GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    GRUB_CMDLINE_LINUX_DEFAULT="quiet"
    GRUB_CMDLINE_LINUX=""

    # Uncomment to enable BadRAM filtering, modify to suit your needs
    # This works with Linux (no patch required) and with any kernel that obtains
    # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
    #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

    # Uncomment to disable graphical terminal (grub-pc only)
    #GRUB_TERMINAL=console

    # The resolution used on graphical terminal
    # note that you can use only modes which your graphic card supports via VBE
    # you can see them in real GRUB with the command `vbeinfo'
    #GRUB_GFXMODE=640x480

    # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
    #GRUB_DISABLE_LINUX_UUID=true

    # Uncomment to disable generation of recovery mode menu entries
    #GRUB_DISABLE_RECOVERY="true"

    # Uncomment to get a beep at grub start
    #GRUB_INIT_TUNE="480 440 1"

After the changes you will need to update grub

    sudo update-grub

DONE!

#### Add comment

Name (required)

E-mail (required, but will not display)

Website

1000 symbols left

Notify me of follow-up comments

Refresh

Send
Cancel