How to Add Swap Space on Ubuntu 20.04

How to Add Swap Space on Ubuntu 20.04

In this post we will give you information about How to Add Swap Space on Ubuntu 20.04. Hear we will give you detail about How to Add Swap Space on Ubuntu 20.04 And how to use it also give you demo for it if it is necessary.

A swap is a space on a disk that is used when the amount of physical RAM memory is full. When a Linux system runs out of RAM, inactive pages are moved from the RAM to the swap space.

In the case of Linux, the swap file is an important part. It’s not a must-have option but having one is crucial for a number of purposes. Generally, when installing the system, you have to declare the size of the swap file. The recommended size is 4GB but you can either decrease or increase it depending on your demand.

See also  add new elements to DOM in jQuery

If you want to change the size of your swap file just follow the following steps.

Note:  Running all these commands requires root privilege, so I recommend running a root terminal.

1. Turn off all running swap processes

swapoff -a

2. Resize swap

fallocate -l 2G /swapfile

Here, the total size of the swap file will be 2GB.

3. CHMOD swap

chmod 600 /swapfile

4. Make file usable as swap

mkswap /swapfile

5. Activate the swap file

swapon /swapfile

To verify your swap size run the following command and you will see the swap size.

free -m

Removing a Swap File

To deactivate and remove the swap file, follow these steps:

See also  How to solve contains is not a function in JavaScript

1. Start by deactivating the swap space by typing:

sudo swapoff -v /swapfile

2. Next, remove the swap file entry  /swapfile swap swap defaults 0 0 from the  /etc/fstab file.

3. Finally, remove the actual swapfile file using the  rm command:

sudo rm /swapfile

Thank you for reading this blog.

Also see:  Vue.js Sweetalert Modal Notification Example

If you have any queries or doubts about this topic please feel free to  contact us. We will try to reach you.

Hope this code and post will helped you for implement How to Add Swap Space on Ubuntu 20.04. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

See also  Node.js Tutorial: A Beginner’s Guide - onlinecode

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US