I wanted to run through some Arch Linux install procedures and document them. My plan was to connect to the VM via serial console so I could use my regular terminal emulator to copy the output that I was interested in.
In the settings of the VM enable the serial console with the following properties:
- Port Mode: Host Pipe
- Connect to existing pipe/socket unchecked
- Path/Address: <path to the socket>
Now start the VM for the socket to be created.
Connect to the socket
In order to connect to the socket we use socat to link the socket with a new pty device.
$ socat UNIX-CONNECT:<path to the socket> PTY,link=<path to the pty>
We can use good old screen to attach to the pty.
$ screen <path to the pty>
Depending on how fast the previous commands where a reboot / reset of the virtual machine might be necessary.
Since I wanted to boot from an Arch Linux Live CD the following section is focused on those circumstances.
Once I was able to see GRUB2 bootloader I had to enable the serial console in the Linux kernel for the upcoming boot. I had to hit TAB and add the following to the kernel parameters:
Written with the help of ArchWiki - Remastering the Install ISO.
Booting from (U)EFI with console enabled proved to be somewhat more problematic. There is no easy way to that I know of to change the boot parameters. The strategy is to unpack the iso, add another boot menu entry with the console parameters and then pack it again into an iso file.
Mount the ISO:
$ mkdir -p /mnt/iso $ mkdir -p /mnt/newiso $ mount -o loop <path to iso> /mnt/iso $ rsync -av /mnt/iso/ /mnt/newiso/
The boot loader config files are located unter /mnt/newiso/loader/entries. Create a copy of the archiso-x86_64.conf file. In the copy edit the title accordingly and add " console=ttyS0,38400" to the end of the options line.
Now we need to create a new iso file. For this we change back to the root of the new iso.
$ pwd /mnt/newiso $ genisoimage -l -r -J -V "ARCH_201702" -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c isolinux/boot.cat -o ../arch-custom.iso ./
Be aware, the -V parameter should resemble the version of the iso (year, month) as the image will look for that name in /dev/disk/by-label.
When booting from the newly created iso we can now select the new boot menu entry and will have our console over the serial connection.