USB – Using USB Drive as RAM in Ubuntu

ramswapusb

In windows it is possible to use usb flash drive as a virtual ram. I wonder if it is possible to do so in ubuntu? If it is, how could one do it?

[Edit]: I mean Ready boost equivallent for ubuntu. I know that it is not a perfect replacement for ram and it is not advisable for longterm use.

Is creating swap file in a usb flash drive similar to it? Will it demonstrate performance gains over a swap file in a Hard Disk Drive?

Best Answer

The answer Sean suggests is one way of accomplishing this, another would be to just create a swapfile on the stick, that way you can also use your stick for other files. Like so:

  • find out where the stick is mounted. Look in nautilus or issue mount in the terminal

  • create an empty file of dd if=/dev/zero of=/media/YOURSTICK/swap bs=4096 count=131072. This creates a 512 MB file (512 * 1024^2 / 4096 = 131072)

  • create the swap and enable it sudo mkswap /media/YOURSTICK/swap && swapon -p 1000 /media/YOURSTICK/swap

The swap on your USB stick won't be faster than one residing on your HDD. Also it will kill the stick on the long term, writing does that to USB sticks.

To increase the usable amount of ram check out zram.

Related Question