[HowTo] Make Swap File in Ubuntu

Saturday May 22, 2010 by  

One tips to make your Ubuntu or other linux faster is by adding a swap space or swap file. Swap space is the area on a hard disk which is part of the Virtual Memory of your machine, which is a combination of accessible physical memory (RAM) and the swap space.

Swap space temporarily holds memory pages that are inactive. Swap space is used when your system decides that it needs physical memory for active processes and there is insufficient unused physical memory available. If the system happens to need more memory resources or space, inactive pages in physical memory are then moved to the swap space therefore freeing up that physical memory for other uses.

You need swap space or swap file if you have low memory but have enough space in your harddrive. Usually you need swap space is double of your RAM. So if you have 512MB RAM, make your swap file 1GB, and so on.

Her is how to make swap file in Ubuntu:
1. Open your terminal and login as root
2. Create a large empty file:

dd if=/dev/zero of=/mnt/512Mb.swap bs=1024M count=512

3. Format the swap file:

mkswap /swapfile

4. Turn the swap file on:

swapon /swapfile

5. The additional swap is now available and can be seen by :

cat /proc/meminfo

6. Add it to fstab to make it permanent:

vim /etc/fstab

add this to the file:

/swap_file       none            swap    sw              0       0

What people search:

Other Interesting Articles: