Swap on flash drive?

I am working on a system that will run off of a flash drive and I was
wondering if using swap on a flash based storage is a good idea? I am
worried that all the read/write that takes place in swap will damage the
device and on a system with only a gig of ram I notice it running KDE4.

“We must plan for freedom, and not only for security, if for no other
reason than only freedom can make security more secure.” Karl Popper

It depends on the type of flash. If it’s a dedicated, solid-state drive that uses flash, it might work just fine. If it’s anything else, it does depend on the flash specs, access times, etc., etc.

If it’s a cheap “pen” drive, no way. (But surely you know that.) :slight_smile:

Edited: in case you are talking about a USB “pen” drive, most of them have terrible write access times, and limited write operations before failure, anyway. I added this edit because it occurred to me: you might running OpenSUSE off of a “pen” drive?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Out of curiosity do you think you’ll need swap? When you say a ‘flash
drive’ I assume you mean a USB stick or something that is solid state and
probably small and made for a quick startup now and then for a semi-secure
or specialty-purpose system vs. something that you’ll have running large
photo-editing, document-creating, virtual machine processes. If you are
building a slim system and only going to be using it in a system created
in the last few years having ‘swap’ at all may not really be necessary and
going without it may be a good idea.

Good luck.

Adam Jimerson wrote:
> I am working on a system that will run off of a flash drive and I was
> wondering if using swap on a flash based storage is a good idea? I am
> worried that all the read/write that takes place in swap will damage the
> device and on a system with only a gig of ram I notice it running KDE4.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLMa6AAAoJEF+XTK08PnB5S7EP/joIEC18vD5wLd1r+DFyojUl
hRk26iueox6OBLwP4l9LFQ5qEoNmPYvgzXReCVIQVK9Ki1vymH8iA+HcsblrO6DM
hWuCr/KRQWJ7sgUdGHON+VW/3ywb0qYupZb+MWlpJ5nA4rsyGsdTgKAd80E+gn8d
k99HFq8ZBmw6jkDTAnrzntTtolkP0rAWqYp/ZZhDwwnTT4SGLspV2Iz20173ep9w
fkz11SdbuJ68urRFPIz0HAXa89ADD0FRBqQToOQpHtc507WaNyDnsInVoLKbiDFU
7PPsWc5EzOdhdD6gv2Lfkh27dBa1l17rvtDORLr335SSBX0urERqcWLh8HndfhxE
Lh1JplVTLlvdWmLy90ueZKfiVPSBbUdCttxR9M3zkOzyJY1Zu/4NhCmbJN9/hFeh
XC1MoOI82nJqL8Gc87ZYf94eqlMHYMwH21nyInHuWxvAYG1kbjzKZUjb/Rvu5iqE
HjjHzH5BjVvcmlasML4L0yrR12Agy09q9ZvZKICgRxeETTIkdk/kZDrJcfAQsvIc
sHPbrLNymXu8jHpwJ0DWKbz+puk77ZCSaw01BmsGXx6H4iuJd1SIPFWTHTrYftBJ
Q7LPZx7IXXaRT/xRKcMGV2696zXFWWoI3BMYklX1ikStnP1vrS6CobnyjO0p8OP0
F9oa+NzhG7+jQodrIs7D
=KoI3
-----END PGP SIGNATURE-----

That’s a good point. I’ve got 4 Gig on this machine, and I’ve seriously debated just killing the swap entirely. I still enable it during installation out of sheer habit, but the system rarely (if ever) uses it. Even with a VirtualBox guest running Windows XP full tilt boogie, “top” shows that we never dip into virtual memory. We’re always on hardware RAM.

My PC has 1 GB RAM. It is filled up, and swap begins to be used, when I open several photos in Gimp: each takes around 0.15 GB of RAM.

