Fix Exceeding Swapping on a Small Proxmox Server

I have a small server at home with little specs but great ideas. Now that I am using more containers and assigned more RAM to them than I got, Swapping got to a level of 42.2%. And that’s not good. So I fixed it.

Paperless-ngx did not fully work, so I checked for memory issues on the Proxmox host.

OOM Memory Issues

bash
1
dmesg | grep -i oom

My output

plaintext
1
2
3
4
5
[292157.680595] systemd-network invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
[292157.680623]  oom_kill_process+0x110/0x240
[292157.680803] [  pid  ]   uid  tgid total_vm      rss rss_anon rss_file rss_shmem pgtables_bytes swapents oom_score_adj name
[292157.680911] oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=ns,mems_allowed=0,oom_memcg=/lxc/107,task_memcg=/lxc/107/ns/system.slice/paperless-task-queue.service,task=convert,pid=1562888,uid=100000
[292157.680925] Memory cgroup out of memory: Killed process 1562888 (convert) total-vm:2070820kB, anon-rss:863744kB, file-rss:0kB, shmem-rss:939264kB, UID:100000 pgtables:3640kB oom_score_adj:0

Memory ran out, so Proxmox killed a process I wanted to run.

Check RAM Situation:

bash
1
free -h

My output

plaintext
1
2
3
               total        used        free      shared  buff/cache   available
Mem:           7.6Gi       5.0Gi       1.9Gi       123Mi       1.1Gi       2.6Gi
Swap:          7.6Gi       3.2Gi       4.4Gi

This shows that I am really limited in RAM. ProxMenux is a Proxmox Dashboard that checks for System Health. It showed an critical info: Swap >20% of RAM (42.4%). For short periods of time it is ok if swap is at 20 - 30%. RAM pressure already happened and Linux pushed memory pages to disk.


Now let’s check what filesystem we’re on: ZFS is common but has high memory usage and slow performance at >80%, in comparison to ext4.

Check if using ZFS

bash
1
zpool status

My output

plaintext
1
no pools available

or

bash
1
df -Th /

My output

plaintext
1
2
Filesystem           Type  Size  Used Avail Use% Mounted on
/dev/mapper/pve-root ext4   68G   54G   11G  83% /

I am using ext4.


ZRAM Swap: reduces real swap usage by ~50–70%

Check Swaps:

bash
1
cat /proc/swaps
plaintext
1
2
3
root@proxmox:~# cat /proc/swaps 
Filename                                Type            Size            Used            Priority
/dev/dm-0                               partition       8011772         0               100

Install zram:

bash
1
apt update && apt install zram-tools

Configure:

bash
1
vi /etc/default/zramswap

Add this

plaintext
1
2
3
ALGO=zstd
PERCENTAGE=80
PRIORITY=100

Enable

bash
1
2
systemctl enable --now zramswap
systemctl status zramswap
plaintext
1
2
3
zramswap.service - Linux zramswap setup
     Loaded: loaded (/lib/systemd/system/zramswap.service; enabled; preset: enabled)
     Active: active (exited) since Mon 2026-02-09 12:40:33 CET; 1h 37min ago

List swaps:

bash
1
cat /proc/swaps
plaintext
1
2
3
4
root@proxmox:~# cat /proc/swaps 
Filename                                Type            Size            Used            Priority
/dev/dm-0                               partition       8011772         0               -2
/dev/zram0                              partition       4006404         0               100       

Zram compression in use:

bash
1
zramctl

Shows:

plaintext
1
2
NAME       ALGORITHM DISKSIZE  DATA  COMPR  TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd          3.8G  2.7G 932.3M 959.4M       4 [SWAP]

Change the swappiness to force Linux to prefer RAM (less aggressive swapping):

bash
1
2
sysctl vm.swappiness=10 # temporarily
echo "vm.swappiness=10" >> /etc/sysctl.conf # permanent

Check:

bash
1
sysctl -p

We are ready to check if the tweaks worked.

Flushes swap usage and clears old RAM pages (without reboot)

bash
1
2
3
swapoff -a
swapon -p 100 /dev/zram0
swapon -a

Now check again:

bash
1
2
3
htop
# or
watch -n 2 free -h
plaintext
1
2
3
               total        used        free      shared  buff/cache   available
Mem:           7.6Gi       7.5Gi       147Mi       210Mi       510Mi       165Mi
Swap:          7.6Gi       621Mi       7.0Gi

Paperless-ngx config:

Configure in /opt/paperless/paperless.conf

Add

conf
1
2
PAPERLESS_TASK_WORKERS=1
PAPERLESS_THREADS_PER_WORKER=1

Paperless-ngx now works without problems.