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 No Comments on How To Add Swap Space On CentOS 8

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:  5 Ways To Count The Number Of Lines In A File In Linux

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

VirtualBox Installation VirtualBox 6.0 Released With Tons Of Improvements Linux
Linux Commands To Remove Files And Directories Linux Commands To Remove Files And Directories Linux
5 Best Screenshot Tools For Linux In 2021 5 Best Screenshot Tools For Linux In 2021 Tools
Happy Birthday, Linux: 28 Years Of Awesomeness Linux
Mount Linux Partitions From Windows(1) How To Mount Linux Partitions From Windows 11 [Updated] Linux
Best Linux Laptops Of 2021 [Specs & Price] Best Linux Laptops Of 2021 [Specs & Price] Linux

Leave a Reply Cancel reply

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

Recent Posts

  • 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
  • Linux Wget Examples September 27, 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]
  • Sr. Demand Writer (Costa Mesa)

    • Costa Mesa, CA
    • The Law Offices of Daniel Kim
    • Part Time
  • Technical Writer

    • Swiftwater, PA
    • Adecco
    • Full Time
  • Video Photojournalist

    • Washington DC
    • NTD
    • Full Time
  • Senior Technical Writer

    • Swiftwater, PA
    • Aequor
    • Full Time
  • Technical Writer II (Swiftwater)

    • Swiftwater, PA
    • HireTalent - Staffing & Recruiting Firm
    • Part Time
  • Service Writer

    • Richfield, OH
    • W.W. Williams
    • Full Time
  • Senior Data Scientist, Product, Google Play

    • Mountain View, CA (Remote)
    • Google
    • Full Time
  • Technical Writer

    • Pittsburgh, PA
    • The HIRD
    • Full Time

Copyright © 2025 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme