I'm using LUKS/dmcrypt to encrypt my SSD boot drive.

How does wear-leveling and effective garbage collection/TRIM work on encrypted SSD partitions?

  • The same way it works on non-encrypted drives. Encryption means nothing at that level, the drive just cares about bits, and their locations on the drive. – Ƭᴇcʜιᴇ007 Jul 8 '14 at 20:18
  • Doesn't a drive being encrypted mean that the drive itself doesn't know which sectors are occupied or unoccupied? If so, wouldn't that greatly hamper TRIM's ability to work, wear-leveling, garbage collection, etc.? For all intensive means, it appears as a full drive as everything is encrypted. – Naftuli Kay Jul 8 '14 at 21:07
  • What makes you think encryption encrypts empty space, or that the drive thinks it's full when it's not? Wear-leveling (specifically for example) is a drive-level function, and the drive doesn't (can't) know what the data on it actually means. It's not smart enough. :) – Ƭᴇcʜιᴇ007 Jul 8 '14 at 21:29
  • 1
    That's exactly what I'm saying. Encrypted drives generally start out by writing random bits to the entire duration of the encrypted partition. There are no zero bits, except as randomly displaced by the random number generator. Meaning that wear-leveling probably won't work at all on encrypted partitions. – Naftuli Kay Jul 8 '14 at 21:32
  • You're asserting that "full drive encryption" actually encrypts empty space, making it look full. This is not my experience, so I'm wondering where you can point to that will confirm your assertion. Wear-leveling does work on full drives. It moves the data around so that the same blocks aren't being written to over and over, even if the drive is "full", it still does this. Related Does full Volume encryption put an SSD into a fully used state? – Ƭᴇcʜιᴇ007 Jul 8 '14 at 21:36

I think it just count how many times a memory block has been written and keep a ranking, less used blocks are prioritary for the upcoming writes. But remember that a logical FS block is not attached always to the same physical block, it can be moved around the disk, so when there is a wear leveling and you rewrite a file, the physical blocks might not be the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.