Add Extra Swap Space To Your Linux Box with a USB drive [Linux Hacks]

You must have heard about a feature called “Readyboost” in Windows Vista and Windows 7, which lets you add a flash drive or USB thumb drive as an extra drive for disk cache. By using this feature system performance is significantly increased, as the newly added flash drive increases the virtual memory of your computer.

In a similar way, you can use a USB flash drive to add extra swap space to your Linux OS. Increasing the swap space means increasing the system performance. Christer Edwards has written a shell script, which allows you to add a USB drive as an extra swap space in Linux. You can download the shell script file from here :

The steps required to use the extra space on the USB drive as swap space are :

  1. Insert USB disk and allow KDE/Gnome to auto-mount the device.
  2. Open a Terminal and run ./ -n to create a new swap addition.
  3. After executing these steps the swap space would have been increased, by the amount of free space on the USB drive. You can check the available swap space for your Linux OS with swapon -s .

When you no longer want to use the USB drive as an extra swap space, you can do the following:

  1. In the Terminal, run ./ -d to delete added swap and safely unmount your USB disk.
  2. Your swap should now have been reduced by the amount of space previously added. swapon -s will now show only your default swap space.

Note: This script is still in alpha stage, so use it on your own risk.