What is the ‘swap’ ?
‘swap’ means the technique enable use the HDD, SSD as a main memory when main memory is fulled.
1. Create swapfile with ‘dd’ command
let’s create swapfile in linux file system. ‘bs’ option means the size of block and ‘count’ option means the number of blocks.
simplely, the below command enable create the file with the size you defined in bs, count options.
1
| > sudo dd if=/dev/zero of=/swapfile bs=128M count=32
|
2. Change the authority of ‘swap’ file
‘600’ value is able to give the authority for reading and writing.
1
| > sudo chmod 600 /swapfile
|
3. Define swap file as a swap
this command defines the swap file created just before will be used as a swap.
4. Add swap file
5. Check whether swap is success or not
in vi
1
| /swapfile swap swap defaults 0 0
|
7. Check whether it works well or not
1 2 3 4 5
| > free
total used free shared buff/cache available Mem: 988696 568720 193836 400 226140 277896 Swap: 4194300 0 4194300
|