Showing posts with label power management. Show all posts
Showing posts with label power management. Show all posts

Saturday, June 15, 2013

Useful processes to kill in OSX

From time to time, some of user interface or system process go crazy or freeze. It's always good to know how to kill and restart those processes them without restarting the system.

  • Frozen Finder: Kill it. Restarts by itself
    > sudo killall Finder
  • Frozen Spotlight: Kill it. Restarts by itself
    > sudo killall SystemUIServer
  • mDNSResponder sometimes gets stuck (observed in 10.5 and 10.6) and as it does so the system-wide name resolving stops working. Meaning that internet names are not resolved anymore
    > sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
    > sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
    or ometimes it also works to kill it and restarts by itself
    > sudo killall mDNSResponder
  • If mds goes crazy indexing some new volume: Stop it:
    > sudo mdutil -i off /path_to_volume
    or stop it on all volumes with:
    > sudo mdutil -a -i off
  • ... any other?

Sources:
http://superuser.com/questions/231517/how-can-i-quit-frozen-spotlight-without-rebooting-my-computer
http://linuxtoosx.blogspot.fr/2011/10/restart-mdnsresponder.html
http://www.thexlab.com/faqs/stopspotlightindex.html
http://support.apple.com/kb/ht3789#

Saturday, October 15, 2011

Optimizing Mac OS X for SSD drives (update: Safe Sleep tuning)

This article: http://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/ recommends to reduce the writes on SSD drives to increase their lifespan. The proposed actions go in the direction of reducing un-necessary writes and disable legacy options linked to spinning hard drives.
I'm using: 1(with modified deepsleepdelay), 2, 3 and 4.

1. Alter the Sleeping mode 
By default, when closing the lid on a MacBook, the content of the ram (random-access memory) is saved to disk for safety. The ram is still powered on however, and is used when starting up again. The content saved on disk is only used in case of a power loss.

• This behavior can be changed so that ram content is not saved to disk.
$ sudo pmset -a hibernatemode 0 
This means that the laptop will never enter DeepSleep (or hibernation, that is the ram is always powered and in the event of a power loss the state is lost), and in this case the sleepimage /var/vm/sleepimage can also be removed.

• The default setting (SafeSleep) can be restored with: 
$ sudo pmset -a hibernatemode 3

• There is an intermediate behavior of SafeSleep, which delays the writing of the sleepimage for some time. This is controlled by the deepsleepdelay parameter (or standbydelay), by default set to 4200 seconds, meaning that the seleepimage is written 70 minutes after closing the lid. This may be too short.
To make it wait 12hs before writing the image to disk run:
$ sudo pmset -a deepsleepdelay 43200
or, on systems with OS X ≥ 10.6.8,
$ sudo pmset -a standbydelay 43200
during this time only the ram is powered and the wakeup is immediate. After 12 hours of sleep, the memory content is dumped to the sleepimage and the memory is powered off.
I'm currently trying this setting.

In conclusion, SafeSleep (hibernatemode 3) combined with deepsleepdelay <seconds> covers a wide range of sleepping/hibernating behaviors. It can even emulate the hibernatemode 0 (never save a sleepimage) just by setting a deepsleepdelay big enough.

2. Disable Hard drive sleep 
Putting SSD hard drives to sleep has no benefit. 
This can be disabled under System Preferences -> Energy Saver

3. Disable Sudden motion sensor 
$ sudo pmset -a sms 0

4. Enable noatime for SSD filesystems 
Every time a file is accessed its access time is modified to reflect it. This can be disabled to save additional writes. To do this for the local filesystem create the file /Library/LaunchDaemons/com.noatime.root.plist 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">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.noatime.root</string>
        <key>ProgramArguments</key>
        <array>
            <string>mount</string>
            <string>-uwo</string>
            <string>noatime</string>
            <string>/</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
</plist>
This will execute mount -uwo noatime / upon system startup,

5. Disable Spotlight 
$ sudo mdutil -a -i off

Sources and resources:
http://larvecode.tumblr.com/post/9622045759/osx-on-ssd
http://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/
http://www.macworld.com/article/53471/2006/10/sleepmode.html
http://www.uponmyshoulder.com/blog/2011/deep-sleep-on-macbook-air-late-2010/
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/pmset.1.html

Tuesday, September 22, 2009

Make Macbook Pro Hibernate


pmset -g | grep hibernate

This should return one of the following:
  • 0 - Legacy sleep mode. It will save everything to RAM upon sleeping but does not support “Safe Sleep”. Very fast sleep.
  • 1 - Legacy “Safe Sleep”. This is the “Safe Sleep”. Everything your laptop goes into sleep, it will save everything to harddisk. Slow on Sleep and Startup.
  • 3 - Default. As described above, when sleeping, contents are saved to RAM. When battery runs out, hibernate occurs.
  • 5 - Behaves as 1 but applicable only for modern Mac that uses “Secure virtual memory”.
  • 7 - Behaves as 3 but applicable only for modern Mac that uses “Secure virtual memory”.
Now edit and save your /Users/username/.bash_profile file with the following lines:

alias hibernateon="sudo pmset -a hibernatemode 5"

alias hibernateoff="sudo pmset -a hibernatemode 3"

hibernateon and hibernateoff can be any text you want, you just need to remember what you used.

See follow-up: http://linuxtoosx.blogspot.com/2011/10/optimizing-mac-os-x-for-ssd-drives.html