Swap: Difference between revisions
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
== Procedure == | == Procedure == | ||
Here's a procedure that you can run as root, or an administrative user with sudo privileges. | Here's a procedure that you can run as root, or an administrative user with sudo privileges. If you want more info, or want to '''modify''' your swapfile, see [https://askubuntu.com/questions/927854/how-do-i-increase-the-size-of-swapfile-without-removing-it-in-the-terminal the AskUbuntu thread here] | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# see if it's enabled? | # see if it's enabled? | ||
| Line 12: | Line 12: | ||
df -h | df -h | ||
# lets make a swap file that is 2x RAM | # lets make a swap file that is 2x RAM | ||
dd if=/dev/zero of=/swapfile bs=1G count=2 | |||
# fallocate is faster than dd because it doesn't actually write 2GB of zeroes | # fallocate is faster than dd because it doesn't actually write 2GB of zeroes | ||
# however, | # however, as of 2025 it is still best to NOT write sparse files, and therefore use dd | ||
fallocate -l 2G /swapfile | # fallocate -l 2G /swapfile | ||
# set permissions so that nobody but root can read/write | # set permissions so that nobody but root can read/write | ||
chmod 600 /swapfile | chmod 600 /swapfile | ||