Optimizing MacOS X Lion for SSD

April 1st, 2012 by Martin Leave a reply »

Approx. 18 months back I bought my first SSD (120GB OCZ Vertex 2) for my (then) new iMac. I am using it as the primary disk, while I kept the original 1TB HDD as the secondary one. So far I’ve been very happy with it and thanks to applying some tweaks the drive seems still healthy as new. Recently I bought another SSD – this time a 240GB Vertext 3 for my MacBook – that one I am using as the only drive in the laptop. And as I found out, with the new features in Lion, some additional tweaks need to be applied – especially in case of a laptop. So, I’ve decided to write this blog – for my own benefit (to keep track of what I did in case I have to re-apply it in the future) as well as for the benefit of others who may run into this blog entry. Here I am providing the list of things I found on various web sites or came up with myself to minimize the risk the SSD wears out too soon. Some of them you may already be aware of. So, here is a list of content in case you want to skip to particular sections:

DISCLAIMER: Applying any of these tweakss is at your own risk. Make sure you back up your computer before trying any of these.

Don’t run benchmarks on your new SSD
Use Trim Enabler
Turn off local Time Machine snapshots [laptops only]
Turn off hibernation [laptops only]
Set noatime flag
Move user home directories to HDD [SSD+HDD only]
Use RAM disk or HDD for temporary files
Turn off sudden motion sensor [SSD+HDD only]
Turn off hard drive sleep [SSD+HDD only]
References/Other tweaks

I’ll try keeping this list up to date. Let me know if any other tweaks work well for you.

Don’t run benchmarks on your new SSD

Some people, right after they buy a new SSD, want to enjoy the speed and are eager to find out how much faster exactly their new SSD is than the old HDD. So they get this cool idea of running some extensive benchmarks to see the amazing performance numbers. Benchmarks usually write a lot of data to the disk (to test the write speed), wearing it out. So it is the best way how you can ruin your SSD even before you start using it. Don’t do it.

Use Trim Enabler

TRIM support is essential for keeping the SSD healthy. Unfortunately, MacOS supports TRIM only for Apple-supplied SSD’s. If you bought a 3rd party one like I did, you have to tweak the system to be able to turn on the TRIM support. Trim Enabler is a simple utility that does this for you. You can read more here or go to the TrimEnabler web site directly.

Turn off local Time Machine snapshots [laptops only]

If you are using the SSD in a laptop, and you turned the Time Machine backups on, you should know that OS X Lion does local snapshots at times when your Time Machine disk is not available. This is quite common – you are typically connecting your external TM disk only once in a while or you are using Time Capsule at home but take your laptop to the office every day for 8+ hours. You can confirm if the local TM backups are on by opening Time Machine Preferences:
Time Machine Preferences pane showing local backups are enabled

There is no GUI switch to turn these local backups off, but it can easily be done on the command line. Just start Terminal.app and execute the following command:

sudo tmutil disablelocal

Once you do this, the TM Preferences panel will immediately reflect it – the text will change from “Time Machine keeps local snapshots as space permits, and:” to “Time Machine keeps:”. To turn it back on, you can simply run the following in the Terminal:

sudo tmutil enablelocal

Also note, this feature gets turned on automatically whenever you turn off and on the Time Machine – so don’t forget to turn the local backups back off again whenever you do that.

I found out about how to turn off the local backups from this article: http://osxdaily.com/2011/09/28/disable-time-machine-local-backups-in-mac-os-x-lion/

Turn off hibernation [laptops only]

Another feature of Mac OS turned on by default on laptops is, that it saves all the memory to disk when entering sleep mode. This is to ensure your laptop does not lose your work if it runs out of battery while “sleeping”. The more RAM you have, the more gigabytes it writes to the disk every time you close the lid/put it to sleep. I typically do this at least twice a day – when leaving the office and when going to sleep in the evening. If you are in a similar situation and you have 8GB of RAM, that means your MacBook writes 16 to 24 GB of hibernation data to your SSD every day. Here is how you can turn this off – it will not only make your SSD’s life longer, but also significantly speed up the time it takes for your laptop to enter the sleep mode:

sudo pmset -a hibernatemode 0

I found it in this article: http://news.metaparadigma.de/osx86-enable-and-disable-hibernation-57/. Reading the man pages for pmset sheds some more light on the factory defaults and meaning of the hibernatemode values:

We do not recommend modifying hibernation settings. Any changes you make are not supported. If you choose to do so anyway, we recommend using one of these three settings. For your sake and mine, please don’t use anything other 0, 3, or 25.

hibernatemode = 0 (binary 0000) by default on supported desktops. The system will not back memory up to persistent storage. The system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep.

hibernatemode = 3 (binary 0011) by default on supported portables. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from disk image.

hibernatemode = 25 (binary 0001 1001) is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want “hibernation” – slower sleeps, slower wakes, and better battery life, you should use this setting.

Once you turn off hibernation, you can also remove the sleep image file that will free up several GB of disk space (depending on how much RAM you have):

sudo rm /var/vm/sleepimage

Set noatime flag

MacOS (like other unix-based systems) by default records last access time for every file. I.e. every time you read a file, a write is made on the filesystem to record this action. There is no point in doing it and no side effects if you disable that by mounting the root filesystem with noatime flag set. To do that create a file named for example “com.nullvision.noatime.plist” (you can pick any other name you wish) in the directory /Library/LaunchDaemons with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

    
        Label
        com.nullvision.noatime
        ProgramArguments
        
            mount
            -vuwo
            noatime
            /
        
        RunAtLoad
        <true/>
    

And execute the following command in Terminal:

sudo chown root:wheel /Library/LaunchDaemons/com.nullvision.noatime.plist

Restart the machine.

You can verify that it worked by executing the following in Terminal:

mount | grep " / "

You should get the following output (i.e. see noatime in the list in parentheses):

/dev/disk0s2 on / (hfs, local, journaled, noatime)

