[Updated July 26, 2020]: Change swapfile permission; Set swapfile in /etc/fstab.
Swap is a special area on your computer, which the operating system can use as additional RAM.
Starting with Ubuntu 17.04, the swap partition was replaced by a swap file. The main advantage of the swap file is easy resizing.
Note: before running the following commands, please make sure you have a backup of your data!
In the following example, we’ll extend the swap space available in the /swapfile from 4 GB to 8 GB.
- Turn off all swap processes
sudo swapoff -a
- Resize the swap
sudo dd if=/dev/zero of=/swapfile bs=1G count=8
if = input file
of = output file
bs = block size
count = multiplier of blocks
- Change permission
sudo chmod 600 /swapfile
- Make the file usable as swap
sudo mkswap /swapfile
- Activate the swap file
sudo swapon /swapfile
- Edit /etc/fstab and add the new swapfile if it isn’t already there
/swapfile none swap sw 0 0
- Check the amount of swap available
grep SwapTotal /proc/meminfo
The post Change swap size in Ubuntu 18.04 or newer appeared first on Bogdan Cornianu.
Top comments (0)