Creating a bigger swap file on Linux Mint

For some reason, Linux Mint (and other variants probably?) creates a measily 2GB swap file, which is too small IMHO when you have 16GB or more of RAM installed.

THis is how you increase the swap file in four easy steps.

  1. Reboot or at least close down all appilcations to free up as much memory as possible = process will be quicker
  2. sudo swapoff -a     # Turn off swap
  3. sudo dd if=/dev/zero of=/swapfile bs=1M count=16384   # 16384 = 16GB, use 8192 for 8GB and so on
  4. sudo chmod 0600 /swapfile
  5. sudo mkswap /swapfile
  6. sudo swapon -a

You can verify everything worked with

swapon -s

Filename Type Size Used Priority
/swapfile file 16777212 512 -2

or

free -m

total used free shared buff/cache available
Mem: 15949 6021 181 233 9746 9367
Swap: 16383 0 16383

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.