This tweak was taken from blogs.nullvision.com, which seems to not be available anymore, but I found a mirror of the old content here: http://www.icyte.com/saved/blogs.nullvision.com/441781
And the same trick (inspired by the same blog) is here: http://blog.philippklaus.de/2011/04/ssd-optimizations-on-mac-os-x/

Move user home directories to HDD [SSD+HDD only]

This tweak is only useful if you have both SSD as well as HDD in your Mac. I’m using this in my iMac. I moved all the content of /Users folder to the HDD and created a symbolic link from the SSD to it (so that I don’t have to change the home folder location in the user settings, as I read some applications don’t like it and may not work correctly). To do that execute the following commands in Terminal:

sudo ditto /Users /Volumes/your_hdd_name/Users
sudo mv /Users /Users.bak
sudo ln -s /Volumes/your_hdd_name/Users /Users

UPDATE (5/22/2012): To be safe, you should also go to System Preferences, click on Users & Groups, click the lock icon to unlock advanced editing (password prompt will appear). Once unlocked, you should be able to right-click on each user account and choose Advanced Options from the pop-up menu. Once in the Advanced Options dialog, change the Home directory of the user from “/Users/user-name” to the new location (e.g. “/Volumes/HDD/Users/user-name”).

Now, check if your home folders are showing up correctly in Finder. If so, restart your computer.

Finally, delete the back-up of your Users folder on the SSD by typing the following into the Terminal:

sudo rm -rf /Users.bak

Use RAM disk or HDD for temporary files

If you have enough RAM, you can dedicate (typically around 256 to 512 MB) of RAM to a RAM disk. RAM disk is a virtual disk that only resides in memory, so is suitable for storing data that need to live only until you shut down your computer. Temporary files are ideal for this. You can create a RAM disk during the boot time and redirect all the temporary files there. To do that, create a file named “MoveTempFoldersToRamDisk.sh” in your home directory and put the following content in:
Now, run the following in the Terminal:

chmod 755 ~/MoveTempFoldersToRamDisk.sh
~/MoveTempFoldersToRamDisk.sh

This creates two RAM disks on startup – one 256MB large for /private/tmp (command “RAMDisk /private/tmp 256” in the middle of the above script) and another one 64MB large for /var/run. You can now delete ~/MoveTempFoldersToRamDisk.sh from your computer.
For the changes to take effect, you have to restart.

If you decide to undo this tweak in the future, you can do it simply by deleting /System/Library/StartupItems/RamFS directory from your Mac. E.g. by executing the following command in the Terminal:

sudo rm -rf /System/Library/StartupItems/RamFS

Again, restart is needed for this to take effect.

There are some small drawbacks to applying this tweak:

  • After applying it it takes a few seconds (2-3 on my machine) to shut down
  • It lowers the size of RAM usable for applications

If you are bothered by the above and have HDD in your Mac as well, you can consider moving the temporary files to HDD instead of the RAM disk. The steps are similar to moving the user home directories. E.g. to move /private/tmp, execute the following in the Terminal:

sudo ditto /private/tmp /Volumes/your_hdd_name/private/tmp
sudo rm -rf /private/tmp
sudo ln -s /Volumes/your_hdd_name/private/tmp /private/tmp

 
RAM disk portion of this tweak taken from here: http://blog.philippklaus.de/2011/04/ssd-optimizations-on-mac-os-x/
Originally suggested by blogs.nullvision.com (mirror at http://www.icyte.com/saved/blogs.nullvision.com/441781)

Turn off sudden motion sensor [no HDD only]

If SSD is the only drive in your Mac, there is no point in using the Sudden Motion Sensor. You can switch it off by executing the following in the Terminal:

sudo pmset -a sms 0

Taken from http://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/

Turn off hard drive sleep [no HDD only]

Some websites mention SSD may freeze when the hard drive sleep feature is on, so it is recommended to turn it off. However, you probably don’t want to do this if you also have a HDD in your Mac. To switch the hard drive sleep off, go to System Preferences->Energy Saver and uncheck “Put the hard disk(s) to sleep when possible”.
Energy Saver preferences pane screeshot

 
Taken from http://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/

References/Other tweaks

The tweaks that I presented are the tweaks that I thought are worth applying. None of them really limits any features. There are other tweaks, which I did not want to apply as I would be giving up on some functionality (such as disabling the Spotlight) or I was not comfortable with (e.g. disabling the swap files). You can find these and more on the following web sites:
http://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/
http://blog.philippklaus.de/2011/04/ssd-optimizations-on-mac-os-x/
http://www.ocztechnologyforum.com/forum/showthread.php?62354

157 comments

  1. Tommy says:

    I noticed that you have the OCZ SSDs which use Sandforce controller. Sandforce controller has native TRIM garbage collection which is more reliable and superior to Lion’s TRIM support. Enabling TRIM will actually reduce performance.

    Here’s a link to OWC website with explanation. OWC also uses Sandforce controller in their SSDs.

    http://blog.macsales.com/11051-to-trim-or-not-to-trim-owc-has-the-answer

    • Martin says:

      Thanks for the pointer. Will update the blog.

      • Martin says:

        Actually, on the second thought, this kind of smells. The article says you don’t need TRIM, as the disk itself is capable of doing some kind of garbage collection. But for the disk to be able to do that, it needs to natively understand all the possible file systems, otherwise the disk has no clue which blocks are used and which are not (i.e. are deleted). Consider FAT – for simplicity. Deleting a file there means removing a pointer to a given block on the disk from the FAT table. The disk has no clue what FAT table is and that you don’t reference given blocks anymore. So how can it garbage-collect??

        Other thing to consider is, I see articles on the web advertising that these manufacturers are adding TRIM support for Windows 7. If TRIM is evil and the native sandforce garbagecollection is the way to go, why are they advertising it on Windows (rather than telling users to not use it)?

        My personal impression: Apple is not adding TRIM support for other manufacturers, so they are disadvantaged. Some users reported earlier versions of Trim Enabler to be unreliable. So the manufacturers need to create impression things are fine even without TRIM (as they can’t provide a supportable TRIM solution).

        Btw, when it comes to Trim Enabler reliability, I’m using version 2.1 and haven’t had any issues so far. I am keeping it for now.

        • Greg says:

          The goals of TRIM and garbage collecting are the same, basically you need to have erased blocks on your SSD that are ready to write, when you need them.
          I think for most people the way TRIM works is pretty obvious. Whenever you delete a file from your drive, the TRIM feature tells the SDD to erase the blocks the file was using, so they are ready to be quickly written to again. Only the OS can do this because the SDD controller has no practical way to know when a file is deleted.

          Garbage collecting is done by the SDD controller alone. The SDD controller maintains a pool of erased blocks, which cuts into the usable size of your SDD. When you delete a file, nothing happens with regard garbage collecting. However, when you attempt to write new data to a used block, the SDD controller knows that particular block is not being used. Otherwise, the OS would not want to write to it. So, the SDD controller grabs a block that is ready to write from the pool of erased blocks, maps it to be used in place of the block you were writing to, which make the write happen fast. Finally, the used block is erased at a convenient time and put into the pool of erased blocks.

          With regard to performance, TRIM will will win whenever you write to more blocks than are available in the pool of erased blocks in a short period of time. Copying a big HD video might fit the bill.

          Garbage collection could be more reliable. Because, it’s a relatively simple addition to the wear leveling system of mapping blocks the SDD controller. Plus, the OS and SDD controller have to play nice with each other for TRIM to work. For example, Microsoft could have good support for your SDD, while Apple only supports their own drives.

        • Binaryspiral says:

          I had a Lenovo SSD with FDE built by Toshiba. It did its own garbage collection as well… I think it was due to the full disk encryption processor.

          I’m not quite sure – but there is a reason they don’t support trim on some models.

          Regardless, it was only a SATA 3G drive and while being *huge* 256GB, it wasn’t as fast as most modern disks – even with the Bitlocker enabled on it.

  2. Pat says:

    Thanks for the tips. Is there a way to move the hibernation file to a second hard disk? I have the original HDD connected (soon to be installed in place of the optical drive) and would like to use it for the hibernation file.

  3. stef says:

    I like the ramdisk idea and tried to implement it. I wasn’t sure it was working so i ran the script by executing it in terminal.
    MoveTempFoldersToRamDisk.sh

    got this output to console:

    5/2/12 8:01:00.245 AM login: USER_PROCESS: 338 ttys001
    5/2/12 8:01:00.301 AM sudo: username : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/bin/mkdir RamFS
    5/2/12 8:01:00.331 AM sudo: username : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/usr/sbin/chown -R root:wheel RamFS
    5/2/12 8:01:00.354 AM sudo: username : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/bin/chmod -R u+rwX,g+rX,o+rX RamFS
    5/2/12 8:01:00.384 AM sudo: username : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/usr/bin/tee RamFS/RamFS
    5/2/12 8:01:00.407 AM sudo: stefankaros : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/bin/chmod u+x,g+x,o+x RamFS/RamFS
    5/2/12 8:01:00.424 AM sudo: username : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/usr/bin/tee RamFS/StartupParameters.plist
    5/2/12 8:01:00.436 AM login: DEAD_PROCESS: 338 ttys001

    Dead process? why did it fail?

    Also, this didn’t work
    Set the noatime option on the root filesystem

    I still don’t see the noatime flag when I
    mount | grep ” / ”
    ?

    • Martin says:

      Weird. Can you check if you see StartupParameters.plist file under /System/Library/StartupItems/RamFS? And check if the content is the same as the pink part at the end of the MoveTempFoltersToRamDisk.sh script.

      Regarding the noatime, check owner of /Library/LaunchDaemons/com.nullvision.noatime.plist file (make sure it is root and group is wheel). The change will take effect after restart.

      • Isidoros Sklivanos says:

        Martin how can i verify if the ramdisk tweak is working..?thanks

        • Martin says:

          If you type “mount” in the terminal, you should see something like:

          /dev/disk0s2 on / (hfs, local, journaled, noatime)
          devfs on /dev (devfs, local, nobrowse)
          /dev/disk1s2 on /Volumes/HDD (hfs, local, journaled)
          map -hosts on /net (autofs, nosuid, automounted, nobrowse)
          map auto_home on /home (autofs, automounted, nobrowse)
          /dev/disk3 on /private/tmp (hfs, local, union, nobrowse)
          /dev/disk4 on /private/var/run (hfs, local, union, nobrowse)
          /dev/disk2s3 on /Volumes/Time Machine Backups (hfs, local, nodev, nosuid, journaled)

          I.e. you should see disks mounted at the folders that should use the RAM disks.

    • David says:

      Hi,I installed the Trim patch and my drive now reropts to support Trim, so that’s nice. However I would like to know if there are any subsequent steps that I need to do in order to benefit from Trim support, or whether that is done automatically.Tom.

  4. Isidoros Sklivanos says:

    Martin i do the process exactly as is written the RamFS is created in startupitems but when i mount in terminal i don’t get these:

    “/dev/disk3 on /private/tmp (hfs, local, union, nobrowse)
    /dev/disk4 on /private/var/run (hfs, local, union, nobrowse)”

  5. Isidoros Sklivanos says:

    ok done! thanks you martin nice tips

  6. Peter Kalas says:

    Martin can i undo “move home folder to hdd” tweak to put back home folder to boot SSD?

    • Martin says:

      Should be possible to simply reverse the steps:

      sudo ditto /Volumes/your_hdd_name/Users /Users.bak
      sudo rm /Users
      sudo mv /Users.bak /Users

      Once you check everything is fine, delete the Users folder from the HDD:

      sudo rm -rf /Volumes/your_hdd_name/Users

      And restart. Haven’t tried it though.

  7. Stathis Tzouvaras says:

    I do the process exactly as is written the RamFS is created in startupitems but when i mount in terminal i only get this

    “/dev/disk3 on /private/tmp (hfs, local, union, no browse)”

    I am on Lion 10.7.4

  8. HackedMyPC says:

    I just wanted to ask how moving the Users folder to another partition and linking it to the system drive via symbolic links works with iTunes?

    I heard iTunes has issues when dealing with symbolic links. Is that still the case?

    Nevertheless, certainly an excellent article!

    • Martin says:

      I’ve been using that for 2 years (with Snow Leopard and with Lion) and never had any issues with iTunes. There are other ways of moving user dir (other than symbolic linking) – by changing the location in your user profile – but that I heard does not work with some applications. With symbolic links I never ran into any issue.

  9. HackedMyPC says:

    Thank you for responding Martin!

    Unfortunately the symbolic linking method does not seem to work OOB. Let me elaborate on what I have encountered so far:

    Say, my username (or account name) is “mike”. which is also an Administrator user and the only user of the system (the first account create during the installation of Lion)

    I login as mike after installation, enable trimming following your guide without issues. Next I set noatime flag, again without issues.

    I reboot the system after each change. Later I use the ditto utility to move my Users folder to a HFS+ (Journaled) partition on my HDD as per your guide. After ensuring that the symbolic link actually does link to the HDD, I reboot the system again. After being presented with a login screen I login as usual. But with a few major issues:

    All my preferences appear to be gone, such as my scrolling preferences with the trackpad or hiding/showing hard drive icons on my desktop. Moreover, even though I attempt to change these settings, they do not seem to come in effect. That is, if I want to enable the “3 finger move” preference, It simply ticks the box and nothing changes although the setting has been changed.
    Furthermore, A question mark appears for iPhoto on the dock, which was not there before moving the Users folder.

    Nevertheless, I went further on and did the same thing for the “/private/tmp” folder as you suggested. After doing that, I was presented with a login screen, but was not able to login to my homepage. I was merely faced with a plain grey screen with no icons on it.

    A second issue I faced was when downloading a torrent to my SSD. Nearly as soon as the torrent begins downloading I got presented with the crash screen instructing me to to power off and on. This was after installing the OS again from scratch prior to moving any folders.

    Have you created a temporary admin user to use the “ditto” command for this purpose? (I believe that should not matter as we are moving the entire Users folder including the home folder of the newly created user)

    Have you done any of these operations in single user mode? (I tried that but used “rm” on the root level by mistake and now have to try again)

    Under the advance settings of the User & Groups system properties for the user you are using, is their home folder stated as /Users/mike or /Volumes/xxx/Users/mike ? (I thought maybe you might have forgot to include that portion in this guide) (in other words, changing the user profile location as you mentioned in your reply)

    I apologize for the messy post, and will be very pleased to get some help as I have been stuck doing this for the past 2 days :)

    Thank you …

    • Martin says:

      Oh, shoot! Sorry to hear about your issues. I did not create any temporary user, however when I go to Users & Groups in System Preferences, and go to advanced options for my account, I do see it points to /Volumes/HDD/Users/martin. I tried several paths when I was doing this and I guess I did not realize I changed this setting as well. Will add it to the blog. What gets printed out when you do “ls -la /Users” and “ls -la /Volumes/HDD/Users”? Can you post it?

      • Martin says:

        It is weird. I just tried creating another user with the home location of /User/username (i.e. the symbolic link, not the actual location) and it does not seem to cause any issues – I am able to log as that user just fine and change settings, etc. So not sure if that is really the core of your problems. Anyway, it does not hurt to update that home location setting as well, so I added it to the blog. Please let me know if it helps to resolve your issues. And let me know how the output of those two ls commands in my previous response looks like – I’d like to see if there may be some problem with permissions set on the Users folder or any of it’s subfolders.

        • HackedMyPC says:

          Thank you for your response.

          I have reformatted the drive so am not able to check at the moment. But from what I remember (pretty clearly), on the terminal, the /Users symbolic link was assigned to the “0” group and “0” user while for the folder itself, one of them was “80”. I tried changing that with chown but did not change anything. Regarding the folders in /Users, well, all the permissions appeared to be exactly the same as the original backed up version.

          I also tried adding a new user while the link was still active pointing to my HDD, It successfully created the user in the HDD. But when I logged in I had the question mark for iPhoto and the settings issues I mentioned before were still present.

          Meanwhile, my SSD drive is a Patriot Pyro 120GB (PP120GS25SSDR). Thus it is not a “MAC” model but a standard one. But I suppose most SSD’s enable trimming automatically only under MS Windows anyways. I also updated my SSD drive to it’s latest firmware under windows (v5.0.2) prior to all this.

          I’m gonna try with another clean download of Lion 10.7.4 again soon, and keep everyone posted.

    • GabrielNar89 says:

      About long paths…:
      This is a Windows* OS/file system issue.The cause is directory paths on the drive is longer than 255 characters (including spaces).There’s a lot of additional softwares which can fix this problem like Long Path Tool.
      http://PathTooDeep.com
      Long Path Tool can simplify and probably end your problems in unlocking, managing and renaming files that appear to have a long filename. Since in some instances, you may have experienced problems accessing, managing and even renaming files that have more than 255 characters, this utility has been made to answer this particular scenario. If you have also encountered problems like error messages that tell you that the path too long, too long path, destination path too long or cannot delete file then this program is definitely for you. This will totally take place of Windows Explorer, Far Manager or other file managing utilities since this is maybe used in any type of Operating System even the earliest Windows 95 version.

  10. reddogva99 says:

    Can somebody help me with native? I don’t even know how to creat the .plist file. What program do I use to create the file? Do I then just copy and past what is above?

    Thanks!!

    • reddogva99 says:

      That should say can someone help with noatime

      • Binaryspiral says:

        reddogva99,

        I’m a bit of a linux geek, so I enjoy using the built in text editor VIM.

        1. Copy the code from this article into your clipboard (highlight the lines of code, command+C)
        2. Launch terminal
        3. Type the following command:

        sudo vim /Library/LaunchDaemons/com.nullvision.noatime.plist

        4. Type your user password
        5. Press the letter i on your keyboard to put VIM into insert mode.
        5. Right click in the terminal window and select Paste
        6. You should see the last line look like this:

        7. Press your escape key
        8. Then type :qw
        9. Press enter to write the file.

        Hope this helps!

        • kent says:

          1) Beware that your browser may include non-printing characters if you cut-n-paste. Depends on all sorts of things, of course. If Finder does not show the com.noatime.plist as a “plist” type file, then you may have non-printing characters in it — easy fix with your favorite editor.

          All of the examples above (and the additional files that some of those create) are (should be) just plain text files. Any editor (textedit, bean, vim, emacs, Word / *Office…) will work, just save as “text only” to be safe. Beware editors tacking on extra suffixes, like .txt – no harm, just rename it if it happens.

  11. IraCanis says:

    When I do the “sudo ditto /Users /Volumes/your_hdd_name/Users” command it tells me that the filename is too long for a .fontconfig.

    “ditto: /Users/17 long username/HDD/Users/17 long username/HDD/17 long username/17 long username/HDD/17 long username/17 long username/HDD/17 long username/17 long username/HDD/17 long username/17 long username/HDD/17 long username/17 long username/HDD/17 long username/17 long username/HDD/17 long username/17 long username … /HDD/17 long username/17 long username/HDD/17 long username/17 long username/.fontconfig/0f0db7876307790c19e1f91eb9095080-x86-6: File name too long”
    “ditto: can’t get real path for source”

  12. Michael says:

    Hi, as SSD technology advances, mean time before failure (MTBF) increases. Most new SSD’s (I’ve got an Intel INTEL SSDSA2CW600G3 600 GB) have a MTBF between 1 Mill and 2 Mill hours… (mine is 1.2 Mill Hours). I know that’s only statistics, but we should be confident that no matter how intensive your SSD use is, this little things should last at least 4-5 years… In that timeframe, they will crlearly become obsolete before your disk wears out… What do you think? I mostly run VMware Fusion Virtual Machines from 40 GB up each one…

    • Martin says:

      Could be. One important factor (which I guess I should add to the blog) is the size of the disk vs. the size of the data. If you have 60GB disk and put 59GB of permanent data on it, there is only 1GB left for the variable data which may get worn out pretty fast. If you have a big disk and leave enough empty space, it will last longer.

      • Andy says:

        Logically, you’d think that, but it doesn’t work that way. Pretty much all SSDs have wear leveling, which shuffles around the blocks in the background to keep that from happening.

    • kent says:

      Talking about two (or more) very different things here.

      MTBF is actual failure of the circuit — yeah, that may be sometime after humans have gone extinct. But *correctly functioning* NAND cells can only be written a limited number of times, measured in (10’s of) thousands – and then they still *read* correctly (no failure here!), but cannot be written again. This will be a problem if using the SSD for something like continually looping HD video feeds — and no, not really a problem for anybody not completely rewriting their disk every few days or more often.

      Then you get wear-leveling and other strategies to make sure you don’t wear out just a small set of NAND cells devoted to youtube. Yes, even if you use the same file name every time for downloading youtube, the driver will keep moving the new data around on the SSD (and leaving the old data around until TRIM/gc time). **Q at end**

      Finally, data size vs. disk size (and data change rates) may contribute to write performance. The debate of TRIM vs. passive garbage collection becomes a bigger issue as the disk fills and data is being written to dirty cells, because erasing the cell takes so much longer than writing it (and you have to erase a 512kb chunk). If there is free space on the SSD and sufficient idle time, then either TRIM or garbage collection will maintain a sufficient pool of clean cells; with little free space and lots of writes, the disk will have to reclaim dirty blocks immediately before writing new data, slowing the SSD.

      **Q** Does disk partitioning have any effect on the cells available to the given partition? That is, if I had two partitions, half disk each, and never wrote anything to one of those partitions, would the SSD still level across the whole disk or only half of it?

      • TipTog (the Swiss-dude) says:

        **Q**
        2 partitions is not a good idea (only if you need both…). To increase lifetime and performance you have to set one partition wich do not use 100% of space. The rest you let there without partition. This “over provisioning” can be used by the SSD-Controller for GC and “wear leveling” and other administration-functions. This will only work if there are more blocks clean (never used) than the space without partition! These Blocks can also be used if some blocks are unusable and the normal amount of spareblocks is used up.

        Most of SSD-Software can reduce the partition (and clean the rest) automatically. But most of them are only working on Win for NTFS-partitions. If you want do this for OSX-partitions you make it when setting them for the first time. Or you erase and clean the whole SSD and clone the data from BU after partitioning.

        >> Samsung recommend (for the 840-Series) 0-20% “over provisioning” for home-used SSD >> and up to 50% for Server-used.

        Hope this will help…

  13. David says:

    256mb and 64mb are so much smaller than I imagined, would make those ramdisks bigger help?

  14. Dale says:

    I get all kinds of syntax errors when I try to run the RAM disk shell script.

    It gets hung up on the first semicolon after the [ ] evaluation if statement and before the “then”. WHy the heck would there be a semicolon between the eval block and the “then”?

    Looking at the top of the script it looks like it wants to run in Bourne shell (#!/bin/sh). Is it supposed to be run in another shell?

    Console error below from startup. If I take out the offending semicolon, it blows up again on the next if block (unexpected fi, since it sees that semicolon and thinks the block is ended, I think)

    Jul 4 12:26:06 Mac-Pro com.apple.SystemStarter[229]: /System/Library/StartupItems/RamFS/RamFS: line 11: syntax error near unexpected token `then’
    Jul 4 12:26:06 Mac-Pro com.apple.SystemStarter[229]: /System/Library/StartupItems/RamFS/RamFS: line 11: `    if [ $? -eq 0 ] ; then’

  15. Dale says:

    OK, solved that syntax error issue:

    I had to go open the actual RamFS file in /System/Library/StartupItems that gets created by the 1st script in TextWrangler and run the “convert to ASCII” command. Not sure why the original script didn’t create it in the right encoding scheme.

    To be clear, I did NOT edit the file and somehow get it stuck in non-ASCII mode, only to correct it. The RamFS script would NOT run in its default-installed state.

    Now it works like a charm (confirmed by looking at console log). Thanks!

  16. Bob says:

    This is a slightly off topic.Currently have a mid-2010 MB Pro 15″ with SSD+HDD. I’m using some symbolic links to map larger user folders to the HDD, keeping the User on the SSD in System Preferences. I’m running Lion.

    I’m wondering about upgrading to Mountain Lion when available later this month? I have a feeling that doing the standard upgrade as Apple will provide will cause problems with my setup. Any thoughts on this?

    What I’m thinking about doing is first setting up Lion to work having the entire user folder on the HDD, OS X on the SSD by turning off my sym links.

    Thanks, Bob

  17. Marc says:

    Hi,

    Why not leave hibernation on when there is also an HDD next to your SSD?
    I linked the /var/vm/sleepimage to /Volumes/MyDiskName/var/vm/sleepimage

    Work great.

    Marc

    • Yosi says:

      Hi, would you mind writing the exact thing that I should do to make a symbolic link to the file sleepimage?

      Thanks.

  18. Rikk says:

    Dear Matt, thanks for this informative page.

    I’ve been a Mac user for decades, though my knowledge is mostly of the amateur self-taught variety. I know a bit about the older physical HDs but almost nothing about SSDs. I have a new rMBP with the 16GB RAM – 768 GB SSD option (bit embarrassing but my employer covered most of the cost of the machine). I’m wondering if your suggestions also apply to the fixed SSDs as supplied with the new rMBP? Someone suggested to me that these have been optimized especially for rMBP and that I may not need to change anything. Unfortunately, I have no basis on which to assess their opinion. I did manage to speak to an Apple tech person, but they seemed to know about as much as I did (!).

    Any suggestions/comments?
    Thanks so much

    Rikk

  19. David says:

    Hi!

    Very useful tips! I have a question though, can you revert everything thats been done if you “Move user home directories to HDD”?

    Since several programs don’t work anymore when I tried to go back to original settings with standard user directories.

    Any tips?

    Thanks!

  20. Tony says:

    I’ve tried creating the noatime plist file with pico, vim and TextEdit, chowned it, and I still can’t get noatime to show up when I run mount | grep ” / ”

    I don’t understand what I could possibly be doing wrong.

  21. Sean says:

    The ramdisk configuration worked under Mountain Lion. I verified this by using the df -k command.

    Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on
    /dev/disk2 467684252 249039768 218388484 54% 62323940 54597121 53% /
    devfs 189 189 0 100% 656 0 100% /dev
    map -hosts 0 0 0 100% 0 0 100% /net
    map auto_home 0 0 0 100% 0 0 100% /home
    /dev/disk3 262144 6160 255984 3% 1538 63996 2% /private/tmp
    /dev/disk4 65536 1560 63976 3% 388 15994 2% /private/var/run

  22. Nathaniel Heng says:

    I’m having trouble with my OCZ Octane 2 128Mb in my 2006 Mac Mini. The highest I can go is Snow Leopard 10.6.8 but after I restore my time machine backup to it. It boots once or not at all. When I check the disk via get info, it says that it is 10.7 and thus cannot boot. But the system is 10.6.8. Trim Enabler doesn’t work on this machine but Chameleon SSD started up but have never been able to enable TRIM. After shutting down the computer, I can’t boot up so I have to re-format and then re-install, it’ll boot once and then die.

    Last night, the whole SSD crashed [perhaps due to heat as it was on my DVD player].

    Help…

    • HackedMyPC says:

      Hi,

      Your issue might have to do with an incompatibility of OCZ Agility 2 and Mountain lion, (also one version of snow leopard but don’t remember which one).

      You have to download a later firmware for your drive and reinstall the operating system.

      Then follow these steps.

      Hope this helps.

      PS: just google ocz firmware, it will take you to there official site.

  23. Coffee Cola says:

    Martin,
    Thanks for compiling all this information. I ended up creating symbolic links to the folders in my home dir (including .trash) since I wanted the SSD to boot without the HDD. I’m going to have to watch the user library closely…
    The trick for moving the temp files to the virtual disk on the memory looks interesting but I’m not sure if I’m willing to give up that much memory seeing as how my mbp 3,1 is maxed out at 6GB RAM.
    This M4 SSD has breathed a new live into my laptop.

  24. R. Gomez says:

    Thank you for the post. I have already manually moved all the contents from Users to a HDD, but I’m still not sure how to create the symlinks properly. My SSD is called SSD and my HDD, DATA. Would this be the right Terminal syntax in my particular case, if I wanted to move the Users folder from the SSD to DATA?

    sudo ditto /Users /Volumes/DATA/Users (isn’t this unnecessary if I have already moved the content of /Users?)
    sudo mv /Users /Users.bak
    sudo ln -s /Volumes/SSD/Users /Users

    Sorry if the question is too simple, but I want to make sure I don’t mess it up. Thanks!

  25. Sobhi says:

    thank you for the tips…

    found this and its very convenient :

    http://chameleon.alessandroboschini.it/index.php

  26. Thomas Thaler says:

    Well, I have to say TAHNK YOU for all of this information. It did work for me after a small fixing of your script for moving tmp files to the RAM disk.
    You have in your script

    RamFS

    BUT it is missing the start command for RamFS.
    So it should be more like

    RamFS start

    Now if you do a mount or hdiutil info you’ll see both RAM disks created and mounted.

    Regards from Switzerland
    Thomas

  27. JUKE179r says:

    Thank you very much for the info! I added an OCZ Vertex 4 SSD to my aging 2007 3,1 MBP and now it’s a new notebook again!!! very fast, silent and has less heat now.
    Cheers!

  28. Kapil says:

    Is the “put the hard drive to sleep when possible” appropriate if you have a SSD/HDD combination? With the HDD in the optical bay?

    • Channon says:

      I am now running an SSD/HDD combo. My Mid-2009 13″ MacBook Pro has the same NVidia SATA controller for both the HD bay and the optical bay. (This is the outdated NVidia controller that Apple should not have used, which requires a non-SandForce SSD, such as the Samsung 830 series.)

      I initially put the HDD in the optical bay slot, but when I saw that both had negotiated link speed of 3 Gigabits, I realized that this gave me no speed/performance advantage and I was giving up the Sudden Motion Sensor support, which only exists in the original HD bay. So I swapped the drive locations, and even though the SSD is my start-up disk, it resides in the optical bay. The HDD is in the HD slot, with SMS on.

      Also, the HDD is set to power down after 1 minute of inactivity (to save battery power), and I’m about to implement some of the tips here (specifically, using RAM disk for temp files, and the tip above in the comments by Marc to leave hibernation on since there is also an HDD by linking the /var/vm/sleepimage to /Volumes/MyDiskName/var/vm/sleepimage ).

      Finally, my MBP is 3.5 yrs old, and I think this new SSD/HDD combo is going to give me at least 3.5 more years of functionality, maybe even 5–with the new speed and storage space. I am of the mindset that the SSD, even with a ton of abuse, will never be the lifespan-limiting factor of my MBP! To see that to fruition, I bought a 256GB SSD and only currently have 60GB of data on it. That gives both headroom for the future and “more drive” to wear out.

  29. stuartbell says:

    I am really afraid of coding and all that. I just downloaded the tool from http://www.drivetoolbox.com/ and optimized my Mac OSX.

  30. mike galicki says:

    Just a word of caution. I had been enjoying the RAM disk configuration mentioned here for several months. Recently I started to notice installation of software updates were failing left and right. I turns out that /private/tmp is not big enough for things like Microsoft Office software update. The update writes temporary files into /private/tmp and ends up filling the device.
    I haven’t had a chance to try to find the sweet spot on sizing of /private/tmp but just know if you start to see install errors from MAS or other places you might want to disable the RAM disk or make it larger.

  31. Vitor says:

    hi, is the Disable “last access time” tweak reversible?

  32. mike says:

    Hey Martin,

    Good article, thanks.

    Seems like someone may have liked it enough to put it on their website too – maybe they did let you know about that and got your permission (in which case it’s OK I suppose), but maybe they didn’t? I thought you might want to check it out – I’ve stumbled across it accidentally, just after I’ve read yours!

    http://icomputerdenver.com/ssd-optimization-for-mac-os/

    Regards,
    mike

  33. Jim Knoble says:

    Thought you might want to know a virtual clone of your article, with no attributions, has appeared: http://icomputerdenver.com/ssd-optimization-for-mac-os/ . The “author” also removed attributions from the MoveTempFoldersToRamDisk.sh script.

  34. Vincent says:

    Hey Tim,

    I followed your steps to a T… was doing some reasearch on Fusion drive, but have decided to stick with your method since its faster!

    however this guy’s point on the ~\library folder has got me thinking…

    what’s your opinion on it? also i’ve been driving myself nuts in circles trying to figure out to implement this.. since i’ve already moved the whole home folder (which is of course now tooo large to just throw back to the SSD)

    any input would greatly be appreciated!

    vincent

  35. Vincent says:

    actually i think i may have figured a way.. trying now.. (made a backup before of course)

    so what i did was use your new revised method and right clicked on my user and rerouted the user directory to my HDD. [p.s. in user preferences with your original method it still did show ~\users in there just like normal…]

    then went on SSD deleted users folder (symlinked)

    then created a new users folder and my user folder name (just so i dont get confused later)

    now using terminal commands from the other guys page.. to ditto the library folder over back to SSD.

    and make a sym link from the HDD to the SSD..

    sigh i’m pretty confident this will work.. and will definitely get you some feedback on how it feels (sadly i was too eager to do any timing tests)

  36. jol1naras says:

    I will offer a suggestion, regarding the hibernation.

    I have the following configuration on my laptop:
    primary disk: SSD – for the OS and the user folder.
    secondary disk: HDD – for files.

    In case you want to keep hibernation, without harming your SSD, you could create a link to the HDD instead of the SSD.

    Simply:

    Keep it if something goes wrong.
    $ sudo mv /var/vm /var/vm.backup

    create a link to the disk you want to keep your RAM output. REMEMBER to replace the with your actual disk name.
    $ sudo ln -s /Volumes//vm/ /var/vm

    Then close the lid and see if the “sleepimage” file is created. If so, then move the swapfile0 there too and you are set to go.

    Copy the swapfile0
    either: $ open /var/vm

    Then drag & drop inside the folder you created above with the “ln” command.

    or: $ sudo cp /var/vm/swapfile0 /Volumes//vm/swapfile0

    It worked for me, so I assume it will work for everybody else. I don’t guarantee any correctness, regarding the above description.

    • jol1naras says:

      Actually I forgot something.

      You must first create the folder “vm” on the new disk.

      $ sudo mkdir /Volumes//vm
      $ sudo chgrp wheel /Volumes//vm

      After this you can continue with the commands described on the previous post.

  37. Stephen says:

    Wow, that’s a really well researched post. I recently put a 120 gig OCZ in my MBP (late 2008) and will be doing some of these things later on. Most interesting was the RAM disk, which I last used on a Powerbook 1xx series back in the early 90’s. It sure makes the mac faster

  38. Neither the hibernatemode = 0 option nor the noatime flag work for me. I have Macbook Pro Retina 16GB with 256 SSD OSX10.8.2 (Mountain Lion).

    I can delete the 17GB sleepimage file, but it re-appears after some minutes (don’t even need to set the machine to sleep using the power button nor closing the lid; it simply re-appears!

    And the no update option is not set for the drive though I followed the instructions to the dot.

    Do this tweaks for for the latest OSX?

  39. Maximilian says:

    Thanks Martin for posting this! I applied several of those tweaks—including the one that uses a RAM disk for temporary files—and my fusion drive seems to be quite happy with them.

    Now, I have a quick question that I hope you might be able to answer. For some reason the installer of Microsoft Office 2011 14.2.5 fails, and looking at the log output I have a hunch it might have something to do with the RAM disk tweak Do you think that’s possible?

    Thanks! Max

    PS: This was in the installer log:

    Cross device symlink found in shove path, including /private/tmp/com.microsoft.office.updater/com.microsoft.office.all.automator.pkg.14.2.5.update

    writing to output file got error: Result too large

    error processing data: Invalid argument

    Error relinking file (copy item): /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/Cleanup At Startup/PKInstallSandboxManager/1.sandbox/Root/tmp/com.microsoft.office.updater/com.microsoft.office.all.word.pkg.14.2.5.update to /private/tmp/com.microsoft.office.updater/com.microsoft.office.all.word.pkg.14.2.5.update, NSError = ““Microsoft Word” couldn’t be copied to “MacOS”.”

    srcPath = /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/Cleanup At Startup/PKInstallSandboxManager/1.sandbox/Root/tmp/com.microsoft.office.updater/com.microsoft.office.all.word.pkg.14.2.5.update NSFileOwnerAccountID=0 NSFileSystemFileNumber=2597217 NSFileExtensionHidden=0 NSFileSystemNumber=16777224 NSFileSize=102 NSFileGroupOwnerAccountID=80 NSFileOwnerAccountName=root NSFileCreationDate=2012-11-16 11:38:48 +0000 NSFilePosixPermissions=509 NSFileType=NSFileTypeDirectory NSFileGroupOwnerAccountName=admin NSFileReferenceCount=3 NSFileModificationDate=2012-11-16 11:38:48 +0000

    dstParentPath = /private/tmp/com.microsoft.office.updater NSFileOwnerAccountID=0 NSFileSystemFileNumber=610 NSFileExtensionHidden=0 NSFileSystemNumber=16777225 NSFileSize=1530 NSFileGroupOwnerAccountID=0 NSFileOwnerAccountName=root NSFileCreationDate=2012-11-15 08:52:47 +0000 NSFilePosixPermissions=493 NSFileType=NSFileTypeDirectory NSFileGroupOwnerAccountName=wheel NSFileReferenceCount=45 NSFileModificationDate=2012-11-16 11:39:08 +0000

    [source=dir, dst=dir] failed _RelinkFile(/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/Cleanup At Startup/PKInstallSandboxManager/1.sandbox/Root/tmp/com.microsoft.office.updater/com.microsoft.office.all.word.pkg.14.2.5.update, /private/tmp/com.microsoft.office.updater/com.microsoft.office.all.word.pkg.14.2.5.update) with unexpected error: No such file or directory

    srcPath = /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/Cleanup At Startup/PKInstallSandboxManager/1.sandbox/Root/tmp/com.microsoft.office.updater/com.microsoft.office.all.word.pkg.14.2.5.update NSFileOwnerAccountID=0 NSFileSystemFileNumber=2597217 NSFileExtensionHidden=0 NSFileSystemNumber=16777224 NSFileSize=102 NSFileGroupOwnerAccountID=80 NSFileOwnerAccountName=root NSFileCreationDate=2012-11-16 11:38:48 +0000 NSFilePosixPermissions=509 NSFileType=NSFileTypeDirectory NSFileGroupOwnerAccountName=admin NSFileReferenceCount=3 NSFileModificationDate=2012-11-16 11:38:48 +0000

    dstPath = /private/tmp/com.microsoft.office.updater/com.microsoft.office.all.word.pkg.14.2.5.update NSFileOwnerAccountID=0 NSFileSystemFileNumber=9802 NSFileExtensionHidden=0 NSFileSystemNumber=16777225 NSFileSize=102 NSFileGroupOwnerAccountID=0 NSFileOwnerAccountName=root NSFileCreationDate=2012-11-16 11:39:08 +0000 NSFilePosixPermissions=493 NSFileType=NSFileTypeDirectory NSFileGroupOwnerAccountName=wheel NSFileReferenceCount=3 NSFileModificationDate=2012-11-16 11:39:08 +0000

    installd[12249]: PackageKit: Install Failed: Error Domain=PKInstallErrorDomain Code=120 “An unexpected error occurred while moving files to the final destination.” UserInfo=0x7f8a024042e0 {NSUnderlyingError=0x7f8a03318530 “The operation couldn’t be completed. No such file or directory”, NSLocalizedDescription=An unexpected error occurred while moving files to the final destination., arguments=(
    “-f”,
    “-s”,
    “/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/Cleanup At Startup/PKInstallSandboxManager/1.sandbox/Root”,
    “/”
    )} {
    NSLocalizedDescription = “An unexpected error occurred while moving files to the final destination.”;
    NSUnderlyingError = “Error Domain=NSPOSIXErrorDomain Code=2 \”The operation couldn\U2019t be completed. No such file or directory\””;
    arguments = (
    “-f”,
    “-s”,
    “/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/Cleanup At Startup/PKInstallSandboxManager/1.sandbox/Root”,
    “/”
    );
    }

    Installer[14141]: Install failed: The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.

    • Martin says:

      I am guessing this may be caused by the size of the ram disk being too small for MS Office installer. So you may either want to revert the RAM disk hint temporarily or increase the RAM disk size.

    • mark says:

      I’m a little late to the party having just installed an SSD, but my solution was to rename the /tmp symlink to /tmp.h (sudo mv /tmp /tmp.h), then you can either create a /tmp folder or link another drive the that location. Once completed I just removed the link and renamed /tmp.h back to /tmp. Try to leave your computer idle while the update installs so no other applications have open files into your temporary /tmp folder (I had no problems).

Leave a Reply