Swap Memory
Swap is a type of virtual memory in Linux that provides extra memory by using a portion of the storage (HDD or SSD) as RAM when the system’s physical memory (RAM) is full.
vicharak~ ❯ free -h
total used free shared buff/cache available
Mem: 1.9Gi 785Mi 538Mi 45Mi 619Mi 1.1Gi
Swap: 0B 0B 0B
Follow steps below to make a swap partition
-
Make a 4 GB swap partition.
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress; sync -
Secure the Swap File
sudo chmod 600 /swapfile -
Set Up the Swap Area
sudo mkswap /swapfile -
Enable the Swap File
sudo swapon /swapfileIn order to make It Permanent
Add the following line to
/etc/fstab:/swapfile none swap sw 0 0
-
Note

Be careful while editing
/etc/fstabfile and then reboot the board. -
Verification
You can verify by running
free -hcommand.vicharak~ ❯ free -h total used free shared buff/cache available Mem: 1.9Gi 759Mi 18Mi 45Mi 1.1Gi 1.1Gi Swap: 4.0Gi 0B 4.0Gi -
Remove Swapfile
sudo swapoff /swapfile