To Add 1GB Swap Space
#create swap file
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
1048576+0 records in
1048576+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 19.8022 s, 54.2 MB/s
#set permission
sudo chmod 600 /swapfile
#set up swap area file
sudo mkswap /swapfile
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=53c7c8d2-ed2d-4f61-b263-79a4dcd94304
#activate swap
sudo swapon /swapfile
sudo swapon --show
NAME TYPE SIZE USED PRIO
/dev/dm-1 partition 2.1G 4M -2
/swapfile file 1024M 0B -3
sudo free -h
total used free shared buff/cache available
Mem: 1.7Gi 898Mi 69Mi 12Mi 970Mi 852Mi
Swap: 3.1Gi 4.0Mi 3.1Gi
#make permenant entry
sudo vim /etc/fstab
/swapfile swap swap defaults 0 0