The article is copied from ubuntu community as it is .
In case you don't want or you're not sure how to create a swap partition, you can create a swap file which will work in the same way as partition. Here are the steps (using terminal):
In case you don't want or you're not sure how to create a swap partition, you can create a swap file which will work in the same way as partition. Here are the steps (using terminal):
- Create an empty file (1K * 4M = 4 GiB).
sudo mkdir -v /var/cache/swap cd /var/cache/swap sudo dd if=/dev/zero of=swapfile bs=1K count=4M sudo chmod 600 swapfile
- Convert newly created file into a swap space file.
sudo mkswap swapfile
- Enable file for paging and swapping.
Verify by:sudo swapon swapfile
swapon -s
ortop
:
Should display line like:top -bn1 | grep -i swap
KiB Swap: 4194300 total, 4194300 free
To disable, usesudo swapoff swapfile
command. - Add it into
fstab
file to make it persistent on the next system boot.
echo "/var/cache/swap/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
- Re-test swap file on startup by:
Note: Above commands re-checks the syntax ofsudo swapoff swapfile sudo swapon -va
fstab
file, otherwise your Linux could not boot up properly.
No comments:
Post a Comment