To check if swap space exist or not use: "free -m" command
Use the dd command to create a swap file on the root file system. In the command, bs is the block size and count is the number of blocks. The size of the swap file is the block size option multiplied by the count option in the dd command. Adjust these values to determine the desired swap file size.
The block size you specify should be less than the available memory on the instance or you receive a “memory exhausted” error.
In this example dd command, the swap file is 4 GB (128 MB x 32):
$ sudo dd if=/dev/zero of=/swapfile bs=128M count=32
Update the read and write permissions for the swap file:
$ sudo chmod 600 /swapfile
Set up a Linux swap area:
$ sudo mkswap /swapfile
Make the swap file available for immediate use by adding the swap file to swap space:
$ sudo swapon /swapfile
Verify that the procedure was successful:
$ sudo swapon -s
Enable the swap file at boot time by editing the /etc/fstab file.
Open the file in the editor:
$ sudo vim /etc/fstab
Add the following new line at the end of the file, save the file, and then exit:
/swapfile swap swap defaults 0 0
REFERENCES:
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-memory-swap-file/
https://www.linux.com/news/all-about-linux-swap-space/$sudo nano /etc/fstab
Add priority = 5 to that file
/swapfile swap swap pri=5,defaults 0 0
sudo swapoff -a
sudo swapon -a
swapon --show
Set priority for Swap devices in Ubuntu
References
https://techpiezo.com/ubuntu/set-priority-for-swap-devices-in-ubuntu/
No comments:
Post a Comment