-   Linux - Hardware (
-   -   Using a usb thumb drive or flash drive as a swap partition. (

stevenjoseph 06-09-2006 07:53 AM

Using a usb thumb drive or flash drive as a swap partition.
I tried out a little experiment, i created a swap on my 1G thumbdrive.
There seems to be a little improvement in performance. Is this possible, safe, and can i continue to do this.
How do i know if the usb version.
and how do i bench mark performance

Life would have been a lot more easier if we had the source code.

oneandoneis2 06-09-2006 09:42 AM

You're going to kill your thumb drive using it as swap - flash memory can only take so many writes, and swap will get through them in a very short time.

kilgoretrout 06-09-2006 09:56 AM

I think it's a bad idea. First, I've found write times to flash drives to be incredibly slow, slower than disk reads:


[root@localhost patrick]# hdparm -tT /dev/sdc

 Timing cached reads:  3524 MB in  2.00 seconds = 1761.39 MB/sec
 Timing buffered disk reads:  30 MB in  3.06 seconds =  9.80 MB/sec
[root@localhost patrick]# hdparm -tT /dev/hde

 Timing cached reads:  3460 MB in  2.00 seconds = 1729.40 MB/sec
 Timing buffered disk reads:  116 MB in  3.01 seconds =  38.52 MB/sec

There, hde is an ata100 ide hard drive and sdc is a flash drive.

Second, flash drives have a limited amount of writes before they will fail to function. You don't want to put them in a position where they will potentially be constantly written to like a swap file/partition.

Third, if you have 512MB of ram or more, you will rarely go into swap during normal operation. Even if flash were faster, you are not likely to see any significant performance improvement if you have that amount of ram.

boscharun 01-14-2012 12:51 PM

You will defenitely kill your USB drive if you use swap daily. But for occasional usage, using a pen drive as RAM or swap works perfectly fine as it does for me.
From my experience till now, it is really fast if you are adding in small processes(firefox, gimp etc) one by one. You don't feel any hang. But for very heavy ones like starting a virtualbox guest OS, there is a hang although not as much as with the hard disk swap.

H_TeXMeX_H 01-14-2012 01:02 PM

Bad idea. Try instead zram or zcache (better).

jefro 01-14-2012 01:09 PM

I have used flash drives a lot. I am not sure you can easily kill them. In a year you just find the old one is too small and you throw it away. I run linux on them all time and use them for moving files. They have proven pretty good. Sheeze. A 4G is like $4.

A linux user sort of re-created the ready boost of windows, I think it was a script they called flash boost or such. Basically it uses flash to store swap.

You should monitor swap once in a while. Modern linux has made great advanced in it's ability to handle ram. Most people don't use swap. You may find it is not as valuable as it once was. Your system and exact use would decide for sure.

elvinhaak 01-15-2012 06:56 AM

What about shrinking the amount of data on the HDD, eventually moving the files to the external flash and using the internal HDD for the extra swaps?
What would the performance do in these instances?
I guess the most speed is to gained because the same HDD is not reading the data and writing to swap at the same time, so thus putting the 'static data' on the usb-device would get the most speed out of the system.
I got one of my older systems working way faster this way with an external USB-stick. By the way USB1, internal mem. 400MB, "older" laptop (2003, maybe 2002), 30GB HDD internal, 8 GB external IDE. Mostly works fine alone but with bigger files it likes its extra swap-memory.
Nice tough: large files from wireless network (over USB1 too) open faster in these cases then from internal hdd.

jefro 01-16-2012 12:00 PM

A real hard drive is almost always faster for many reasons. The point of a usb flash drive is not to replace an internal hard drive. Consider a second drive.

Swap file/partition is not really designed to make a system faster as such, it is designed to allow to too little ram. Get more ram is the solution to that.

snowpine 01-16-2012 12:09 PM

Performance-wise, there is an exponential improvement from USB drive to internal HDD, and then again from HDD to RAM.

Therefore if you have a limited budget to improve your computer's performance, maxing the RAM is almost always the best "bang for the buck."

All times are GMT -5. The time now is 06:37 AM.