Archive for January, 2012

Enabling TRIM Support on OSX

Getting an SSD is probably the single most amazing thing that ever happened to my personal computing experience. It made my Mid-2010 MacBook Pro 13″ something from an OK experience, to a 1st class experience.

The system boots fast, Applications load faster, and I’m much more productive.

One thing that’s important in the SSD life is TRIM support. TRIM, in short, is the garbage collecting that is needed to clear deleted data on your SSD.

To go into more detail, When the operating system deletes data off of the hard drive, the SSD doesn’t actually clear the bits for that data, it just removes it from the allocation table. The TRIM command is sent from the Operating system to eventually clear those bits and make them ready to be written to again.

If TRIM wasn’t available from the operating system, eventually the SSD will be slow because the SSD would need to find free bits, and then clear them.

Wikipedia article on TRIM

Fortunately most modern Operating Systems do support TRIM, (Windows 7, and OSX 10.7). The problem with OSX is that its not enabled by default, unless it was an apple branded SSD.

I got an OCZ Vertex 2 120 GB SSD, and when I went to check for TRIM support after a re-install, TRIM was not supported (You can see this by going into About this Mac > More Info > System Report > Serial-ATA). You can enable this but it requires a reboot and some terminal work.

There is a good article from this website.

They point to a document but there was an issue with the way the quotes work, so Ill post the commands here, but just for the sake of completeness you can find the document here.

First backup the file in question:

sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /IOAHCIBlockStorage.original

Now time to use perl to modify the file:

sudo perl -pi -e ‘s|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00).{9}(\x00\x51)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg’ /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage

Clear the kext caches:

sudo kextcache -system-prelinked-kernel

sudo kextcache -system-caches

Now reboot your Mac.

Now you should see TRIM support as Yes.

There are bugs that you can get around with, and then there are some that are just weird.. I came across one that involved a weird state for a local windows profile. Usually this will prompt you to simply solve the issue by just re-creating the profile. This usually solves the issue, but there is a faster way to resolve issues that involve with the profile with a backup status:

The image above doesn’t really show a backup status but, you get the picture.
The profile in question will load the home directory c:\users\TEMP. The user’s desktop won’t be the same, outlook won’t have the same profile, and the user’s favorites will be gone. Lets not panic, the folder in question is still there. The user is just not properly mapped to the right home directory.

First thing to do is to reboot the workstation in question. If you still have the same issue, we will need to modify the registry.

NOTE: Modifying the registry is risky, and even if you follow the instructions word for word, I can’t guarantee success or a corrupted windows or loss of data. Please proceed at your own risk.

This remedy is taken from this Microsoft KB article, but ill mention it here for completeness and add my thoughts to each task.

Go to Start and run REGEDIT

Go to:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
In this key, you should see something similar to this:

The S-1-5-21 keys actually are the configuration of the profiles in windows. one thing to notice is that there are two that are strikingly similar (S-1-5-21-1079119….) but with one difference, the .bak at the end of the key at the bottom.

Lets take a look inside the key:

A healthy profile should look like this:

A cool thing to note is that the ProfileImagePath points to the home directory of the user. An unhealthy profile will display the ProfileImagePath to c:\users\temp, and the RefCount will have a value higher than 0.

To solve the problem, login to an administrator account other than the one that has the issue.

Next modify the key name that doesn’t have the .bak to .ba.

Now Rename the key that HAS the .bak and remove the .bak.

Finally modify the key name that HAS the .ba to .bak

Once that is done, you will need to modify a few more things in the key without the .bak.

We need to change the RefCount to 0

We need to clear the state in State to 0

Now its time to reboot and try to login.

This worked for me. What your more or less doing is manually changing the state of the profile from the backup state to a local state. This is something similar to when a windows server cannot remove the restart pending status.