Install Ubuntu 20.04 LTS Via Serial Console

I have a few PC Engines APU units that do not have a graphics adapter, and are designed to be setup via a serial interface.

The first step is to find the mini.iso that is made available on the mirrors. This ~75MB image is the core installer for Ubuntu and it will download the items needed to complete your install as it runs, instead of it being pre-loaded onto a larger ISO image. Ubuntu does not make it that easy to find anymore, but if you know where to look you can find what you need.

Head to the below link, and then navigate into the version of Ubuntu you’re looking to install. In this case, 20.04 is Focal.

Once you’ve selected your version, you just need to navigate down into the folder for installers and grab the mini.iso file. The full path, as of Feb 5th, 2021, is below:

Once downloaded, use your preferred method to image it onto a CD, or thumb-drive. I use a thumb-drive and DD to make that happen. For instance;

dd if=/the/path/to/mini.iso of=/you/thumbdrive bs=4k status=progress && sync

With that done, pop it into your APU device, hook up the serial interface, plug it into a network with DHCP, and apply power.

I talk to the APU via another PC using the screen command and a USB serial adapter. My APU is setup to talk serial at the 115200 speed, but you’ll want to check the manual for your device to see what it’s defaults are.

The command I use to open up that session is:

screen /dev/ttyUSB0 115200

or, depending on how your system is setup:

sudo screen /dev/ttyUSB0 115200

You should see a prompt that says 'Press F10 key now for boot menu' which will allow you to select your thumb-drive, if it's not your default. A few moments later a small blue box will open and ask you how you want to proceed. Simply press the tab key on your keyboard at this point to stop the countdown, and show you the boot command, which we'll edit.

Ubuntu Mini.iso Boot Menu

The default command, which will not present us an interface over serial is

linux vga=788 initrd=initrd.gz --- quiet

Instead, you need to remove the vga portion, and add in the console details. I also remove the ‘quiet’ option, since I’d like to see what’s happening while it boots, to be sure it’s working.

Updated, the command should look like the below. When it does, press enter.

linux initrd=initrd.gz console=tty0 console=ttyS0,115200n8

You’ll then see the system boot into the installer, which will all appear in your terminal window. You can do whatever system setup you need to and get your system installed. When complete, as prompted, remove the thumb-drive and reboot.

When the system reboots, you’ll see the boot loader and then the terminal window will go blank. Allow a few minutes and then check to see what IP the unit picked up via your DHCP server, and SSH into it. We need to tweak the grub bootloader for the OS to tell it about the serial terminal as well. This may be possible to do prior to rebooting after install, but I have no looked into that.

Once you’d SSH’d onto the machine, edit the /etc/default/grub command as the super user:

Update this line:

And add this line below it:
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"

Save your edits and then run:

sudo update-grub

Reboot the machine one more time, and after the boot-loader, you’ll see the system boot into the installed OS and then deliver you at a login prompt. I still admin these machines primarily over SSH, but when something is wrong it’s great to be able to hook up the serial connection and see what the hardware is doing, or fix a bad network config, etc.

Long Live the Serial Cable!

4 Replies to “Install Ubuntu 20.04 LTS Via Serial Console”

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.