Swap partition too small :(

I run swappiness at 200 (the maximum), because I've got 3 swap drives with the same priority, so any swapping will be done round-robin fashion across three drive interfaces and three drives... that's about as fast with spinning-rust drives as a single SSD (without having to worry about write-wear on the drive).

swapon --show
NAME      TYPE      SIZE USED PRIO
/dev/sda2 partition   2G   0B    1
/dev/sdb2 partition   2G   0B    1
/dev/sdc2 partition   2G   0B    1

Some relevant swap commands:

Turn off all swap:
sudo swapoff -a

Zero a swap partition:
sudo dd if=/dev/zero of=/dev/disk/by-partuuid/$swap bs=512 status=progress
You'll have to find the partition UUID of the swap partition you want to zero, and put it in where '$swap' is above. I use 'by-partuuid' because the drive letter (sda, sdb, sdc, sdd, etc.) can change, but the UUID should never change.

Make a swap partition:
sudo mkswap /dev/disk/by-partuuid/$swap -U $swapUUID
You'll have to find the partition UUID and the drive UUID and put them in above where '$swap' and $swapUUID' is. Note that this means you can make up your own $swapUUID, if you want. The script I use to zero all free drive space (to make compressed backups smaller) uses the pre-existing UUIDs of the swap partitions so I don't have to make any changes to the fstab file to get the now-zero'd swap partitions to auto-mount at boot.

Turn on all swap:
sudo swapon -a

2 Likes