Custom Arch .iso with Serial Console

In CS 326 we set up virtual machines to use during the semester. Arch Linux is a great choice for this because it is well-documented but requires students to get their hands dirty during the installation process.

Initially, I’d have students set up using a graphical console via VNC or Spice. However, this was often a bit painful: ports would need to be forwarded (our VMs are located behind a jumphost), copy and paste doesn’t work, and ultimately running GUI applications on our VM host’s amazing GPU with 16 MB of video RAM proved to be fairly miserable.

Might as well install text-only using a serial console instead; the Arch Linux installation happens all from the command line anyway. However, the installer .iso does not support this by default.

Installing Arch via Serial Console

According to the Arch Wiki, getting serial output is as easy as appending the following to the kernel command line from the bootloader menu:

console=ttyS0,38400

…except doing this over KVM is tricky: by the time the serial console is launched, the boot timeout may have already elapsed, the menu might not display properly, and in general this can be quite confusing for students that are being thrown mercilessly into the deep end.

Serial by Default

We can build our own Arch Linux installer .iso with the serial output on by default. This also gives us the opportunity to customize the install environment (rather than only referencing the Arch Linux wiki in the MOTD, we can add a link to our class page, tips, etc.).

Doing so is easy with Archiso. Install with pacman -Sy archiso.

We’ll use the releng profile. This is the same profile used for the monthly install image published on Arch Linux’s homepage.

# First, cd to wherever you'd like to work.
$ cd work

$ cp -vr /usr/share/archiso/configs/releng/ archlive

( ... lots of files copy ... )

$ cd archlive

BIOS-Based Systems

Now we need to update the kernel command line in the bootloader configuration. Since our VMs are emulating a system with a BIOS, we need to edit syslinux/archiso_sys-linux.cfg and add/modify an APPEND directive to the bootloader entry to add parameters to the command line:

APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% console=ttyS0,38400

The console=ttyS0,38400 at the end is the important part!

NOTE: It seems like the names of these files change over time. If yours is named slightly different but contains the same configuration options, you’ll probably be fine.

EFI-Based Systems

If you are using/emulating an EFI system, then you will need to edit efiboot/loader/entries/01-archiso-x86_64-linux.conf. Update the ‘options’ line:

options archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% console=ttyS0,38400

NOTE: It seems like the names of these files change over time. If yours is named slightly different but contains the same configuration options, you’ll probably be fine.

Wrapping Up

You can also add files, packages, etc. to the live environment. airootfs contains files that will be present in the installation environment. I like to edit airootfs/etc/motd to add some useful information to the MOTD for students and put a copy of our installation guide in airootfs/root in case they’re particularly command line-inclined.

Building the .iso

Now that the install environment is customized to our liking, we can build the iso. Assuming you are in the archlive directory we created earlier, you can simply run:

mkarchiso -v .

…and the resulting .iso file will be stored in the out directory once the process is finished.