Properly usage of Solid State Drive on Linux

Solid State Drive (SSD) is superior to even the fastest 7200rpm Hard Disk Drive (HDD), both in performance, power saving and temperature control.

I recently bought a used Thinkpad T430 with a 500GB @7200rpm HDD. Performance is not bad at all with 8GB RAM. But the palm rest on the left side of the touch pad become hot until the point I couldn’t take it anymore (not really really hot though, just around 40 degree C but still uncomfortable). I decided to upgrade it to a 128GB SSD of Kingston and was amazed by its performance: file copied instantly, OS boot just like come back from sleep, temperature was at a comfortable degree that I could work on this laptop for hours. Amazing! Yes it’s expensive, for only 128GB I have to put 20$ more into my HDD to finish the deal. But it’s totally worth every cents.

But the SSD is different to a normal HDD in writing and reading, in deleting file. The minimum unit when writing is a 4KB page. But the minimum unit when deleting is a block of 256KB. See the problem yet?

nand_flash_pages_and_blocks

To write to a page is easy and always ready as long as there is an empty page. But if the SSD want to delete a page, it has to copy all written pages in the same block –> erase the whole block, then copy those pages except for the page it need to delete. The process become heavily slow overtime. The more data is written to an SSD, the slower it get.

So to fix this problem, the OS must tell the SSD which block is empty in the file system. And this is where the TRIM command come to the rescue. TRIM command or alternative is available on Windows 7, 8, 10 (where windows 9 is at huh Bill Gates?) and latest Linux OS.

My system run Linux Mint 17 and it’s already have the script enable to weekly TRIM the SSD. But it only apply for Intel and Samsung drive. I have to add –no-model-check to bypass this model checking and all is well.

This is the content of my currently weekly cron script:

#!/bin/sh
# call fstrim-all to trim all mounted file systems which support it
set -e
# This only runs on Intel and Samsung SSDs by default, as some SSDs with faulty
# firmware may encounter data loss problems when running fstrim under high I/O
# load (e. g. https://launchpad.net/bugs/1259829). You can append the
# --no-model-check option here to disable the vendor check and run fstrim on
# all SSD drives.
exec fstrim-all --no-model-check
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s