[GTALUG] Swap and Hibernate on SSDs

D. Hugh Redelmeier hugh at mimosa.com
Sun Jan 28 12:34:30 EST 2018


| From: Giles Orr via talk <talk at gtalug.org>

| In the early days of SSDs, there was a lot of talk in the Linux community
| that you shouldn't have a swap partition on an SSD.  An indirect side
| effect of that is that it becomes impossible to suspend-to-disk (aka
| "hibernate") on a SSD-only system.

I don't even know how to ask to hybernate these days.  I last did it
in the APM days.  How do you do it?  I have one perverse system that
it would be useful for.

| - is it considered okay to have a swap partition on an SSD drive?

Yes.

| - how should I set the swappiness?

I don't know.

| - is it considered okay to hibernate to an SSD?

Yes.

Russell's message is probably a better source than what I'm going to say.

- the key to SSD longevity is to keep writes to a reasonable amount

- the hard-to-understand factor is "write amplification"

- write amplification, roughly, is that a small write on to the disk, from 
  the software's standpoint, causes a lot of writing to the actual flash 
  memory.

- The model of hard disk we and Linux have is simulated by the SSD
  because flash isn't really like a hard disk.

- write amplification gets really bad as the flash gets full.

- Trimming allows the flash firmware to know when virtual disk blocks are 
  no longer needed.  This is important.  Otherwise, the only way it knows 
  is if the virtual disk block is rewritten -- then the old value and its 
  space are vacated.  But rewriting of a block also ties up a new chunk of 
  flash for the new value of the block.  On trimming can reduce the number
  of blocks allocated.

- trimming is mostly used to advise the SSD firmware that the blocks of a 
  deleted file are no longer needed.  It is also used (I hope and assume)  
  when you mkfs or repartition.

- the other (complementary) way of reducing fullness is to actually
  leave unused space on your filesystems.  Unused Space in any
  filesystem on a device reduces write amplification for all
  filesystems -- it is a global property of the device.  You can also
  do this by not allocating the whole virtual drive to partitions.

- All flash drives have some more flash than the virtual drive presents.  
  This is called "over provisioning".  Enterprise drives have more.

- write-amplification, as a function of the amount of free flash, is quite 
  non-linear ("hockey stick curve").  So it is critical not to get to 100% 
  full (you cannot, due to over provisioning), but below some threshold 
  (95%???) and things are fine.


More information about the talk mailing list