1

I increased my swap file size using instructions in this link and now it has stopped being used. I actually tried it a few times and it has happened every time. When I ran swapon -s after each attempt, the swap file's priority always showed -2 so I increased it to 100 but that didn't help either.

swapon -s and free -m output screenshot

How can I fix this? I have 16GB ram and increased the swap file size to 32GB.

mook765
  • 15,925

1 Answers1

0

Swap size recommended settings from Ubuntu Official documentation
https://help.ubuntu.com/community/SwapFaq

RAM   No hibernation    With Hibernation  Maximum
16GB  4GB               20GB              32GB

You need 4Gb or 20Gb of swap space. Not more.

The priority makes sense when there is more than one swap area. Not used in your (1 swap area) case

You can tune the swapping behavior with swappiness
The same Documentation FAQ tells about swappiness,
see: https://help.ubuntu.com/community/SwapFaq#What_is_swappiness_and_how_do_I_change_it.3F


Rebuild your swap setup:
## Delete old swapfile
sudo swapoff -a
sudo sudo rm /swapfile

## Create new swapfile (choose one according to hibernation use)
# sudo fallocate -l 20g /swapfile  ## If hibernation have to be used
sudo fallocate -l 4g /swapfile     ## If no hibernation use is planed
sudo chmod 600 /swapfile
sudo mkswap /swapfile

## Enable new swapfile
sudo swapon /swapfile

## /etc/fstab check
# since /swapfile was used, a line should be present in /etc/fstab file
# search for and check '/swapfile swap swap defaults 0 0'

## Show swap settings and usage
swapon -s
free -h
cmak.fr
  • 8,696