How Do I Add Swap Space to Ubuntu?
Contents

How do you add a space to a swap in Linux?

The basic steps to take are simple:

  1. Turn off the existing swap space.
  2. Create a new swap partition of the desired size.
  3. Reread the partition table.
  4. Configure the partition as swap space.
  5. Add the new partition/etc/fstab.
  6. Turn on swap.

How do I create a swap partition after installing Ubuntu 20?

Complete the steps below to add swap space on Ubuntu 20.04:

  1. First, create a file that will be used as swap: sudo fallocate -l 2G /swapfile. …
  2. Set the file permissions to 600 to prevent regular users to write and read the file: sudo chmod 600 /swapfile.
Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest