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: , , , , , , , ,

Click the icon, share the link:
  • Digg
  • del.icio.us
  • MisterWong
  • Furl
  • Reddit
  • Technorati
  • BlinkList
  • feedmelinks
  • PopCurrent
  • Blogosphere News
  • Facebook
  • Fark
  • Mixx
  • Slashdot
, , , , , , , ,

This post was written by:

arsgeek - who has written 1980 posts on ArsGeek.


Contact the author

8 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)

Leave a Reply