This is a short guide on getting started with running a Serpent VM using virtiofs as the rootfs. The benefit of this is that the Serpent root is essentially just a folder on your host machine. You are completely unrestricted in using host tools/editors on the Serpent root even while the virtual machine is running. You can also start a systemd-nspawn container from the same root for when you want to be developing SerpentOS but don't need to be testing the full kernel/boot stack (though I would advise you not to run a systemd-nspawn container at the same time you have a VM booted, if it works at all it's likely to lead to corruption).
This guide uses virt-manager because it automatically manages virtiofsd on the host for you. You can do all of these steps without it but you're going to need to figure out the exact CLI syntax and/or XML config syntax to make everything happy.
Finish the onboarding process
Ideally you complete the process in our onboarding repo first, as this will set you up with all necessary tools and repositories like moss
.
Make the Serpent root (adjust paths as desired)
sudo mkdir /mnt/serpent # This folder MUST be owned by root otherwise a bunch of things in systemd error out
sudo moss -D /mnt/serpent repo add volatile https://dev.serpentos.com/volatile/x86_64/stone.index -p10
# If you intend to install local packages:
sudo moss -D /mnt/serpent repo add local file:///var/cache/boulder/repos/local-x86_64/stone.index -p20
Initial packages (adjust to your liking)
sudo moss -D /mnt/serpent install bash bash-completion boulder coreutils curl dash dbus dbus-broker file findutils gawk git grep gzip inetutils iproute2 kbd kmod less libarchive linux-kvm lvm2 moss moss-container nano neofetch nss openssh procps python screen sed shadow sudo systemd unzip util-linux vim wget which
Networking workaround (until glibc gets fixed)
sudo cp -va /etc/protocols /mnt/serpent/etc/
Until you do the above, you won't be able to e.g. use ping
from within your VM instance.
Set up virt-manager virtual machine instance
Once that is done open virt-manager and select "New Virtual Machine"
Choose Manual install:
Search for and select "Generic Linux 2020" (if your distribution ships a "Generic Linux 2022" profile you can use that instead)
The default of 2 CPU cores and 4GB of memory is probably sufficient for initial testing though you can certainly adjust these to your liking.
Uncheck "Enable storage for this virtual machine" (Where we're going we don't need storage).
Name the VM something like "Serpent-BIOS" as for now we're going to be using BIOS as UEFI does not currently work. In the future UEFI will be the only supported option. Also check "Customize configuration before install" and if you like you can edit the network configuration now or go with the default NAT setting.
The configuration screen for the VM will appear. In this initial window make sure "Firmware" is set to "BIOS". After each setting you change make sure you hit "Apply" to save that setting.
Select "Boot Options". Expand "Direct kernel boot" and check "Enable direct kernel boot". Now, you'll need the paths to the initrd and kernel, both of these can be found in the usr/lib/kernel
folder under your Serpent root. In my case the kernel path is /mnt/serpent/usr/lib/kernel/current.kernel
and the initrd is /mnt/serpent/usr/lib/kernel/current.initrd
. Since these are symlinks, you don't need to change this for kernel updates. For kernel args put in rootfstype=virtiofs root=root rw quiet loglevel=3 rd.modules-load=virtio_pci
Click the Video option on the left. Change the model to "Virtio" and make sure "3D acceleration" is enabled.
Go to the Display option. Make sure the Type is Spice server
, Listen type is None
, and OpenGL is selected. In case you have multiple GPUs (i.e. integrated + discrete), make sure you select the one that is powering your display.
Under the NIC section make sure Device model is set to virtio
(it's normal for IP address to be "unknown" now, the VM isn't started).
Under Memory make sure that "Enable shared memory" is enabled (IMPORTANT, virtiofs won't work without this!!)
Now, let's setup the virtiofs mount. Click "Add Hardware", then select "Filesystem" from the available types. Make sure the Driver is virtiofs
, put in your serpent root path (e.g. /mnt/serpent
) as "Source path", and put in root
for the "Target path" (this NEEDS to match the value you put in root=
in the kernel arguments). Click finish to go back to the previous screen.
You should now have everything configured. Select "Begin installation" and assuming everything is working correctly you should be greeted with a running VM window:
If you are using a keyboard layout different to the default one, you can change this by using localectl set-keymap
, e.g.
root@snekbox # ~ localectl set-keymap de
root@snekbox # ~ localectl
System Locale: LANG=en_US.UTF-8
VC Keymap: de
X11 Layout: de
X11 Model: pc105
X11 Options: terminate:ctrl_alt_bksp
Note that you can delete and re-create the serpent root and do not need to delete and recreate the VM.