1. Home
  2. Docs
  3. Hardware and Network
  4. Harddisks and Partition
  5. Adding swap after installation.

Adding swap after installation.

by Bryanpwo

To add after installation there are two options, using Gparted on the Live ISO or creating a swap file.

Just a note, it’s not recommended making a swap partition on a SSD, this can damage the medium.

Making a swap partition with Gparted

Boot your machine with the Live ISO and open Gparted. Select the last partition on your HDD (this can either be the Root partition or the Home partition, depending on how you partitioned your disk) and shrink the partition by leaving a disk space free equal to the size of your RAM or double the size, that’s up to you. Then select the free space and mark it as a swap partition, let Gparted do its work and boot back into your installed system and swap should be recognized by systemd. To check enter:

swapon --show

Making a swap file

The above method is the easiest one, but it can damage your partition you’ve shrunk. So you can also make a swap file. just run the following command:

sudo fallocate -l xxG /swapfile

Replace the xx with the amount of GB you want to install. then:

sudo chmod 600 /swapfile

To give the swap file root-only permissions.

sudo mkswap /swapfile

To make the file as swap space and finally to enable the file:

sudo swapon /swapfile

Edit the fstab configuration to add an entry for the swap file:


/swapfile none swap defaults 0 0

to check:

swapon --show
Follow us
Was this article helpful to you? Yes 7 No

How can we help?