Get updates via: rss | twitter | email | google+

Ubuntu Linux: Create swap file

Written by Guillermo Garron .
Date: 2013-01-22 18:40:13 -0500

Memory in Linux is can be increased by create swap space, it can be a special partition, or a file which will work as a swap file. We will cover now, how to create a swap file.

Create a swap file

sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k


You can change count to 1024K if you want 1 Gigabyte of swap, more than that is not really recommended.

Format the file as swap

sudo mkswap /swapfile

Enable the swap

sudo swapon /swapfile

Make it permanent

To make the swap space available after every boot, edit the /etc/fstab file and add this line.

/swapfile       none    swap    sw      0       0 

Set the permissions to the swap file

sudo chown root:root /swapfile 
sudo chmod 0600 /swapfile


If you enjoyed the article, please share it

twitter | facebook | google+ | linkedin | email | reddit