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:
Activate swap to this file (would not survive a reboot):
To check it did it:
Disable swap to this file:
Of course, the file is not deleted on reboot, and you might reuse it several times.