OS X on SSDs

I recently replaced the boot drives of my 17″ MacBook Pro, 15″ MacBook Pro and Hackintosh with SSDs. I have replaced the Superdrives on both MacBooks with cradles holding 750GB 7200RPM SATA HDDs, so I wasn’t too worried about having giant-capacity SSDs, I basically just needed enough to hold the OS and Applications. Consequently, a good balance of price and capacity at the time (Dec 2012) was 128GB Sandisk SATA 3 drives. Yes, the MacBooks are not SATA 3, but my Hackintosh is.

I am a great fan of partitioning, coming from a Solaris background (Back when Sun was good), and consequently, partitioned both the SSD boot drive and the HDD, as follows:

SSD:

Boot – 60GB
Applications – 50GB
FastAccess – 18GB

HDD:

Swap – 24GB (MacBook Pro) 72GB (Hackintosh) (3 X amount of RAM)
Users – Remainder of disk

The reason the swap partition is so high will become apparent later

So….

Build the OS in the usual way, onto the Boot partition on the SSD.

Move Applications.

There is no real need to move the applications, I just prefer to in order to compartmentalise things

When all is complete, and you have rebooted, move the applications to the Applications partition:

cd /Volumes/Applications
sudo ditto /Applications .

Next, make sure that the Applications partition mounts on /Applications at boot. First find the GUID of the Applications partition. Open Disk Utility, highlight the Applications partition, and click File -> Get info. Highlight the value of the Universal Unique Identifier parameter, and hit Command-c to copy it to the clipboard.

Add the following line to /etc/fstab (“sudo vifs” will open it for editing):

 UUID=<Universal Unique Identifier from above> /Applications hfs rw 0 2

Empty the /Applications directory, so that it works correctly as a mount point:

 cd /Applications
 sudo rm -rf *

Reboot. Run Software Update, and update everything. The first part is now complete.

In part 2, we move users, swapfile, sleepimage and tmp files off the SSD, add TRIM support and switch off access time recording for files on SSD partitions

Move Users.

Run the following command:

 sudo ditto /Users /Volumes/Users

Then open System Preferences, click on Users and Groups, Unlock to make changes, right click on each user to open Advanced Options, and change the Home Directory to the correct path

Reboot

Move Swapfile.

The swapfiles are usually located in /var/vm. Obviously, we want them off the SSD, so we’ll put them in the Swap partition we created on the spinny disk

Run the following commands:

 cd /System/Library/LaunchDaemons
 sudo cp com.apple.dynamic_pager.plist com.apple.dynamic_pager.plist.bak
 sudo plutil -convert xml1 com.apple.dynamic_pager.plist

Edit com.apple.dynamic_pager.plist. Replace

 <string>/sbin/dynamic_pager</string>
 <string>-F</string>
 <string>/private/var/vm/swapfile</string>

with

 <string>/bin/bash</string>
 <string>-c</string>
 <string>/bin/wait4path /Volumes/Swap/ &amp;&amp; /sbin/dynamic_pager -F /Volumes/Swap/swapfile</string>

Reboot

Move sleepimage

When the system hibernates, it saves the contents of memory to disk. The size of this file varies, but can be up to the the size of system RAM. This is why the Swap partition is so big – we’re going to put this file there (Usual location is /var/vm)

Run the following command:

sudo pmset -a hibernatefile /Volumes/Swap

Reboot

Move tmp files

tmp files live until reboot. we don’t really want them on the SSD, they can also go on the spinny drive.

Run the following commands:

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

Reboot

Add TRIM Support

Download Trim Enabler

Install it

Switch it on.

Reboot

Switch off File Access Time Recording

In /Library/LaunchDaemons, create the following files:

com.apple.noatime1.plist

 <?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">
 <plist version="1.0">
   <dict>
     <key>Label</key>
     <string>com.apple.noatime1</string>
     <key>ProgramArguments</key>
     <array>
       <string>mount</string>
       <string>-vuwo</string>
       <string>noatime</string>
       <string>/</string>
     </array>
     <key>RunAtLoad</key>
    <true/>
   </dict>
 </plist>

com.apple.noatime2.plist

 <?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">
 <plist version="1.0">
   <dict>
     <key>Label</key>
     <string>com.apple.noatime2</string>
     <key>ProgramArguments</key>
     <array>
       <string>mount</string>
       <string>-vuwo</string>
       <string>noatime</string>
       <string>/Applications</string>
     </array>
     <key>RunAtLoad</key>
    <true/>
   </dict>
 </plist>

com.apple.noatime3.plist

 <?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">
 <plist version="1.0">
   <dict>
     <key>Label</key>
     <string>com.apple.noatime3</string>
     <key>ProgramArguments</key>
     <array>
       <string>mount</string>
       <string>-vuwo</string>
       <string>noatime</string>
       <string>/Volumes/FastAccess</string>
     </array>
     <key>RunAtLoad</key>
    <true/>
   </dict>
 </plist>

Reboot

DONE!