linux, centos,

How to Add Swap Space on CentOS 9 Stream

Aug 17, 2022 · 1 min read · Post a comment

If some of your services are struggling and can’t work properly then might your amount of physical memory be full? If that’s the case, adding swap space will solve the throttling issues on your CentOS 9 machine. Let’s see how to add swap space on CentOS 9 Stream.


  • CentOS
  • sudo privileges


Step 1. Create a swap file of 1GB size.

sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576

Step 2. Set the correct permissions.

sudo chmod 600 /swapfile

Step 3. Set up swap area on the file.

sudo mkswap /swapfile

Step 4. Activate the swap.

sudo swapon /swapfile

Step 5. Check if swap is active.

sudo swapon --show


/swapfile file 1024M 309.1M   -1

You can also check that with:

sudo free -h

Step 6. To make the changes permanent add swap entry into the /etc/fstab file.

sudo nano /etc/fstab

Once the file is open, paste the line below.

/swapfile swap swap defaults 0 0


Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.