Creating a Swap File

If you don’t have a partition free to allocate additional swap space, you can create a swapfile on an existing file system.

The following example creates and enables a 16 MB swapfile called /var/swapfile:

dd if=/dev/zero of=/var/swapfile bs=1024 count=16384
mkswap /var/swapfile
swapon /var/swapfile