RSS



Readyboost for Linux – a quick how to on getting more speed from a USB flash drive

Thu, Jul 24, 2008

Linux, Ubuntu, howto

Talk about it in our Forums

Readyboost for Linux – a quick how to on getting more speed from a USB flash drive

Readyboost for Vista is a feature added to the OS where you can encourage your limping Vista install to jog a bit faster by essentially using a smallish USB drive as disk cache.  There’s also some Vista Voodoo with Superfetch going on there.

While Ubuntu (the distro that I use) and other distros don’t really use Superfetch, you can still get an advantage using the disk cache functionality – particularly if you’re running on a system that doesn’t have a ton of RAM available. This tutorial is written with Ubuntu in mind but can be easily modified to use with just about any distro.  And yes, there’s some command line stuff.  No, it’s not as guified as Vista.

<br />First, stick the USB drive into an open USB slot. Make sure it’s a drive that you don’t mind overwriting.

Ubuntu should mount this automagically in /media/disk.  You’ll probably also get a nifty icon on your desktop.

To unmount this  – open up a terminal session (Applications-> Accessories-> Terminal) and type

mount

Now look to see where your USB drive is mounted.  In Ubuntuland it’s usually under /media/disk or /media/usbdisk.  On my system it’s mounted like this:

/dev/sdb1 on /media/disk type vfat (rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush)

The easy way to tell if this is the correct disk is to run the mount command before you stick it in your USB slot and then after.  The newest mount – well that’s the one you want.

To unmount this, type:

sudo umount /dev/sdb1

Of course, change the /dev/sdb1 bit to reflect what’s on your system.

Now, we’re going to create a swap file on the unmounted USB drive.  In my case I’ll type:

sudo mkswap /dev/sdb1

Again, change the /dev/sdb1 bit to what you say when you ran the ‘mount’ command earlier.

Now that I’ve filled this drive with a swap partition, it’s time to turn it on and give it high priority.

sudo swapon -p 32767 /dev/sdb1

That turns the swap partition on, with a priority (-p) of 32767.  Why 32767?  Well that’s the highest priority available.  Here’s the documentation if you’re interested.

You can double check that you did everything correctly by checking the /proc/swaps file:

cat /proc/swaps

My output is as follows:

Filename                Type        Size    Used    Priority
/dev/sda5                               partition    3229024    0    -1
/dev/sdb1                               partition    1981928    0    32767

You can see I have about 2GB of swap space allocated on /dev/sdb1

This won’t give you a huge speed boost on higher memory machines but if you’re using a laptop with only 512 megs of RAM you should see a noticable difference.

Technorati Tags: , , , , , , , ,

Popularity: 6% [?]

Share and Enjoy:
  • Digg
  • del.icio.us
  • MisterWong
  • Reddit
  • Technorati
  • BlinkList
  • Facebook
  • Fark
  • Mixx
  • Slashdot
, , , , , , , ,

This post was written by:

arsgeek - who has written 1989 posts on ArsGeek.


Contact the author

