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=1000This example would create a swapfile of 1 gig using a blocksize of a megabyte (1048576).
2. Make file as a swapfile
mkswp /swapfile3. Activate swapfile
swapon /swapfile4. Verify that our swapfile has been activated
swapon -sWe should see something like this in the list ..
Filename Type Size Used PriorityIf you want to have this a permanent solution, then adding the entry to fstab would probally be a better idea,
/swapfile file 9999992 0 -2
open up /etc/fstab in your favourite editor and add the following line.
/swapfile swap swap defaults 0 0
![Digg](http://1.bp.blogspot.com/_lxBSX0YJV58/SwQiO9krTcI/AAAAAAAAAhc/80Z-NLrZ7wU/s1600/digg.png)
![Google Bookmarks](http://1.bp.blogspot.com/_lxBSX0YJV58/SwQitItySOI/AAAAAAAAAhs/RQQh6Du9HrA/s1600/google.png)
![reddit](http://1.bp.blogspot.com/_lxBSX0YJV58/SwQitlmYSuI/AAAAAAAAAh8/mTtVHQxL_mE/s1600/reddit.png)
![Mixx](http://2.bp.blogspot.com/_lxBSX0YJV58/SwQitawG7PI/AAAAAAAAAh0/vF4HOlj8JH8/s1600/mixx.png)
![StumbleUpon](http://2.bp.blogspot.com/_lxBSX0YJV58/SwQit6IUS5I/AAAAAAAAAiE/gfbBSYnbjnU/s1600/stumbleupon.png)
![Technorati](http://4.bp.blogspot.com/_lxBSX0YJV58/SwQiuP6h64I/AAAAAAAAAiM/x_aGzBKYCgc/s1600/technorati.png)
![Yahoo! Buzz](http://1.bp.blogspot.com/_lxBSX0YJV58/SwQi2FtKY5I/AAAAAAAAAiU/ByTK_Wci_Uo/s1600/yahoo.png)
![DesignFloat](http://4.bp.blogspot.com/_lxBSX0YJV58/SwQiOmnjWDI/AAAAAAAAAhU/nMIbaOaCDic/s1600/designfloat.png)
![Delicious](http://4.bp.blogspot.com/_lxBSX0YJV58/SwQiOHLlI8I/AAAAAAAAAhM/6JP39Dh6sF8/s1600/delicious.png)
![BlinkList](http://3.bp.blogspot.com/_lxBSX0YJV58/SwQiN859bNI/AAAAAAAAAhE/E_Uh6XTQmpo/s1600/blinklist.png)
![Furl](http://3.bp.blogspot.com/_lxBSX0YJV58/SwQiPG9Y6xI/AAAAAAAAAhk/YzmjQUPdnrg/s1600/furl.png)