![]() |
Virtual memory in Linux OS is RAM + swap space. It is used when memory usage of the system exceeds a certain point then swap space is used all the idle processes are shifted to swap and new processes are assigned to RAM. Now how to allocate swap space ideally swap space should be twice RAM size for example if RAM is 64KB then swap should be 128KB. This was the case when RAM sizes were small. For the latest computers, we know the minimum RAM is 2GB so swap space is less than twice of RAM due to a performance issue According to fedora or Cent OS swap space documentation
We will see an example of how to manage swap space. I am using vagrant and virtual box and using centos7 image instead of a proper Linux OS. (But you should use Linux machine instead of VM as they don’t come with a proper partition table) Step 1: Open a terminal in your machine and start by typing the command below
Step 2: We are going to create a new partition of 150 MB swap to demonstrate. Log in as the root user to your system in terminal using sudo su
Step 3: Start by first creating a new space using fdisk command
Choose the size of the partition first sector: press enter (chooses default value) last sector:+150M (Choose the size of space in the case 150 MB) Step 4: Choose the type of partition we want to create press t Specify partition number you want as swap Press enter (to select default) press 82 (82 which is linux swap partition type you can also type L to check all the code) press w (type w to write new partition to disk) Step 5: After that, you will exit fdisk interactive user mode will be back in the terminal type partprobe (to re-read the partition table and avoid a reboot)
Step 6: It is necessary to edit /etc/fstab file so that change stays even after reboot and remain permanent
Add a line to the bottom of the file /dev/sdaX swap swap defaults 0 0 And exit and save your changes (Where X is your partition number) Reboot your device and open terminal
Congrats you have created a new swap partition on your device |
Reffered: https://www.geeksforgeeks.org
How To |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |