FLASH disk as swap

Alan Dayley alandd at consultpros.com
Thu Dec 3 20:04:07 MST 2009


There has been lots of good answers in this thread.  I'm learning a
bunch, myself.

Yes, a flash drive can be used for the swap.

Fact one about flash drives: Small writes of few LBAs are worst case
scenario for flash.  This has to do with the structure of NAND flash
and is true for all the NAND flash you can buy, no matter the
manufacturer.  Small writes are a significant cause of
fragmentation[1] and more importantly write amplification[2].

Fact about swap: The size of the "pages" that the kernel swaps in and
out of RAM is 4096 bytes.  This can be changed if you want to
recompile your kernel but most of the time, this is the size.  (I am
assuming things have not changed over the last couple of years when I
looked into Linux kernel virtual memory.)

4096 bytes is 8 LBAs.  So the kernel will be writing out chunks of 8
LBAs at a time when using the swap.  That 8 LBA count is well under
the size of "small" and is bad for flash memory.

All that "bad news" said, flash controllers and SSD firmware are
designed to compensate for all these things.  If you buy a modern SSD
from a reputable manufacturer you will not see any problems with using
swap on flash.  SSDs, in general, will outlast the computers they are
installed in, even with the swap on the flash drive.

Disclosure: I work for a flash SSD manufacturer.  It's in my best
interest for people to use SSDs.

My opinion about swap files: Install enough RAM in your computer so
that you hardly ever need swap.  Then configure swap to be the same
size as the RAM because a slow, swapping computer is better than a
frozen one.

Alan

[1] http://gizmodo.com/5157015/intel-ssds-may-suffer-from-irreparable-fragmentation-slowdowns
[2] Write amplification is the side effect of the flash structure and
house keeping that causes the flash controller to write the flash
multiple times per each host write.  Google it to find some white
papers and such if you wish to learn more.

On Thu, Dec 3, 2009 at 3:40 AM, Marco Savo <savomarco at gmail.com> wrote:
> Hello,
> I have a *simple* question:
> it is possible use a FLASH drive as SWAP? someone told me that there
> is a limited numbers of write that is possible doing, so that will
> reduce the life of the flash. But what about SSD hard drives then? are
> not NAND flash as well? and which is the best filesistem to use then?
> (UBIFS? EXT4?...)
> Oh obviusly... but why we need a swap?
>
> I hope you like my questions, maybe one day I can also provide answers...
>
> --
> 'The Magic Is In the Movement'
>
>             ___
>           {~._.~}
>           _( Y )_
>          (:_~*~_:)
>           (_)---(_)
> (_Marco_)---(_Savo_)
> ___                    ___
> \-_-/SW Engineer\-_-/
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>


More information about the PLUG-discuss mailing list