Posted by: aneeska on: June 25, 2009
Swap space in linux is analogous to page space(Virtual memory) in windows.
Three steps to make and use it in linux.
- create a partition and mark it as swap
- create a swap file system
- add the swap partition info /etc/fstab
Use “fdisk” to create a partition to be used as swap. One thing to remember is that the size of the partition need to be equal to or more than system RAM size for better performance.
The swap partion’s system id should be set as hex code 82 so that when you list the partitions using fdisk the output sould look something like this:
$ fdisk -l /dev/sda
Device Boot Start End Blocks Id System
/dev/sda4 4989 5100 899577 82 Linux swap / Solaris
Now that the partition is ready, its time to create swap file system in it. Use the “mkswap” command
$ mkswap /dev/sda4
Add the swap partition info to /etc/fstab so that in the next boot swap is mounted and used.
Add this line:
/dev/sda4 swap defaults 0 0
After a reboot, check the contents of this file
$ cat /proc/swaps
If swap is active, output will resemble something like this:
Filename Type Size Used Priority
/dev/sda4 partition 2031608 0 -1
Read this REDHAT Documentation