Using USB flash as swap space.

Ray Parrish crp at cmc.net
Thu Aug 6 19:45:55 UTC 2009


Dan Farrell wrote:
> On Mon, 03 Aug 2009 12:02:59 -0700
> Ray Parrish <crp at cmc.net> wrote:
>
>   
>> Hello,
>>
>> I recently read an article that states that using a USB flash drive
>> as swap space can help speed up a low memory system since the flash
>> drive is faster than a hard drive.
>>     
>
> I think this is a terrible idea.  First of all, who says a flash drive
> is faster than a hard drive?  Maybe if it is cached, it is just as fast
> as any cached data.  Of course that won't help if you're low on memory
> anyway.   But I don't think flash drives can hold a candle to, say, a 5
> year old 50MB/s hard drive.  
>
> These drives are on USB and if you can't use a modern memory stick
> chances are you aren't going to see optimal USB speeds anyway.  Even if
> you were - and correct me, list, if I'm wrong - the max read speed on
> usb2.0 is 48MB/s, isn't it?  
>
> Just for fun I used hdparm to see just how fast I could hope my cheap
> little 4G flash drive could go with hdparm: 
>
>  sudo hdparm -t /dev/sdf 
>
> I got 17.86 MB/sec.
>
> Granted, that's a very cheap flash drive and probably not the highest
> performance money can buy.  Nevertheless, by comparison an old 40G drive
> that happens to be in the computer goes 46.37MB/sec.  
>
> Of course, that's read speed.  I would imagine that due to the nature
> of swapping out of memory, you'd expect swap to be written just as much
> as it is read.  Write speeds are considerably slower.  For example, I
> tested mounting that same usb drive and using this command to write to
> it:  
>  sudo dd if=/dev/zero of=./test.file;
>  # wait...
>  Ctrl-C
>
> dd said 28.3mb/s.  however, I ran 'sync' afterwards to make sure the
> data actually got written, and it took about 30 seconds of flash drive
> blinking before sync completed.  Not a very well done benchmark, but a
> good reference point.  By comparison, the same command into a file in
> my home directory gave me 82.8 MB/sec - and although this surely isn't
> true write speed of my hard drive, nevertheless sync returned
> instantly.  
>
> My conclusion - this is a terrible idea.  
>
> Newegg has a recertified maxtor 40G hard drive for $20 right now.  A
> terrible, crappy, prone-to-failure hard drive -perfect for disposable
> data like swap, IF you can tolerate your system locking up when your
> swap drive dies.  (That's what will happen when you computer can't swap
> something essential back into memory)
>
> Finally,  are you sure swap space is the way to speed up your
> system?  I think you should consider cutting down on memory usage - if
> possible, that is - before you think about switching your swap space
> onto something "faster".  Swap will never compare to memory speeds.  If
> you want help slimming things down, let us know.  I'm sure these fine
> ubuntu people (i mostly just pretend to be an ubuntu person, in
> reality, preferring gentoo) can help you trim the fat as it were.   In
> particular, try a lightweight window manager.  Fluxbox or similar
> should save many megs of memory.  Ditch gnome!  
>   
You're right... I've discovered since that a IGB stick for my machine is 
only $19.99 at New Egg and would do wonders to speed it up. Not that I 
really have much problem with my machine being slow under Ubuntu. 8-) 
Windows is another matter, running it with 512mb RAM with 64MB in use 
for the video card it is very slow at times.

Ubuntu on the other hand is very snappy until I get around 50 tabs open 
in Firefox and try to switch from the browser to my email, or something 
else, then I get gray outs for at most 30 seconds at times.

So, I'll just be getting more real RAM, as soon as possible.

Later, Ray Parrish


-- 
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com






More information about the ubuntu-users mailing list