14
03/08/12 5:02 AM Optimizing MacOS X Lion for SSD » Martin's Weekend Coding Page 1 of 14 http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/ April 1st, 2012 by Martin April 1st, 2012 by Martin Leave a reply » Leave a reply » Tweet Tweet 19 3 Share Optimizing MacOS X Lion for SSD 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 [#no-benchmarks] Use Trim Enabler [#trim-enabler] Turn off local Time Machine snapshots [laptops only] [#time-machine] Turn off hibernation [laptops only] [#hibernation] Set noatime flag [#noatime] Move user home directories to HDD [SSD+HDD only] [#move-home] Use RAM disk or HDD for temporary files [#ramdisk] Turn off sudden motion sensor [SSD+HDD only] [#no_sms] Turn off hard drive sleep [SSD+HDD only] [#no_hdd_sleep] References/Other tweaks [#references] 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 [http://osxdaily.com/2012/01/03/enable-trim-all-ssd-mac-os-x-lion/] or go to the TrimEnabler web site [http://www.groths.org/?page_id=322] 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 Martin's Weekend Coding Sharing useful tips from my "weekend projects" 9 Like

Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

Embed Size (px)

DESCRIPTION

Turn hibernate on off os x Guide for a OS x user. References are welcome

Citation preview

Page 1: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 1 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

April 1st, 2012 by MartinApril 1st, 2012 by Martin Leave a reply »Leave a reply »

TweetTweet 19 3 Share

Optimizing MacOS X Lion for SSD

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 keptthe 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 stillhealthy 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 thelaptop. 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’vedecided 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 ofothers 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 minimizethe 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 toparticular 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 [#no-benchmarks] Use Trim Enabler [#trim-enabler] Turn off local Time Machine snapshots [laptops only] [#time-machine] Turn off hibernation [laptops only] [#hibernation] Set noatime flag [#noatime] Move user home directories to HDD [SSD+HDD only] [#move-home] Use RAM disk or HDD for temporary files [#ramdisk] Turn off sudden motion sensor [SSD+HDD only] [#no_sms] Turn off hard drive sleep [SSD+HDD only] [#no_hdd_sleep] References/Other tweaks [#references]

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 SSDSome 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 thanthe old HDD. So they get this cool idea of running some extensive benchmarks to see the amazing performance numbers. Benchmarks usuallywrite 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 startusing it. Don’t do it.

Use Trim EnablerTRIM support is essential for keeping the SSD healthy. Unfortunately, MacOS supports TRIM only for Apple-supplied SSD’s. If you bought a3rd 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 foryou. You can read more here [http://osxdaily.com/2012/01/03/enable-trim-all-ssd-mac-os-x-lion/] or go to the TrimEnabler web site[http://www.groths.org/?page_id=322] 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 attimes when your Time Machine disk is not available. This is quite common – you are typically connecting your external TM disk only once in awhile 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

Martin's Weekend Coding Sharing useful tips from my "weekend projects"

9Like

Page 2: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 2 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

are on by opening Time Machine Preferences:

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 thefollowing 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 asspace 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 backupsback 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/ [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 ensureyour 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 diskevery 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 theevening. 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 yourSSD 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 takesfor 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/ [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 thehibernatemode values:

We do not recommend modifying hibernation settings. Any changes you make are not supported. If you choose to do so anyway, werecommend 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 systemmust 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, andbetter battery life, you should use this setting.

Page 3: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 3 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

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 muchRAM you have):

sudo rm /var/vm/sleepimage

Set noatime flagMacOS (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 thefilesystem 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 noatimeflag 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:

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 [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/[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 folderto 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 readsome 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/Userssudo mv /Users /Users.baksudo 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 advancedediting (password prompt will appear). Once unlocked, you should be able to right-click on each user account and choose Advanced Optionsfrom the pop-up menu. Once in the Advanced Options dialog, change the Home directory of the user from “/Users/user-name” to the newlocation (e.g. “/Volumes/HDD/Users/user-name”).

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

123456789

101112131415161718

<?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.nullvision.noatime</string> <key>ProgramArguments</key> <array> <string>mount</string> <string>-vuwo</string> <string>noatime</string> <string>/</string> </array> <key>RunAtLoad</key> <true/> </dict></plist>

?

Page 4: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 4 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

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 filesIf 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 onlyresides 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:

#!/bin/bash

# +----------------------------------------------------------------------+

# | |

# | Set up Mac OS X to store temporary files in RAM rather than on disk.|

# | |

# | By Philipp Klaus <http://blog.philippklaus.de> |

# | |

# | Originally by Ricardo Gameiro <http://blogs.nullvision.com/?p=357> |

# | Changes by Daniel Jenkins |

# | <http://blogs.nullvision.com/?p=357#comment-1140> |

# | |

# +----------------------------------------------------------------------+

cd /System/Library/StartupItemssudo mkdir RamFSsudo chown -R root:wheel RamFSsudo chmod -R u+rwX,g+rX,o+rX RamFScat << "EOF" | sudo tee RamFS/RamFS > /dev/null#!/bin/sh

# Create a RAM disk with same perms as mountpoint

RAMDisk() { mntpt=$1 rdsize=$(($2*1024*1024/512)) echo "Creating RamFS for $mntpt" # Create the RAM disk. dev=`hdik -drivekey system-image=yes -nomount ram://$rdsize` # Successfull creation... if [ $? -eq 0 ] ; then # Create HFS on the RAM volume. newfs_hfs $dev # Store permissions from old mount point. eval `/usr/bin/stat -s $mntpt` # Mount the RAM disk to the target mount point. mount -t hfs -o union -o nobrowse $dev $mntpt # Restore permissions like they were on old volume. chown $st_uid:$st_gid $mntpt chmod $st_mode $mntpt fi}

# Test for arguments.

if [ -z $1 ]; then echo "Usage: $0 [start|stop|restart] " exit 1fi

# Source the common setup functions for startup scripts

test -r /etc/rc.common || exit 1

Page 5: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 5 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

view rawMoveTemporaryFoldersToRamdisk_MacOSX.sh

. /etc/rc.common

StartService () { ConsoleMessage "Starting RamFS disks..." RAMDisk /private/tmp 256 RAMDisk /var/run 64 #RAMDisk /var/db 1024 #mkdir -m 1777 /var/db/mds}StopService () { ConsoleMessage "Stopping RamFS disks, nothing will be done here..." # diskutil unmount /private/tmp /private/var/run # diskutil unmount /private/var/run}

RestartService () { ConsoleMessage "Restarting RamFS disks, nothing will be done here..."}

RunService "$1"EOFsudo chmod u+x,g+x,o+x RamFS/RamFS

cat << EOF | sudo tee RamFS/StartupParameters.plist > /dev/null<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"><plist version="0.9"> <dict> <key>Description</key> <string>RamFS Disks Manager</string> <key>OrderPreference</key> <string>Early</string> <key>Provides</key> <array> <string>RamFS</string> </array> <key>Uses</key> <array> <string>Disks</string> </array> </dict></plist>EOF

This Gist brought to you by GitHub.

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 abovescript) 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.

Page 6: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 6 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

There are some small drawbacks to applying this tweak:

After applying it it takes a few seconds (2-3 on my machine) to shut downIt 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 RAMdisk. 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/tmpsudo rm -rf /private/tmpsudo 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/[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[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 [http://en.wikipedia.org/wiki/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/ [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 probablydon’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 anduncheck “Put the hard disk(s) to sleep when possible”.

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

References/Other tweaksThe tweaks that I presented are the tweaks that I thought are worth applying. None of them really limits any features. There are other tweaks,

Page 7: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 7 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

41 comments41 comments Add your commentAdd your comment

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://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/] http://blog.philippklaus.de/2011/04/ssd-optimizations-on-mac-os-x/ [http://blog.philippklaus.de/2011/04/ssd-optimizations-on-mac-os-x/] http://www.ocztechnologyforum.com/forum/showthread.php?62354 [http://www.ocztechnologyforum.com/forum/showthread.php?62354]

Previous Entry: New Library for Reading and Writing Zip Files in JavaNext Entry: Proxy Client on Top of JAX-RS 2.0 Client API

Posted in MacTags: lion mac osx ssdYou can follow any responses to this entry through the RSS 2.0 Feed . You can leave a response , or trackback from your own site.

Reply

Tommy

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 toLion’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

April 6, 2012 at 12:47 am

Reply

Martin

Thanks for the pointer. Will update the blog.

May 2, 2012 at 2:37 pm

Reply

Martin

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 garbagecollection. 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 areused 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 fromthe 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 thenative 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 ofTrim Enabler to be unreliable. So the manufacturers need to create impression things are fine even without TRIM (as they can’t provide a supportableTRIM 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.

May 2, 2012 at 3:34 pm

Greg

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 youneed 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 toerase 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 nopractical 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 ofyour 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 ablock 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 writehappen fast. Finally, the used block is erased at a convenient time and put into the pool of erased blocks.

July 7, 2012 at 3:10 pm

Page 8: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 8 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

Reply

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 shortperiod 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 SDDcontroller. Plus, the OS and SDD controller have to play nice with each other for TRIM to work. For example, Microsoft could have good supportfor your SDD, while Apple only supports their own drives.

Reply

Pat

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.

April 29, 2012 at 12:03 pm

Reply

Martin

I don’t know. See if symbolic links enable you to do so (i.e. try doing the similar thing I did for the user home dir).

May 2, 2012 at 2:51 pm

Reply

Frank

My internal SSD is called “Macintish SDD”My internal HD is called “Macintosh HD”Please change according to your settings in the following…

sudo mkdir /Volumes/Macintosh\ HD/var/vmsudo chown root:wheel /Volumes/Macintosh\ HD/var/vmcd /private/varsudo mv vm vm.baksudo ln -s /Volumes/Macintosh\ HD/var/vm ./vm

August 1, 2012 at 3:24 pm

Reply

stef

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 ttys0015/2/12 8:01:00.301 AM sudo: username : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/bin/mkdir RamFS5/2/12 8:01:00.331 AM sudo: username : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/usr/sbin/chown -R root:wheel RamFS5/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 RamFS5/2/12 8:01:00.384 AM sudo: username : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/usr/bin/tee RamFS/RamFS5/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/RamFS5/2/12 8:01:00.424 AM sudo: username : TTY=ttys001 ; PWD=/System/Library/StartupItems ; USER=root ; COMMAND=/usr/bin/tee RamFS/StartupParameters.plist5/2/12 8:01:00.436 AM login: DEAD_PROCESS: 338 ttys001

Dead process? why did it fail?

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

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

May 2, 2012 at 2:07 pm

Martin

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 atthe 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

May 2, 2012 at 2:48 pm

Page 9: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 9 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

Reply

effect after restart.

Reply

Isidoros Sklivanos

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

May 6, 2012 at 4:21 pm

Reply

Martin

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

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

May 6, 2012 at 4:43 pm

/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)

Reply

David

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 todo in order to benefit from Trim support, or whether that is done automatically.Tom.

May 28, 2012 at 8:29 am

Reply

Martin

That’s done automatically by the system.

May 29, 2012 at 11:59 am

Reply

Isidoros Sklivanos

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)”

May 6, 2012 at 6:33 pm

Reply

Isidoros Sklivanos

ok done! thanks you martin nice tips

May 6, 2012 at 6:47 pm

Reply

Peter Kalas

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

May 9, 2012 at 4:04 pm

Martin May 9, 2012 at 10:15 pm

?

Page 10: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 10 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

Reply

Should be possible to simply reverse the steps:

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

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

sudo rm -rf /Volumes/your_hdd_name/UsersAnd restart. Haven’t tried it though.

Reply

Stathis Tzouvaras

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

May 10, 2012 at 9:59 pm

Reply

HackedMyPC

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!

May 19, 2012 at 3:51 pm

Reply

Martin

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 thansymbolic 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 anyissue.

May 19, 2012 at 10:38 pm

HackedMyPC

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 ensuringthat 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 Iattempt 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 changesalthough 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 ableto 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 toto 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 includingthe 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 ? (Ithought 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 …

May 22, 2012 at 4:49 am

Page 11: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 11 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

Reply

Reply

Martin

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 advancedoptions 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 thissetting 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?

May 22, 2012 at 10:09 pm

Reply

Martin

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 seemto 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 doesnot 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 howthe 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 Usersfolder or any of it’s subfolders.

May 22, 2012 at 10:26 pm

Reply

HackedMyPC

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 /Userssymbolic 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 didnot 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 inI 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 mostSSD’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.

May 23, 2012 at 3:09 am

Reply

reddogva99

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!!

May 31, 2012 at 3:34 pm

Reply

reddogva99

That should say can someone help with noatime

May 31, 2012 at 3:34 pm

Reply

IraCanis

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 longusername/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 longusername/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”

June 12, 2012 at 1:17 am

Page 12: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 12 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

Reply

Michael

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 MTBFbetween 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, thislittle 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 VMwareFusion Virtual Machines from 40 GB up each one…

June 19, 2012 at 5:08 pm

Reply

Martin

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 ofpermanent 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 willlast longer.

June 26, 2012 at 1:26 pm

Reply

Andy

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 tokeep that from happening.

July 28, 2012 at 4:49 am

Reply

David

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

June 23, 2012 at 10:00 pm

Reply

Martin

For the two locations I am redirecting to the ram disks they seem to be big enough – i.e. no reason to make them bigger.

June 26, 2012 at 1:19 pm

Reply

Dale

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 theblock 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’

July 4, 2012 at 8:15 pm

Reply

Dale

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. Notsure 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!

July 5, 2012 at 6:48 pm

Page 13: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 13 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

Trackbacks Trackbacks //PingbacksPingbacks

Matt Adamczyk's Blog - Replacing MacBook Pro OpticalMatt Adamczyk's Blog - Replacing MacBook Pro OpticalDrive with a SSDDrive with a SSD

What you really need to know when adding a SSD to yourWhat you really need to know when adding a SSD to yourMacbook Pro! | ElectricSproketMacbook Pro! | ElectricSproket

Set noatime in Mountain Lion for SSD | MoVn - LinuxSet noatime in Mountain Lion for SSD | MoVn - LinuxUbuntu CenterUbuntu Center

Reply

Bob

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 Useron 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 causeproblems 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

July 8, 2012 at 4:06 pm

Reply

Marc

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

July 25, 2012 at 10:03 am

Reply

Rikk

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 aboutSSDs. 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 yoursuggestions 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 notneed 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 asmuch as I did (!).

Any suggestions/comments?Thanks so much

Rikk

July 26, 2012 at 11:34 pm

Reply

David

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!

July 30, 2012 at 6:10 pm

Page 14: Turn-Off Hibernation - Optimizing MacOS X Lion for SSD

03/08/12 5:02 AMOptimizing MacOS X Lion for SSD » Martin's Weekend Coding

Page 14 of 14http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/

Name (required)

Mail (will not be published) (required)

Website

Submit Comment

Back to Top

Leave a Reply

© 2012 Martin's Weekend Coding · Proudly powered by WordPress & Green Park 2 by Cordobo.Valid XHTML 1.0 Transitional | Valid CSS 3