1) Open a terminal window and create an empty file in the root of the file system using the dd command, as follows (this creates a 1GB file — you should ideally adjust the count= figure to at least match the size of your memory, bearing in mind that there is 2,048MB in a 2GB):
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
2) Now we need to format it as a swap file:
2) Now we need to format it as a swap file:
$ sudo mkswap /swapfile
3) The final step is to make Ubuntu mount it at boot, which is done by editing /etc/fstab:
3) The final step is to make Ubuntu mount it at boot, which is done by editing /etc/fstab:
$ gksu gedit /etc/fstab
Then make a new line at the bottom of the file and add the following:
Then make a new line at the bottom of the file and add the following:
/swapfile none swap sw 0 0
You can align the entries on the line under the column headings in fstab, like the other entries in the file, but it doesn't matter so long as there is at least one space between each entry on the line. Once done, save the file and reboot your computer.
Once the computer has rebooted, you can test to see if the swapfile is being utilized by typing:
You can align the entries on the line under the column headings in fstab, like the other entries in the file, but it doesn't matter so long as there is at least one space between each entry on the line. Once done, save the file and reboot your computer.
Once the computer has rebooted, you can test to see if the swapfile is being utilized by typing:
cat /proc/meminfo|grep Swap
Read more:

