# dd if=/dev/zero of=/swapfile bs=1G count=2
# fallocate is faster than dd because it doesn't actually write 2GB of zeroes
# however, if you get an error (e.g. CentOS) when you get to 'swapon', then you'll need to physically create a file using dd
fallocate -l 2G /swapfile
# set permissions so that nobody but root can read/write
</source>
[[Category:System Administration]] [[Category:Cloud]]