Linux 101 : Swap memory - Using a partition as a swap space (mkswap, swapon) -
When the RAM is full, programs can't function properly. To fix that we allocate a part of the hard drive and use it as a "slower" extension of the RAM, this is what is called the Swap space.
The less frequently accessed data is written to the disk to free up the RAM.
A Swap space could be a partition, a logical volume or a file.
The less frequently accessed data is written to the disk to free up the RAM.
A Swap space could be a partition, a logical volume or a file.
Using a disk partition as a Swap space:
We are going to create a partition on the disk /dev/sdb using the fdisk partition tool:
Changing the partition type to "Linux swap":
Writing the changes to the disk:
We then write the changes to the disk using the below command:
We create the swap partition using the below command:
Checking the Swap space:
We can check the swap memory using the below command:
Adding teh swap space to the "/etc/fstab" file:
To be able to have access to the Swap space after a reboot, we add the below line to the "/etc/fstab" file:
Comments