Random experimentation: making a truly-headless VirtualBox Linux VM
I got the farthest I could to make my lightest VM ever, totally headless (i.e., no video at all) while still keeping network-related functionalities:
- It's an UEFI Void Linux setup, whose live ISO originally can't boot with less than 2GB (tried to boot with less than 2GB before installation just to face a kernel panic). I installed it, then I started to find out how far I could reduce its RAM.
- No video at all, no SSH either: I configured both the GRUB and the Linux to use the serial port. I can access it using `socat` and `screen`/`minicom` together. I can choose which device to boot at GRUB (although there's no need for choosing other than the Void Linux that's installed there), I can see the plymouth boot "screen" (without a screen), and I can login and have a full `bash` shell (in the screennshot, I'm using `dash` to hide the hostname).
- There's an iptables inside, as well as two interfaces, because I'm intending to set it up as a tiny router to isolate another VM from the LAN while allowing it (the other VM) to access the WAN (the Internet).
Purpose: not that I needed to make it lighter (than it already was before removing
the video)... however, I did it "because it can be done".
Some issues:
- I couldn't get to remove `btrfs`: although I instructed `dracut` to omit the `btrfs` module, as well as blacklisting it through `/etc/modprobe.d/blacklist.conf`, it's still being loaded somehow, as the plymouth shows " Activating btrfs devices... Scanning for Btrfs filesystems". There's no btrfs partition within the setup, just the swap, ext4 and fat32 (vfat) (the EFI partition).
- I still need to find a way to `stty cols .. rows ..` automatically (i.e., having host's `screen` and guest's `getty`/`bash`/whatever to communicate somehow regarding host `screen`'s current terminal size), outside a SSH environment. I avoided configuring a SSH daemon just because it can be done.
- VirtualBox isn't made for truly-headless VMs. While one can set "Graphics Adapter" to "None", setting 0MB of graphical memory supposedly makes it glitch.
Screenshot: