SwapBoost v0.1alpha – early testers wanted

By | 2007/07/02

So a few months ago I was visiting Georgia and had a pleasant dinner with a few guys from the Georgia Team. Somehow the topic of Windows Vista came up and some of the “cool” features that it had, one of which being an ability to add available space from an inserted USB drive to the virtual memory (swap). Well, I quickly outlined a plan in my head on how it *could* work, but never sat down to actually try it. Today I finally made time to try it.

After twenty minutes I had a basic implementation. Not very flexible, but it worked on the USB drive I plugged it. The first implementation took only 43 lines of bash code, much of that simply being echo output, so it could have been smaller.

After some more testing and expanding it now seems a little more solid. It’s a bit over 100 lines of bash code, with plenty of room to grow but I wanted to get some feedback from the general public. If you would like to help alpha test this application you can get a copy of the script below. If you’d like to help on this project I think there is plenty of improvement and could make for a good team project as well.

In any event, here is a basic outline of what it does and how to use it at this point. It may not be completely intuitive, but that is part of what I need feedback on. Below are three steps to increase your swap size by using excess space on a pluggable USB disk.

  1. Insert USB disk and allow gnome / KDE to auto-mount the device.
  2. Run ./swapboost.sh -n to create a new swap addition
  3. Check your system memory. Your swap should now be extended by the amount of free space on the device. (swapon -s will show you all available swap areas).

When you would like to make use of the disk again for that other than swap you can run the cleanup portion of the script by doing the following.

  1. Run ./swapboost.sh -d to delete added swap and safely unmount your USB disk.
  2. Check your system memory. Your swap should now be reduced by the amount of space previously added. (swapon -s will show you only your default swap area).

I’d love to get some feedback on this script. I know there are some features that need improving. A GUI would be great. The ability to select the size to expand the swap, instead of *only* the full size. A more intuitive launcher.. etc. The list can go on and on. Again, if you’d like to join this project I think it could be fun. If you’d simply like to give some feedback check out the v0.1alpha release below.

This release goes out to my boys in Georgia. Thanks for planting the seed.

Remember, this script is in alpha stage and the user assumes all responsibility for its potential lack of function. If this messes up your machine it is not my fault. Use at your own risk. (I had to get that out of the way. It most likely won’t really screw things up, but you never know at this stage.)

SwapBoost.sh v0.1alpha

53 thoughts on “SwapBoost v0.1alpha – early testers wanted

  1. Pingback: SwapBoost: Quick Fix for Your Slow Computer | Veritas/tic

  2. jdong

    Cool — note that if you are going to swap, it will drastically reduce the lifespan of your flash media; current flash media is not meant to be rapidly overwritten to in this fashion. Of course, with flash media so cheap and people owning several sticks (and losing them way before 100,000 rewrites), I doubt many people care :D

  3. Martins Skele

    I just looked at your code. Even I could understand it.

    Is this ALL that readyboost does? There has to be more.

    It’s hard to believe that it could be this simple.


  4. Pete

    From my understanding of this technology on Vista, it is nothing at all like swap space.

    What happens is that commonly needed, yet infrequently modified files are copied to the usb drive.

    These files are then used during boot and application startups. The additional drive takes load off of the disk. Since the system is already bottlenecked by IO from the hard disk, having the additional data source makes things faster.

    Plus, since the files on the usb disk are infrequently changed, this has no ill effects on the lifespan of the usb drive.

  5. Jeremy

    Agreed with jdong, this will kill your flash drive.

    I know you have a disclaimer already, but you might want to make a note of it being bad for the drive.

  6. mike

    That is nothing like readyboost, but might still be useful. Readyboost does pre-emptive caching, copies stuff that has not been used yet but likely will, to the usb stick.

    Sure, you can mimick that with building a statistics gathering daemon and some fs redirecting to the stick…

  7. Jeff Schroeder

    Well preload certainly works for your “statistics gathering daemon”.

  8. mike

    Indeed, I was aware of that. All that is missing is some plumbing to make it so that the applications will access the certain files from the flash disk instead of the normal hdd..

  9. Athropos

    Dont’ want to offend you, but I don’t really see the point of this. It’s surely useless from the point of view of providing additional space, and I’m really not sure whether it could provide any speed boost by using the flash memory.

  10. dtlin

    Linux swap is not suitable for flash drives at all. Please do not encourage its misuse.

  11. Alex

    Well /I/ think it’s a good idea. ReadyBoost is just swap + preload. That’s /really/ all this is too. ReadyBoosts performance boost is also questionable, it’s just proof of concept of how simple MS readyboost is. nj zelut.

  12. Marius Gedminas

    I wonder what would happen if you (intentionally or accidentally) pulled out the flash drive when it was being used as swap.

    I wouldn’t be surprised to get a kernel panic.

  13. lefty.crupps

    Cool app, I had this idea as well when I read about Vista’s ReadyBoost ‘technology’. ..

    some ideas and concerns:

    1. Would it be possible to offer to backup the data, and restore it when the swap part wasn’t needed? I would hate to plug in my drive for this purpose and not realize i was losing everything.

    2. It would be ‘desasterous’ if the USB was a vfat32 partition and this left unknowing users with a stick that didn’t function on their closed OSes (unless drivers were installed, but you get the idea)

    3. Do well-setup Linux systems really need an additional 128 or whatever of Swap? Memory shortfalls are a Windows issue, and it looks like Vista hasn’t fixed it, they just allow you to dynamically add space. Adding swap space from a hard drive is easy enough (but this doesn’t solve the hard drive bottleneck issues as discussed).

    4. There are graphical tools meant for Bash which may help you; an example is Zenity (Automatix uses it)

    I like the concept though and it may be useful…

  14. thomas

    Sooooo stupid idea… Ubuntu, when Windows does something ugly, please do not waste your time trying copying it… You want to boost boot ? Fix apps. Fix HAL, CUPS, X.org, Gnome, … Read “Why userspace sucks” here : http://trends.newsforge.com/article.pl?sid=06/07/21/192241

    “on boot, FC5 was touching 79,000 files and opening 26,000 of them. On shutdown, 23,000 files were touched, of which 7,000 were opened.”

    Arrggghhhh… 79.000 files !!!

  15. jdong

    Vista ReadyBoost has nothing to do with swap or paging — it uses flash media as a cache basically. Linux does not use swap to perform any caching.

    The ONLY time I would do this, is if I had 512MB of RAM and a 1GB flash drive, my root fs was damaged, and fsck requires 800MB of total memory to rebuild my filesystem. ;-)

  16. Pingback: Featured Linux Download: Speed up your Linux box with a thumb drive

  17. Pingback: » Featured Linux Download: Speed u