A Debian 13 VM with 300 MB RAM

Virtual machine RAM use with Debian 13 and Wireguard running in a Docker container.

Back in 2022 I upgraded most of my virtual machines to Ubuntu 22.04. As I had quite a number of VMs that only ran a single program, I ran them with 512 MB of RAM. The bad surprise: Ubuntu 22.04 significantly increased the RAM requirement out of the box, so the VMs wouldn’t even boot anymore after upgrading until I increased the assigned RAM to the VM to 768 MB. Disappointing, but what could I do, I thought at the time. Now I know: Go back one step and use Debian as basis for my VMs. This gets rid of all the stuff Canonical has added to Ubuntu over the years, which I really don’t need on my VMs. Ubuntu is based on Debian, so the learning curve was not that steep. But RAM usage is now even less than what I ever required for an Ubuntu based VM!

A Practical Example

The whole thing started because I wanted to set up a small VM for a containerized Wireguard server. Based on Debian 13, I reduced RAM down to 300 MB, and together with a swap file of 1 GB, the system runs just fine. On just 300 MB of RAM!

Swap Use is the Tradeoff

There is a bit of swap usage, around 100 MB per day. And despite being written to an SSD, that’s fine for me. A nice tradeoff. The VM would work just fine without the swap for Wireguard, but some periodic tasks like updating the VM with apt update && apt upgrade requires more than the 300 MB of RAM.

Here’s the command I used to check swap usage:

date; grep -E 'pswpout' /proc/vmstat

The output is the number of swapped out pages (4 kB) since startup. So subtract a current value from a previous one and multiply the result by 4 to get the amount of data swapped out in kB.

Less Disk Space

Another nice benefit: Instead of well over 5 GB of installed files including a swap file, Debian 13 out of the box requires 1.2 GB of disk space with an extra swap partition. If you move the swap into a file, which I did so I can easily extend the partition later if required, disk use is 2.2 GB, i.e. still less than half what a current Ubuntu server requires.

Where Did This Come From?

I probably wouldn’t even have thought about this at all if it weren’t for another activity early in the year. Back then, I moved a remote VM from one data center provider to another to reduce costs. The new VM was cheaper but came with less RAM and Debian instead of Ubuntu. At the time, I noticed that my app ran fine of Debian as well without any modifications. So the thought that I could migrate from Ubuntu to Debian at home as well for some VMs stayed at the back of my mind until I had a use for it for this project. An interesting ’cause’ and ‘effect’ chain.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.