Jim's Site
 Home 
 Climbing & Walking 
 Macaroni Penguins 
 Photo Gallery 
 Miscellaneous 
   Recommended Links 
 >Tips 
   Software 

Jim's Tips: Linux File System Swap

Last Updated: Wed Jun 09 14:13:41 BST 2004



Swap Tips

Platform: Linux
Requirements: 2.2.17, 2.2.18, 2.4.1

Adding File System Swap To Linux

Find a drive with some empty space on it (using df) and run the following commands as root (for an extra 128Mb of swap):


mkdir <drive>/swap
dd if=/dev/zero of=<drive>/swap/swap1 bs=1024k count=128
chmod go-rw <drive>/swap/swap1
mkswap <drive>/swap/swap1
swapon <drive>/swap/swap1

You'll probably want to enable this swap every time you boot so add the following to /etc/rc.d/rc.local


## Additional Swap
echo "Enabling Filesystem Swap"
swapon <drive>/swap/swap*

To add more space just do the same thing again (without the mkdir) using a different filename (swap2, swap3 etc).

If you have multiple drives it's probably a good idea to spread your swap across them and enable them all at the same priority (see swapon(8)) with a line like this in /etc/rc.d/rc.local


swapon -p 0 <drive1>/swap/swap* <drive2>/swap/swap* ...

You can check the status of your swap space with either of the following commands:


swapon -s
cat /proc/swaps



All information on this site is copyright © 1994-2016 Jim Randell