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?
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 terminalcreate 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.
I found out about this when I did it from http://www.tuxgarage.com/2011/07/add-virtual-ram-to-ubuntu-using-spare.html
Plug-in your USB drive and make sure there are no important files on the drive. Delete all the files on the drive or re-format it and go to a Terminal.
First, we need to unmount the drive if Ubuntu auto-mounted it when you plugged it in:
Where 'drive-label' is the name you see for the USB drive when it is mounted.
Or you can also do it this way:
Where 'sdx1' is your drive/partition letter. You can find it by running this command:
Now, we'll create the Swap file on your USB drive:
Where 'sdx1' is your drive letter we figured out from the output of 'fdisk -l' command above.
Now, turn on your new Swap:
Done!
In order to make sure your new Swap is working, you can take a look at the output of this command:
My output is:
To take the stick out first turn off the Swap:
If you truly need to add RAM to your system, there is nothing short of installing more memory sticks or increasing the physical memory of the machine.
Using a USB cannot increase the RAM in such a manner as to ONLY increase the swap file, plus the read/write times are decreased by the USB 480mb transfer limitations.
If you want to experience an increase in performance use "zRam". This adds a special file to your existing system and increases the system's virtual memory. It decreases the I/O write times as it uses a compressed block technology stored on the current RAM
More information here
I already tried this ago. But usb stick so slow when writing something.
I experienced very short hang continuously when system using usb swap. It was may my stick was so cheaper one.