Trim support on SSDs in Mac OS X 10.6.8 (SL) and 10.7 (Lion)

As you all know, for some reason Apple thinks that it is cool to only enable TRIM support for solid-state drives (SSD) which you buy through Apple. However, Apple’s SSD is most of the time just a plane Samsung PM800 SSD which Apple just overprices to the max. As you probably know there are much better SSD drives out there, but it would help quite a big deal if the OS also would help along and enable TRIM support for those drives as well.


For the ones who are already totally lost ūüėČ I’ll first explain what TRIM support really means and why we want it.

The TRIM command allows an OS to inform a SSD which blocks of data are no longer considered in use and can be wiped internally. While TRIM is frequently spelled in capital letters, it is not an acronym; it is merely a command name. In plain english: This makes sure that the free space on your disk is also really empty.

Because of the way that file systems typically handle delete operations, storage media (SSDs, but also traditional hard drives) generally do not know which sectors/pages are truly in use and which can be considered free space. Delete operations are typically limited to flagging data blocks as “not in use” in the file system.¬†Contrary to, for example, an overwrite operation, a delete will therefore not involve a physical write to the sectors that contain the data. Since a common SSD has no access to the file system structures, including the list of unused clusters, the storage medium remains unaware that the blocks have become available. While this often enables undelete¬†tools to recover files from traditional hard disks,¬†despite their being reported as “deleted” by the operating system, it also means that when the operating system later performs a write operation to one of the sectors, which it considers free space, it effectively becomes an overwrite operation from the point of view of the storage medium. For traditional hard disks this is no different from writing an empty sector, but because of how some SSDs function at the lowest level, an overwrite produces significant overhead compared to writing data into an empty page, potentially crippling write performance.

SSDs store data in flash memory cells that are grouped into pages, with the pages (typically 4 kB each) further grouped into blocks (typically 128 pages, or 512 kB in total). NAND flash memory cells can only be directly written to when they are empty. If they are considered to contain data, the contents first need to be erased before a write operation can be performed reliably. In SSDs, a write operation can be done on the page-level, but due to hardware limitations, erase commands always affect entire blocks. As a result, writing data to SSD media is very fast as long as empty pages can be used, but slows down considerably once previously written pages need to be overwritten. Since an erase of the cells in the page is needed before it can be written again, but only entire blocks can be erased, an overwrite will initiate a read-erase-modify-write cycle: the contents of the entire block have to be stored in cache before it is effectively erased on the flash medium, then the overwritten page is modified in the cache so the cached block is up to date, and only then is the entire block (with updated page) written to the flash medium. This phenomenon is known as write amplification.


Enabling SSD support in Mac OS X 10.6.8 / 10.7

Ok, well, if you have an Apple SSD, you’ll be done really quick. Just install the SSD, make sure you update to 10.6.8 or Lion (10.7), reboot and you’ll have TRIM support enabled. You can check this easily in your system properties.

Mac OS X 10.6.8/10.7 TRIM support

But what if you got one of those nice Intel or OCZ drives? They are rated much quicker than the Samsung PM800 drives Apple supplies. But without TRIM support it might end up as a slow drive as well. How to do this?

Life has been made simple by Oskar Groth from Sweden. He made a tool which let you backup your current settings and patch the settings of the OS to enable TRIM support on your own SSD drive.

You can download it here or visit his website.

Working on FCO-IM lessons

As a few of you already know, I am going to give a few lectures of information modeling. Since in Poland ORM and look-a-likes are highly under appreciated in general, I am going to spend the block on teaching the students FCO-IM.

My goal is not only to teach them how to use FCO-IM as a modeling language, but also see what ORM and ORM like modeling methods add to the system development cycle in contradiction to other methods.