Site Tools


start:zramswap

This is an old revision of the document!


Ubuntu and Debian are fairly similar.

Before enabling zramswap you should ensure partitioning is logical. For example here is my daily drivers partition layout:

My disk has been cloned in the past so the sizes might seem a little strange, but you don't need to fixate on things being exact when comparing, instead see that the first boot partition is around 1GB, the second root partition is around 512GB and then I have a third partition I store files on that's about 1.2GB. The third partition should be ext4 so that I can store VM images and other files on it but again it was cloned from a legacy system and I never got around to changing it. Then the last partition is a 64GB swap partition.

The swap partition is abnormally large as I have 32GB of RAM and with zram you use 50% of your RAM size for zramswap. I have experimented with other values but any larger reduces performance. the compression is around 3 on average so you want to have enough swap to move out the 16GB when its uncompressed into a normal page file if need be or you can have weird issues. To ensure thats possible a disk swap of about double RAM works pretty well in testing. This allows me to allocate out about 44GB of RAM to virtual machines without any performance issues. Once you go over that you do notice a couple of pauses here and there as the base OS of Debian seems to like about 4GB to itself either some free, and a couple of GB for it to run nicely. Basically I just take my RAM + zram - 4GB so in my case 32+16-4=44 or there about. It is plenty when running a bunch of VM's.

Here is htop with 44GB of RAM allocated out to a bunch (6) of VM machines. As you can see my CPU on this laptop is starting to become the bottleneck now, as running the VM's tend to use a lot of the 12 threads I have. However being able to spin up many machines is very useful:

start/zramswap.1648216812.txt.gz · Last modified: 2022/03/25 14:00 by peter