[SSD only] Activating TRIM on Mac OS Lion / Mountain Lion 10.8

Original author: Grant Pannell
  • Transfer
Hello, dear harazhiteli.

This translation is intended primarily for those who already use an SSD drive and MacOS Lion. Personally, I have been pleased with the performance of the Intel X-25M SSD and the lack of a death carousel for a year, which I sincerely wish for you.

Until today, I was sure that my SSD is working at 100% of its capabilities. But it was not there! If you bought your apple computer without an SSD, that is, it left the store with a regular HDD, then the TRIM promised in Leo will be inactive , as it turned out, only computers originally equipped with SSDs have this function by default. The problem, as you know, in the company's marketing challengesIt has software roots, not iron ones. And for this Apple trick, Mr. Grant Pennel offers his threaded bolt.



Before proceeding directly to the translation, I suggest you check whether TRIM works for you or not:


If your SandForce 2 *** controller is on your SSD, then TRIM is not recommended for you. As they say, the obvious thing is that the SF2 *** controller processes the information deleted by the user in its own special way and generally stores data on disk in the form of one large archive ... the details of its operation and the ensuing problems are described here . The SF2 *** controller is equipped with a fairly wide range of devices, including the popular OCZ Vertex 3, so be sure to check the list of SSDs equipped with SandForce controllerand look carefully if your drive is in this list, if so, then in the Controller column, determine the serial number, if it starts at 2, then further operations to enable TRIM can only do harm. For all other SSD users, this article will be useful:

Never use the TRIM ENABLER program (1.1 or 1.2) to activate TRIM in Leo.

After a little check of this application, I found that instead of the usual patch, it replaces the most important system file at the system kernel level. This means that if you used TRIM Enabler, then it replaced the file with the mass of threads stretching from it throughout MacOS (especially important for those who moved to Leo from MacOS Snow Leopard 10.6.8). Is that bad. Very bad. Along with the fact that TRIM really turns on, there is a real danger of colliding with a car of problems, starting from kernel panic and ending with input / output (I / O) problems, and then a spinning and frightening beach ball will definitely catch you.

In the course of the discussion with the developer of this application (Oskar Groth), I heard only accusations through comments on his blog that they say I am engaged in trolling and cause fear(although in fact, and to a greater extent, I tried to offer an alternative option, which is presented below). Probably - in the next version of TRIM Enabler - the file will be correctly patched, instead of directly replacing it, nevertheless, this update has not yet happened.

So, here is the right way to enable TRIM support. To do this, execute the following commands in the terminal:

1. First, back up the file that we will patch:
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original

2. We patch the file, thereby activating TRIM support:
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\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

3. We clear a cache:
sudo kextcache -system-prelinked-kernel
sudo kextcache -system-caches

Now reboot!

If you suddenly need to disable TRIM support:


1. Shutdown:
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00).{9}(\x00\x51)|$1\x41\x50\x50\x4C\x45\x20\x53\x53\x44$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage

sudo kextcache -system-prelinked-kernel

sudo kextcache -system-caches

2. File recovery from backup:
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage


All that this patch does is replace the phrase “APPLE SSD” with zeros in the IOAHCIBlockStorage file. This is necessary in order to circumvent the limitation of Apple itself on the use of only branded SSD drives. The backup file is stored in the same directory where the original file is.

To check if TRIM has activated, go here: About This Mac > System Report >


Remember, if your bearded generation SSD and the hardware itself does not support TRIM ... this patch will not help. The patch only bypasses the restriction created by Apple itself to limit TRIM support for any SSDs that are not under the apple brand.

Having dealt with TRIM Enabler and disliking its method, I began to look for a sound solution ... I found it here .

The MD5 checksum entries for the original and patched file in 10.7.0 are as follows:
Original: 155b426c856c854e54936339fbc88d72
Modified: 945944136009c9228fffb513ab5bf734

If you have already used TRIM Enabler, you can do the following:
  • Try to copy and replace the key file from another Mac running the same version.
  • Try to copy and replace the key file from the Recovery Partition (Open Disk Utility> Mount Recovery HD)
  • Reinstall Leo
  • Wait for the next OS update to 10.7. * And hope that the key file will be replaced during the update (which, by the way, is de facto), and after that apply the normal patch.


Important:
Unfortunately, you will have to carry out this operation every time after a major update of OS X 10.7.1 > 10.7.2 > 10.7.3 > and so on ... because the key file is updated almost every time the OS is updated (if it is not on duty) .

End of translation

Further in the article, we chew on Wikipedia that TRIM does not work on standard HDDs, that a computer is not a fool and can distinguish a HDD from an SSD, that an SSD cannot warm up anymore when TRIM is activated, that a patch cannot affect the system’s operation, as it doesn’t no changes to the operation of the kernel itself, that if you enable TRIM, and you have a HDD, then nothing will happen and all commands will simply be ignored ... and so on. In general: since the author called himself a mushroom, I had to get into the box by the very hat and answer everyone. If there are such questions in the local comments, I will translate his afterwords with the prefix “Update”, in batches.

Successful to you. Thanks for attention.

TRIM:
TRIM technology increases the speed of writing to those cells where any data was previously stored. In other words, this data is stored there after they are deleted. And if it is necessary to overwrite the SSD, a command is sent to free these cells and only then recording begins. Thus, time is taken and the recording speed is reduced. TRIM technology allows the controller to record data bypassing the cell release operation. For example: the declared speed of my SSD x-25M is up to 70 Mb per second . After testing before activating TRIM, it issued no more than 50 Mb / s, now the claimed 65-70 Mb / s. Test your SSD, maybe you will also miss 30% of the speed when writing data ...

Update 1.0
There was information that TRIM in some cases causes problems on those SSDs that are equipped with a SandForce 2 *** controller, as they say the obvious thing is that the SF2 *** controller processes the information deleted by the user in its own special way and generally stores data on disk in the form of one large archive ... the details of its work and the ensuing problems are described here .

As it turned out, the SF2 *** controller is equipped with a fairly wide range of devices, including the popular OCZ Vertex 3, so be sure to look at the list of SSDs equipped with a SandForce controller and see carefully if your drive is on this list, if so, in the Controller column, define serial number, if it starts at 2, then disable TRIM, the instruction is above.

Update 2.0

This method stopped working after updating the system to version 10.8.1.
Nevertheless, TRIM Enabler works, but on the Internet there are still opinions that it can destroy the system. You can try it at your own peril and risk, the problems go away, if you disable TRIM through the same program when they occur, but you yourself understand that all this is a “fork in the water” - if it manifests itself, then individually.

When there is a method without interference in the core of the system - I will write about it; if any of you, dear makovody, find a way earlier, do not be too lazy to inform, please.

Update 3.0 // Found a way to activate TRIM for the system 10.8.2

Thanks to the user shok , the method was found on the Internet .

Run the following commands in the terminal:
1. Back up the original drivers.
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents /MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/ IOAHCIBlockStorage-backup

2. We change the driver.
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents /MacOS/IOAHCIBlockStorage

3. We execute two commands to clear the OS X cache and pick up the modified driver.
sudo kextcache -system-prelinked-kernel sudo kextcache -system-caches

4. Reboot the Mac. We verify the activation of TRIM
Source: Science and Technology

Also popular now: