Save a lot of memory in your Qubes OS server

published Feb 15, 2023

Short on RAM? Running a lot of headless qubes (VMs) in your Qubes OS server? Here's how to put your qubes on a diet.

Save a lot of memory in your Qubes OS server

Lots of smart and privacy-conscious people are using Qubes OS as a server these days.  It makes sense — it's easy to manage VMs, you can get full usage of many VMs simultaneously thanks to automatic memory balancing, and it's well-maintained by the people from the Qubes OS project.  And yours truly is the author of the Qubes network server package, which makes Qubes OS flexible enough to run your own servers on it.

What if you're running a bit low on memory, though?  Especially if you're running a lot of VMs — memory usage adds up quickly.

No worries — thanks to this protip by none other than @marmarek, you can save a ton of memory per VM.

Let's suppose you have three qubes — cherry, apple and tomatorunning headless workloads (that means no graphical UI applications).  You can tell them to forego starting the graphical stack within them.  Run this in your Qubes OS dom0:

for qube in cherry apple tomato ; do
qvm-features $qube gui ''
done

Presto!  Next time you restart these VMs, they won't be able to start up GUI applications, but they will save roughly 100 MB of resident memory each.  Make these changes take effect right away like this:

for qube in cherry apple tomato ; do
qvm-stop --force --wait $qube ; qvm-start $qube
done

Here's some prospective memory savings in one of my qubes.  Try and guess at which time the configuration change took effect:

Specifically, what gets turned off with the qvm-features tweak is support for the Qubes GUI agent.  The agent and several processes that start on boot, therefore, don't get started.  That's what saves you roughly 100 MB.

What about GUI applications?  Don't worry — you can still run them remotely from your desktop or laptop computer via SSH, assuming the qube where you run your specific graphical app has SSH running on it.