Skip to content
Technology News Information & Jobs

Technology News Information & Jobs

Ubuntu Tutorials, Ubuntu How To , Linux Tips, Tech Jobs

  • Work with US
  • Search Jobs
  • Post a Job
  • Contact Us
  • Ubuntu
    • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Themes
  • Linux
  • Laptops
  • Tutorials
  • Job Dashboard
  • Toggle search form
How To Add Swap Space On CentOS 8

How To Add Swap Space On CentOS 8

Posted on May 14, 2020 By admin

Tutorial to add swap space on CentOS 8

Previously we covered an article on adding swap space on Ubuntu 20.04 LTS. In this article, we are going to do the same thing but with CentOS 8 Linux.

When RAM is full, It takes inactive pages from the RAM. Swap space is used when RAM is full in your system.

How To Define Swap Space In CentOS 8

  • Swap space 3 times of the RAM if your system has less than 2 GB RAM
  • Swap space same size of the RAM if your system has systems has 2 to 8 GB RAM
  • Systems with more than 8 GB RAM then your Swap space will be at least 4 GB of Swap

How To Add Swap Space On CentOS 8

At first, we need to create a swap file that will serve as swap space in your CentOS 8. We are creating a Swap file with 2 G.

sudo fallocate -l 2G /swapfile

Now, use the dd command to create the swap file:

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

We are setting permission right to 600.

sudo chmod 600 /swapfile

Create a Linux swap area on the file:

sudo mkswap /swapfile

Run the following command to activate the swap file.

sudo swapon /swapfile

Verify that the swap is active.

sudo swapon --show

Or,

sudo free -h

Now, You can make the change permanent by adding a swap entry in the /etc/fstab file:

sudo nano /etc/fstab

and paste the following line:

/swapfile swap swap defaults 0 0

Swappiness Value In CentOS 8

Swappiness is a method that defines how often your Linux system will use the swap space.  Default swappiness value is30 in CentOS 8. You can check the current value with the following command.

cat /proc/sys/vm/swappiness

Note: It can have a value between 0 and 100. A lower value is better as it will make the kernel try to avoid swapping whenever possible and at the same when you have a higher value, the kernel will try to use Swap Space like never before.

READ More Relevant Stuff:  How To Run Linux Commands In background : Run Process In background

Meanwhile, if you want to set the swappiness value, then you need to open the /etc/sysctl.conf file and add the following line.

vm.swappiness=20

Run the following command to delete or deactivate the Swap value in CentOS 8

sudo swapoff -v /swapfile

Now, you can remove the swap file entry /swapfile swap swap defaults 0 0 from the /etc/fstab file.

Run the following command to remove the actual swapfile file with the following command:

sudo rm /swapfile
Linux, Linux Commands Tags:CentOS 8, linux commands

Post navigation

Previous Post: Configure CTRL+ALT+DEL As Task Manager In Ubuntu 20.04/18.04
Next Post: Install Numix Circle Icon Theme In Ubuntu 20.04 LTS : Ubuntu Themes

Related Posts

Nitrux 2.0. Is Available For Download Nitrux 2.0. Is Available For Download Linux
Useful Best GNOME Desktop Extensions In 2021 Useful Best GNOME Desktop Extensions Updated How To Ubuntu
Fedora Linux 34 Beta Is Now Available For Download Fedora Linux 34 Beta Is Now Available For Download Linux
How To Upgrade To Ubuntu 23.04 From Ubuntu 22.10 How To Upgrade To Ubuntu 23.04 From Ubuntu 22.10 Linux
Amazing Useful Raspberry Pi Commands Cheat Sheet Amazing Useful Raspberry Pi Commands Cheat Sheet [2023] Linux
Microsoft Defender ATP Now Available For Linux Microsoft Defender ATP Now Available For Linux Linux

Recent Posts

  • New Job Search October 10, 2025
  • How To Enable Hibernate in Ubuntu 22.04 LTS May 20, 2024
  • Popular Ubuntu Games: Top 5 Games To Play March 17, 2024
  • WordPress | Your site doesn’t include support for the “generateblocks/container” block GenerateBlocks Plugin February 11, 2024
  • Ubuntu Autoremove Command Debian Autoremove Command February 10, 2024
  • How To Mount Windows 11 Shares on Debian Linux December 7, 2023
  • Anonymous Browsing 101: A Deep Dive Into Residential Proxies November 20, 2023
  • How To Correctly Install Uninstall Linux Ubuntu Nvidia Drivers Fast October 31, 2023
  • Ethical Web Design: The Dos and Don’ts October 28, 2023
  • Understanding the Role of Security Operations Center October 25, 2023
  • The Positive Effects of AI Tools and Online Services on Students Successful Essay-Writing Skills October 3, 2023

Categories

  • Android
  • Apple
  • Blogs
  • Debian
  • Fix
  • Gadgets
  • Game
  • Google
  • How To Ubuntu
  • Internet
  • Laptops
  • Linux
  • Linux Commands
  • Linux Game
  • Linux Mint
  • News
  • Operating Systems
  • Security
  • Technology
  • Themes
  • Tools
  • Tutorials
  • Ubuntu
  • ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Windows 11
  • Wordpress
  • Search Jobs
  • Post a Job
  • Job Dashboard
  • Contact Us
  • About US
  • Cookie Policy
  • Terms and Conditions
  • Privacy Policy
  • Sitemap
  • Write For US

Tags

android apps centos ChatGPT command Commands Debian deepin Desktop docker Fedora fix game games Gaming gnome google kernel linux linux commands linux kernel Linux laptops Linux Mint Linux themes minecraft NVIDIA Python Raspberry Pi sysadmin themes ubuntu ubuntu 18.04 Ubuntu 18.04 LTS Ubuntu 20.04 ubuntu 20.04 lts Ubuntu 22.04 LTS Ubuntu games Ubuntu kernel ubuntu themes ubuntu tutorial VirtualBox Windows Windows 11 Wine WSL
itsubuntu.com is an Equal Opportunity Employer. For Advertisement, Jobs, Guest posts, and any other thoughts, email us at [email protected]
  • SQL Report Writer

    • Hammonton, NJ
    • TWO95 International
    • Full Time
  • Sr Electrical Engineer, Data Center (Hybrid)

    • San Jose, CA
    • CyberCoders
    • Full Time
  • Distinguished Data Engineer

    • Petersburg, VA (Remote)
    • Capital One
    • Full Time
  • Deviation Writer

    • Durham, NC
    • Process Alliance
    • Full Time
  • Remote Blockchain Engineering Manager (San Francisco)

    • San Francisco, CA
    • Circle
    • Full Time
  • Azure Engineer

    • Fort Worth, TX
    • Jobot
    • Full Time
  • Nights & Weekends Blogger, The Cut

    • Remote
    • Vox Media
    • Full Time
  • AI / Machine Learning Engineer

    • Stratford, CT
    • Lockheed Martin
    • Full Time

Copyright © 2026 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme