What are we doing here?

This blog includes a series of videos and references to help new users or enthusiasts better understand how to use open source and free technology tools. The quick links includes more information for accessing many of the tools covered along with other references to learn more for taking advantage of these tools.

Click HERE to see the full list of topics covered!

Using Virt-Manager to Create Base VM Images

This topic is something that I've known about in theory, but never realized until the past couple of weeks ago how easy Virt-Manager (the KVM VM management GUI in Linux) makes this process. To anyone needing to test a lot of things in a Linux environment - or any environment really - and doesn't want to use containers, this will hopefully make your life a little bit happier. 

So I've been creating some self-install scripts for Nextcloud and other software - essentially ways to build up a basic Nextcloud instance from scratch with an easy-to-follow guided flow. In building the script if I hit a snag during testing, I would need to tear down the VM and start over. Thankfully, Virt-Manager can create VM clones. Even better it can leverage the base OS! 

 

If you uncheck the storage option, the image will boot just as the base OS image, and a diff partition will be created. This feature is great for testing, and while there is a notice running this way can be dangerous - essentially if the base OS ever changes the clone could get corrupted I imagine - for testing installs and different package combos, this is really nice. 

Essentially, this feature lets one install a base OS once. Create the user account, add sudo access, etc. once. Then shutdown the base OS, clone it with shared storage and start playing. No need to reinstall the OS, no need to worry if something goes sideways. If the test install somehow has issues, just nuke it, make another clone the good base and start over, or test something else. Really nice!

Why not just use containers?

Docker and podman and kubernetes, etc. are all fantastic tools. However, occasionally, having base feature sets like text editors, systemd, cron, etc, are really helpful. Especially if the instance will be running multiple services with different dependencies etc., using a VM makes a lot of sense. 

How to install it? 

I have a longer video way back in 2020 that goes through the concepts, but if using a Debian variety of Linux (Debian, Ubuntu, LinuxMint, PopOS, ZorinOS, MX Linux, etc.), just run the below command. For RedHat distros just swap 'apt' with 'dnf'.

sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager

Then start the libvirtd service

systemctl enable libvirtd

systemctl start libvirtd

That's all. Virt-Manager will be installed - search for Virtual Machine Manager - and start making VMs!