ab@novell.com wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Out of curiosity do you think you’ll need swap? When you say a
‘flash
> drive’ I assume you mean a USB stick or something that is solid
state and
> probably small and made for a quick startup now and then for a semi-
secure
> or specialty-purpose system vs. something that you’ll have running
large
> photo-editing, document-creating, virtual machine processes. If you
are
> building a slim system and only going to be using it in a system
created
> in the last few years having ‘swap’ at all may not really be
necessary and
> going without it may be a good idea.
>
> Good luck.
>
>
>

Well out of 1GB of RAM once the system is up and running free reports
that it only has 6MB of RAM free so the system is very sluggish. Of
course running a swap is only a temporary solution until I can by more
RAM for this machine. Yes I am talking about a USB pen drive, I
should have been a little clearer about this in my first post.
>
>
> Adam Jimerson wrote:
>> I am working on a system that will run off of a flash drive and I
was
>> wondering if using swap on a flash based storage is a good idea? I
am
>> worried that all the read/write that takes place in swap will
damage the
>> device and on a system with only a gig of ram I notice it running
KDE4.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQIcBAEBAgAGBQJLMa6AAAoJEF+XTK08PnB5S7EP/joIEC18vD5wLd1r+DFyojUl
> hRk26iueox6OBLwP4l9LFQ5qEoNmPYvgzXReCVIQVK9Ki1vymH8iA+HcsblrO6DM
> hWuCr/KRQWJ7sgUdGHON+VW/3ywb0qYupZb+MWlpJ5nA4rsyGsdTgKAd80E+gn8d
> k99HFq8ZBmw6jkDTAnrzntTtolkP0rAWqYp/ZZhDwwnTT4SGLspV2Iz20173ep9w
> fkz11SdbuJ68urRFPIz0HAXa89ADD0FRBqQToOQpHtc507WaNyDnsInVoLKbiDFU
> 7PPsWc5EzOdhdD6gv2Lfkh27dBa1l17rvtDORLr335SSBX0urERqcWLh8HndfhxE
> Lh1JplVTLlvdWmLy90ueZKfiVPSBbUdCttxR9M3zkOzyJY1Zu/4NhCmbJN9/hFeh
> XC1MoOI82nJqL8Gc87ZYf94eqlMHYMwH21nyInHuWxvAYG1kbjzKZUjb/Rvu5iqE
> HjjHzH5BjVvcmlasML4L0yrR12Agy09q9ZvZKICgRxeETTIkdk/kZDrJcfAQsvIc
> sHPbrLNymXu8jHpwJ0DWKbz+puk77ZCSaw01BmsGXx6H4iuJd1SIPFWTHTrYftBJ
> Q7LPZx7IXXaRT/xRKcMGV2696zXFWWoI3BMYklX1ikStnP1vrS6CobnyjO0p8OP0
> F9oa+NzhG7+jQodrIs7D
> =KoI3
> -----END PGP SIGNATURE-----


“We must plan for freedom, and not only for security, if for no other
reason than only freedom can make security more secure.” Karl Popper

Then I don’t recommend using it for swap. Even if it appears to work for a while, you’ll end up crashing and burning (spectacularly). As I said above, slow write access times and relatively high failure rates (compared to mechanical hard drives) will combine to bite you in the long run.

Even in the short term, don’t be surprised if you get random, unexplained hangs. Those things are so slow on write, it’s possible you could get a race condition, followed by a deadlock. This would be true whether you were running Linux, MacOS, *BSD or Windows.

If you want to continue booting from the pen drive, try to scrounge up the money to add another gig of RAM to your computer. That won’t cost THAT much, and it’ll only be a benefit in the long run, anyway.

And I can remember years ago when I was so proud to upgrade my old 486 PC to 8 MEG of RAM! lol! (cost $300 for the RAM, too!!!)

Ah, how times have changed! To be honest, with any of the latest distros or Windows versions, I recommend a minimum of 2 Gig of RAM (regardless of what the box might say).

Flash drives are no good for constantly changing data. They are great for relatively constant data. This is because of wear leveling and the fact that the cells wear out after about 10K writes.So for databases (in most cases stable data) and multimedia files and programs the data does not change much or at all. Cache by nature changes often and constantly. This will cause a lot of wear leveling which slows things down and eventual reduction in space due to lost memory cells.

smpoole7 wrote:

>
> vendion;2092901 Wrote:
>> Yes I am talking about a USB pen drive, I should have been a little
>> clearer about this in my first post.
>
> Then I don’t recommend using it for swap. Even if it appears to work
> for a while, you’ll end up crashing and burning (spectacularly). As
I
> said above, slow access times and relatively high failure rates
> (compared to mechanical hard drives) will combine to bite you in the
> long run.
>
> Even in the short term, don’t be surprised if you get random,
> unexplained hangs. Those things are so slow on write, it’s possible
you
> could get a race condition, followed by a deadlock. This would be
true
> whether you were running Linux, MacOS, *BSD or Windows.
>
> If you want to continue booting from the pen drive, try to scrounge
up
> the money to add another gig of RAM to your computer. That won’t
cost
> THAT much, and it’ll only be a benefit in the long run, anyway.
>
>

Yes I plan on getting another gig or 2 on this system, but this was
just a question for the mean time.

“We must plan for freedom, and not only for security, if for no other
reason than only freedom can make security more secure.” Karl Popper

Sorry for digging up this old thread but Windows has been using flash drives to supplement Ram since Vista, many of them are now even labelled as such.

On my system I have only 768MB of memory, it’s pretty old, 333Mhz SDR, difficult to find and quite expensive.

Even hard drives are old and worn out, and the system often fails to properly boot, reaching only the login screen. Log file gives all kinds of “freeing invalid memtype” and “unreadable sectors” and leaves plenty of “incomplete multi-sector transfer” and “input-output” error messages after copying/moving large files that use swap.

Such operations themselves leave several processes in “disk sleep” mode and become extremely slow as soon as the system runs out of ram.

So I thought I could move swap to a 2GB flash drive, I did so on this computer about a year ago when I was using Ubuntu and I remember it was easy to do and I had no problems that I can remember.

Searching for the same solution on Opensuse so far turned only this thread and it doesn’t sound very encouraging.

Suppose it could work, how to go about it here? I did it on Ubuntu 9.04, it mounts flash drives slightly differently, I remember, I think need a proper working line for fstab, to start from, then edit the location of swap, then check if it’s working. I should also probably reformat the flash to ext4 or something.

Any suggestions?

Stan Ice wrote:
> Any suggestions?

the recommended RAM for supported openSUSE versions is
1GB…supplementing real RAM with a disk is a very slow way to make
progress…

if newer, stronger, faster hardware is out of the question i wouldn’t
recommend you move to openSUSE 11.2 (or next week 11.3)…instead i’d
suggest you find a less resource hungry and demanding Linux, i
mentioned several in this posting: http://tinyurl.com/ylf8zq9

others might have a different opinion…


Enjoy Packman’s benefits? Show your appreciation by donating at
http://se.unixheads.org/?donate

DenverD
CAVEAT: http://is.gd/bpoMD [posted via NNTP w/openSUSE 10.3]

Stan Ice wrote:

>
> Sorry for digging up this old thread but Windows has been using flash
> drives to supplement Ram since Vista, many of them are now even
> labelled as such.
>
> On my system I have only 768MB of memory, it’s pretty old, 333Mhz SDR,
> difficult to find and quite expensive.
>
> Even hard drives are old and worn out, and the system often fails to
> properly boot, reaching only the login screen. Log file gives all
> kinds of “freeing invalid memtype” and “unreadable sectors” and leaves
> plenty of “incomplete multi-sector transfer” and “input-output” error
> messages after copying/moving large files that use swap.
>
> Such operations themselves leave several processes in “disk sleep”
> mode and become extremely slow as soon as the system runs out of ram.
>
> So I thought I could move swap to a 2GB flash drive, I did so on this
> computer about a year ago when I was using Ubuntu and I remember it
> was easy to do and I had no problems that I can remember.
>
> Searching for the same solution on Opensuse so far turned only this
> thread and it doesn’t sound very encouraging.
>
> Suppose it could work, how to go about it here? I did it on Ubuntu
> 9.04, it mounts flash drives slightly differently, I remember, I think
> need a proper working line for fstab, to start from, then edit the
> location of swap, then check if it’s working. I should also probably
> reformat the flash to ext4 or something.
>
> Any suggestions?

Invest CHF60 (or equivalent in $favourite_currency) in a second hand
leasing-return box.


Per Jessen, Zürich (24.7°C)
http://en.opensuse.org/User:Pjessen

On 2010-07-11 18:36 GMT Stan Ice wrote:

>
> Sorry for digging up this old thread but Windows has been using flash
> drives to supplement Ram since Vista, many of them are now even
> labelled as such.
>
> On my system I have only 768MB of memory, it’s pretty old, 333Mhz SDR,
> difficult to find and quite expensive.

A real hard disk is cheaper, and your’s seems to be failing already. You
might be left one day with no disk and all data lost.

And watch out, if you try to use a flash disk, check its write speed
(continuous, not peek). They tend to be slow on write.


Saludos
Carlos

(estoy en: ‘c e robinson’ en ‘teleline’ punto ‘es’)

It seems the general consensus is “don’t do it”.

Hmm. As I said, I’ve done it on this same machine already, don’t remember where I got the instructions but it was very similar process to the one described here:

Use your USB-Flash as SWAP for UBUNTU! or Linux

Flash drives are much slower for continuous reading/writing but they are a lot faster for quick random access, something like 1ms comparing to 12ms up for hard disks, and that’s why they are used to complement Ram on Windows.

Win Readyboost, however, sorts out big, continuous requests and doesn’t send them to flash drives, I’m not aware of such funcionality on Linux.

In my particular case system slows down on copying large files, especially from fat32 flash to external ntfs disk and vice versa. In that case writing to swap on flash drive would probably be slower but nothing can be as slow as going into “disk sleep” that takes several minutes to clear and transfer rate grinds down to zero. If I can avoid that with swap on flash that would be a big plus already.

Who cares if flash drive wears out after a couple of years - they cost nothing comparing to either Ram or hard disks, not to mention that moving the working system to a new hard disk is a major pain in the neck and is a subject for another thread. So far Linux flags damaged sectors, there’s constant number of 31 on a 120GB drive. I think it’s far from dying, only three-four years old.

Interesting argument about the hardware, I’ve actually replaced Ubuntu 9.10 with OpenSuse precisely because it’s the only system that works. Upgrade from 9.04 to 9.10 killed driver support for my card on Ubuntu but on OpenSuse, with native ati drivers, I can still run KDE with most Kwin effects without any problems and it looks better than any Windows, including Win7 that I have in dual boot which can’t do Aero. With KDE I get fully funcitoning plasma desktop.

I’m sure I can find less resource hungry window manager and applications but that’s not the point, I want to get best possible experience, it’s a kind of showcase of what Linux can do comparing to Windows.

768MB doesn’t sound like enough memory if you have 1, 2, or 4 GB, but recommended value is 512 and, during my normal use, the system hardly ever even touches swap. I have 2GB on a laptop with the same OpenSuse 11.2 and there’s no noticeable difference in performance under normal conditions.

Back to the thread - what I really want to avoid is “disk sleep” state when system uses swap on hard disk. I thought trying swap on USB could solve the problem, that’s all.

Stan Ice wrote:
> 768MB doesn’t sound like enough memory if you have 1, 2, or 4 GB, but
> recommended value is 512

no, 512 is minimum, recommended is 1 GB

