HOWTO Enable temporary swap file on GNU/Linux

GNU/Linux supports swapping to a file on any filesystem, with reasonable performance impact since kernel 2.4. This might be useful whenever needing a temporary increase in available memory, I’m writing this article with that goal in mind.

Create a zero-filled regular file (following example would create a 1024x1M=1G swap size):

dd if=/dev/zero of=/.swapfile bs=1024 count=1M

Setup a swap area in it:

mkswap /.swapfile

Activate swap to this file (would not survive a reboot):

swapon /.swapfile

To check it did it:

swapon -s

Disable swap to this file:

swapoff /.swapfile

Of course, the file is not deleted on reboot, and you might reuse it several times.


Related Posts

The free software activist game – draft

If you are a free software activist like me and want people you...

More free software and open source good news from Europe

On the line of my latest post about Linagora, a European data researcher...

1 Comments

Comments are closed.

Quick Contact Form