Using a swapfile to increase the swap space on your system



This can be a very handy function if we want to use a file, instead of a partition, and with modern filesystems the performance is almost on par with using a dedicated partition for your swap area.


1. Using dd lets make a zero’d file for the swap

dd if=/dev/zero of=/swapfile bs=1048576 count=1000
This example would create a swapfile of 1 gig using a blocksize of a megabyte (1048576).


2. Make file as a swapfile

mkswp /swapfile
3. Activate swapfile

swapon /swapfile
4. Verify that our swapfile has been activated

swapon -s
We should see something like this in the list ..
Filename Type Size Used Priority
/swapfile file 9999992 0 -2
If you want to have this a permanent solution, then adding the entry to fstab would probally be a better idea,
open up /etc/fstab in your favourite editor and add the following line.
/swapfile swap swap defaults 0 0


Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

Popular Posts