This content originally appeared on DEV Community and was authored by Bo
Create a swap file to let OS use when the physical memory is not big enough. Make the swap file as 1~2x big as your physical memory.
CreateSwap.sh:
#!/usr/bin/env bash
fallocate -l 12G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
Then use swapon --show
to check current swaps.
If your system already configured other swaps, you can use swapoff
to remove it, for example:
swapoff /dev/sdb
Also remember to remove it in the /etc/fstab
file such that it won't get used when system rebooted next time.
Reference
This content originally appeared on DEV Community and was authored by Bo
Bo | Sciencx (2022-03-25T17:46:03+00:00) Create swap file in Ubuntu. Retrieved from https://www.scien.cx/2022/03/25/create-swap-file-in-ubuntu/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.