System Requirements

  • Pentium* III 500 MHz or higher processor (Pentium 4 2.4
    GHz or higher or any AMD64 for Intel* EM64T processor
    recommended)
  • 512 MB physical RAM (1 GB recommended)
  • 3 GB available disk space (more recommended)
  • 800 x 600 display resolution (1024 x 768 or higher recom-
    mended)

cite: SUSE Documentation

> Back to the thread - what I really want to avoid is “disk sleep” state
> when system uses swap on hard disk. I thought trying swap on USB could
> solve the problem, that’s all.

i have no idea how to actually do what you want, but presume it would
begin by creating /swap partition on the 2GB flash drive…i guess
that might be possible with the built-in parted, available via
YaST > System > Partitioner

before you begin, please look at three things:

  1. openSUSE specific, see http://tinyurl.com/328vjmd

  2. Linux in general, see http://tinyurl.com/39p8c36

  3. my standard caveat, below


Enjoy Packman’s benefits? Show your appreciation by donating at
http://se.unixheads.org/?donate

DenverD
CAVEAT: http://is.gd/bpoMD [posted via NNTP w/openSUSE 10.3]

Stan Ice wrote:

> Who cares if flash drive wears out after a couple of years - they cost
> nothing comparing to either Ram or hard disks,

Are we talking about SSD drives? Around here, RAM and GMR harddisks are
both cheaper.

> not to mention that moving the working system to a new hard disk is a
> major pain in the neck and is a subject for another thread.

tar it all up, copy over, untar. Works very well indeed.


Per Jessen, Zürich (24.2°C)
http://en.opensuse.org/User:Pjessen

On 2010-07-12 07:36, Stan Ice wrote:

> In my particular case system slows down on copying large files,
> especially from fat32 flash to external ntfs disk and vice versa.

The ntfs driver uses a lot of cpu, it is very slow on old machines.

> In
> that case writing to swap on flash drive would probably be slower but
> nothing can be as slow as going into “disk sleep” that takes several
> minutes to clear and transfer rate grinds down to zero. If I can avoid
> that with swap on flash that would be a big plus already.

If your hard disk takes a minute to respond, then you really, REALLY, need to replace that HD, ASAP.
You are playing with fire.

> Who cares if flash drive wears out after a couple of years - they cost
> nothing comparing to either Ram or hard disks, not to mention that
> moving the working system to a new hard disk is a major pain in the neck
> and is a subject for another thread. So far Linux flags damaged sectors,
> there’s constant number of 31 on a 120GB drive. I think it’s far from
> dying, only three-four years old.

Test it. Use SMART. Now.

> Back to the thread - what I really want to avoid is “disk sleep” state
> when system uses swap on hard disk. I thought trying swap on USB could
> solve the problem, that’s all.

I don’t know what is that “disk sleep” state. What I think is hapenning, though, is that the disc is
encountering bad sectors, and this can take dozens of retries, each several seconds long. Till the
kernel is convinced that the sector is bad and goes on - if it can go on.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Elessar))

I don’t know what “disk sleep” exactly is and on which disk exactly, I know it happens when working with two ntfs partitions at once and yes, CPU goes to 100% on such processes anyway, even without disk sleep.

At first I thought improving Ram+swap performance would help the problem and so resurrected this thread.

Yesterday, however, I decided to tackle the problem at the root and got rid of a lot of ntfs junk, including now useless Win7 beta install, and freed some 80GB of ext4 space to hold all immediate work and hopefully avoid ntfs to ntfs copying altogether.

The copying speed has gone up from 1.5MBps on a good day to 25MBps between ext4 partitions or ntfs-ext4.

That gave me the kind of improvement that would have been impossible with tweaking Ram, flash drive or even buying some 4GB of genuine memory.

dumping Win7 and Win file systems is almost always a good move…

unless of course you need a game system as well as a work system…


Enjoy Packman’s benefits? Show your appreciation by donating at
http://se.unixheads.org/?donate

DenverD
CAVEAT: http://is.gd/bpoMD [posted via NNTP w/openSUSE 10.3]