Using a usb thumb drive or flash drive as a swap partition.
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using a usb thumb drive or flash drive as a swap partition.
Hi
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
Thanks
Steven
--
Life would have been a lot more easier if we had the source code.
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.
I think it's a bad idea. First, I've found write times to flash drives to be incredibly slow, slower than disk reads:
Code:
[root@localhost patrick]# hdparm -tT /dev/sdc
/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
/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.
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.
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.
Hi,
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.