42 Comments For This Post

  1. John Says:

    Hey! This was a really kickArs tutorial! I plugged an old Gigstick into an older 256 Meg trashable laptop and saw an impressive improvement. Thank you.

  2. arsgeek Says:

    USB Flash drives. Is there nothing they can’t do?

    Glad the article helped.

    Ben

  3. Prasinos Says:

    Your article is misleading. You are confusing disk caching with swap. Readyboost is (or tries to be) an intelligent disk cache (for files that are frequently accessed). Swap has to do with memory management (making programs believe that they have more memory available).
    Linux already does good caching of disk data in memory (you can see that by running “free”). You may see some speed improvement by using a swap file on a usb stick, but it is much better to add some ram (especially if your system uses swap often).

  4. aendruk Says:

    Prasinos is right.

    On a somewhat related note, curious readers may be interested in readahead: http://www.google.com/search?q=ubuntu+readahead

  5. Steve Says:

    I strongly agree with Prasinos. Using a removable drive as an additional swap is in no-way similar to Windows Readyboost. More accurately, it is the equivalent inserting your removable drive into a Windows machine and adding it as an additional virtual memory for the system (under System Properties->Advanced tab->Performance & Virtual Mem). Furthermore, using a USB or SD-card drive as swap *can* dramatically reduce the life of the device. Swap partitions are typically written to & read on a frequent, regular basis. Most flash-based drives aren’t meant to be repeatedly written to many thousands of times on a regular basis.

    Don’t get me wrong, having a ReadyBoost equivalent for Linux is a great idea! But it is essential to understand what ReadyBoost is & is not. Readyboost is NOT an extra swap space. Readyboost is (essentially) a preloader mechanism (A.K.A. prefetch, superfetch, preload, cache, etc.). When superfetch caches disk information to RAM, Readyboost basically gives superfetch another fast place to cache more disk information.

    A preloader tries to predict what your system is going to pull from the disk, and essentially copies it into unused RAM before hand. Then, when you open up [insert huge bloated application here], it’s read from your blazing fast RAM instead of your slow hard drive. In other words:
    DISK–>RAM

    Readyboost simply builds on top of this idea by letting your system preload more stuff into an SD Card or Flash device. It’s not as fast as RAM, but it can be much faster than reading everything from the disk. In other words:
    DISK–>Removable Drive

    This improves performance because:
    1) SD and USB flash drives *can be* faster at reading data than a regular disk.
    2) Reading information from a an SD or USB flash drive frees your main disk from that task, making it more available to perform other tasks in the meantime.

    Again, this has nothing to do with swap space or virtual memory. Swap space is intended to be a temporary place to offload what’s in RAM, in case you run out. In other words:
    RAM–>Disk

    Using an SD or USB flash drive for swap space sounds good because it might read faster, but it’s not a good idea. Why not?

    1) Many types of flash memory may read the information SLOWER than your disk. (Tip: If you bought it from Wal-Mart, it’s probably not designed for performance)

    2) Flash memory is typically much slower WRITING information, effectively negating or reducing swap performance.

    3) Flash memory becomes a paper-weight after being written to so many times–much sooner than a magnetic disk would.

    If you want your Linux system to perform faster, consider installing preload. For Ubuntu users, it is available in the repositories (use Synaptic Manager to install it, or type “sudo apt-get install preload” from a terminal. No extra steps required.)

    If something becomes available to extend preload, prefetch, or some other type of Linux read-ahead mechanism onto removable media, sign me up! Until then, don’t kill your precious portable media.

  6. AlgotR Says:

    Flashmemory is seldom much faster than regular harddisks at reading large consecutive blocks. They ARE however MUCH faster at randomaccess since there are no heads to move around.
    The benefit from ReadyBoost is from using that fast random access to read many SMALL files scattered around.
    If you switch your harddisk to a SSD (Solid State Disk) you would probably not see any improvment at all with ReadyBoost.

    Since flashmemory are usually rather slow at writing I don’t think the performance benefit of putting swapspace on a flashdisk is that big.

  7. Verda Fretz Says:

    Substantially, the post is really the sweetest on this precious topic. I fit in with your conclusions and will thirstily look forward to your upcoming updates. Just saying thanks will not just be adequate, for the phenomenal lucidity in your writing. I will instantly grab your rss feed to stay privy of any updates. Authentic work and much success in your business dealings!

  8. mr. X Says:

    the swapboost script will only make a swap on a flash drive… it’s not like readyboost.

    the real and afaik only readyboost clone for linux is here:
    http://users.cis.fiu.edu/~zhaom/dmcache/index.html

    (gpl source available)

    and it’s a lot more complex thing
    (it’s a kernel module)

  9. kelvin Says:

    Excellent, it works for me! Thanks for the tutorial.

  10. Steve Says:

    As several previous posters mentioned, this article’s information–however useful or not–does not produce an equivalent to Readyboost for Linux. Here’s the best way I can think of explaining this: Windows has always had a swap file. It is essentially used when memory/RAM **runs out**. It’s not a cache–it’s more of a “spill-over” function. Readyboost is a relatively new technology. It doesn’t act as a spill-over for memory/RAM when you’ve run out. Instead, it acts as a sort-of cache that proactively stores data that would otherwise be read from a disk (and then stores it on another disk, where it can basically figure out which one would be faster to use, or uses both in tandem for increased speed).

    If you truly are interested in a Linux-based readyboost equivalent, ignore this misguiding tutorial and search the great-yonder interwebs for “linux preload”. Another similar tool, which is already included in many distributions, is called readahead. Otherwise, you’re going wind up killing your flash drive by using it as a swap.

  11. josh Says:

    Thanks! Worked liked a charm! Very well written!

  12. gramo Says:

    As Prasinos and Steve wrote, using USB to add swap is different from ReadyBoost, but Linux memory management is combined with disk cache, so adding a virtual memory enables larger disk cache, so the final effect may be similar to readyboost.

    Some comments to other mentioned arguments:
    “it is much better to add some ram (especially if your system uses swap often)”
    The same case holds for ReadyBoost — adding RAM brings more performance, but plugging in a spare USB stick is cheaper and easier.

    “Flash memory becomes a paper-weight after being written to so many times–much sooner than a magnetic disk would”
    That is right, but ReadyBoost will write to the disk frequently, too. If ReadyBoost selects well the data, which are frequently read from disk, then the reading operations will prevail over writing operations, so swapping to a flash disk is probably little bit more aggresive than ReadyBoost, but it is only a guess…

  13. gramo Says:

    There is another issue with swapping to a USB — if you unplug the USB unexpectedly (without swapoff & umount), nasty things will happen. I guess with ReadyBoost nothing wrong will happen, because the data cached on the USB are still accessible on the hard drive.

  14. Glenn Says:

    Damn.. You got murked on your own blog, by some super geeks. Good job.

  15. Linda Says:

    HI,

    I just did my first installed of Ubuntu (lucid) from Win7 and I really like the ReadyBoast feature. So, can someone confirm whether this will work for 10.04?

    Thanks,
    Linda

  16. bridal dresses birmingham Says:

    It had been a whilst because I visited internet site with this kind of top quality details. Thansk lots for the helpful information

  17. Cory Says:

    I really want to try this but when I type: sudo mkswap /dev/sdc1 (my drive) all I get is “device or resource busy”

  18. Stephen Says:

    Das Essen von Japan ist eines der Dinge, die ich am meisten vermissen nicht da. Eines Tages hoffe ich, wieder für einen anderen Urlaub.

  19. Jack Says:

    Yn olaf EVE ar-lein wedi gorffen eu diweddaru. Cymryd amser hir i’w llwytho i lawr ac yna gosod. Yna, a sefydlwyd y cymeriad i fy hoffi.

  20. Robert Says:

    Durch eine Menge von Blogs heute in meiner Suche nach mehr Informationen.

  21. Fitz Says:

    .Yesterday was a bright hot sunny day till the evening. Then there was rain for a few hours. This morning is dull and cold. :(

  22. Richard Says:

    Yesterday was a bright hot sunny day till the evening. Then there was rain for a few hours. This morning is dull and cold. :(

  23. Lenny Says:

    feeling drained this morning. Sweating so much last night, i am suffering from dehydration. A few cups of coffee will help to restore the lost fluid and wake me up. :)

  24. Fitz Says:

    .Monday morning once again and off to work i go. Wish i have the numbers for the euro lottery and win enough to retire for life. :) But with my luck, i have the wrong numbers. :(

  25. Gerrad Says:

    The weather is bright and sunny as i went to work. The forecast i saw before leaving for work show a large rain cloud heading to cover where i am. Looks like i am going home in rain later. :( .

  26. Richard Says:

    Back from holidays. Well, staying at home holidays. Wish i earned enough to go on a holiday somewhere like Japan, or New Zealand.

  27. Clyde Says:

    Ar ôl un diwrnod ar ddeg heb idiot o’r enw Sam, ei fod yn ôl yn y gwaith. Pan fydd y penaethiaid o gwmpas, ei fod yn frown ymyl flaen. Gwneud unrhyw esgus i fynd i mewn i’r ystafell ydynt mewn, fel pe dweud “edrych arna. Wyf yn gweithio”. Roedd ei agwedd at ffrindiau gwaith arall pan nad yw’r meistri yn cael eu gwmpas yn “Yr wyf yn well na chi”. Mae’n tynnu jôc ac mae’n ddoniol (yn ei feddwl). Ond os ydych yn tynnu yn jôc arno. Rydych yn yr isaf o’r holl ffurfiau bywyd ac efe yells ei ben i ffwrdd fel strancio bedair oed. Parc o fewn 6 troedfedd (2 fetr) ar ei gar smart ac rydych yn ei blocio.

  28. Connor Says:

    I wonder what it was like to live 20,000 years ago ? Working from dawn to dusk and making sure you gathered enough food to survive the winter. Times of plenty and times of hardship. How many of the people today, could survive back then ?

  29. Jeff Says:

    .Where are we now on the evolution path ? Are we becoming civilized or still going down the path of increasing destructive powers ? Our medical knowledge increases with leaps and bounds of each war, but not as greatly as our destructive weapons.

  30. Bell Says:

    Oli vain lukea mellakoita Lontoossa ja muilla alueilla BBC kotisivuilta. Niiden pitäisi käyttää kumiluoteja, kyynelkaasu ja pippurisumutetta kunnes mellakoijia ovat työkyvyttömiä. Sitten alus heidät Afganistaniin, jotta he voivat oppia, miten käyttäytyä.

  31. Bob Says:

    Riots once more tear through several cities of England. Many people will turn up for their place of work today to find it wrecked or worse, destroyed. How many more are going to lose their jobs as their place of employment was destroyed ? Bring in the army and have a no holds barred in dealing with the rioters. They want to hurt others by throwing brick and other things, so should have the same violence back at them.

  32. Josh Says:

    ?ngilt?r? bir neç? ??h?r vasit?sil? bir daha tear i?ti?a?lar?n. Bir çox q?zaya v? ya pis m?hv tapmaq üçün bu gün i? yeri üçün olur. I? yeri m?hv edilmi?dir öz i?l?rini itirm?k gedir nec? daha çox? H?rbi g?tirin v? rioters münasib?td? barred A keçirilib var. Onlar atma k?rpic v? dig?r ?eyl?r il? BA?QALARINA Z?YAN ist?yir?m, onlar geri eyni zorak?l?q olmal?d?r.

  33. Richard Says:

    Only two more days after this day of working on the government scheme. :( Then back onto the unemployment queue next week. Thirteen weeks of doing a job and only getting forty five percent of the minimum wage for it and the government wonders why the scheme is not popular ! If I was being paid minimum wage I would have enjoyed it more and had some money saved up.

  34. Janet Says:

    .Hökum?t sxemi üzr? i?l?y?n bu günd?n sonra yaln?z iki gün. :( I? gör?n v? yaln?z bunun üçün minimum ?m?k haqq?n?n q?rx be? faiz almaq v? sxemi populyar deyil dövl?t n?y? gör? güzellikler (Sonra geri i?sizlik queue g?l?n h?ft? üz?rind? on üç h?ft? m?n minimum ?m?k haqq? öd?nilir olan ?g?r m?n olard?! daha idil?r v? bir para xilas etdi.

  35. Isaac Says:

    Thanks for the informative, helpful blog.

  36. Jeffery Says:

    I dont comment frequently, but when I do it’s usually for some thing thats informative and great.

  37. Harriet Says:

    Thanks for your useful post the information I found to be extremely useful, great article.

  38. Mandy Says:

    I found your article interesting and your blog especially its discussion.

  39. Frankie Says:

    I have been a daily website visitor to your blogs, great work.

  40. Steph Says:

    Only if the heavens above can be measured and the foundations of the earth below be searched out will I reject all the descendants of Israel.

  41. Jack Says:

    Hi there! Fine post! Please keep us posted when we will see a follow up!

  42. matt Says:

    So, just out of curiosity, what shall I do come a situation in which i need to remove the flash drive?

Leave a Reply