So this will be a very short article, but it is something I find very useful from time-to-time, especially when compiling code on a cheap cloud server with very limited resources. Here’s how to enable a temporary swap file without having to have a partition dedicated to it:
1 sudo dd if=/dev/zero of=/swap bs=1M count=2048 2 sudo mkswap /swap 3 sudo swapon /swap
And that’s it! Just change the
count=2048 to however many kilobytes
you’d like the swap file to be.