Why You Care
Is your Mac harder to wake-up in the morning than a teenager? Do you find yourself waiting impatiently for your VMs and containers to come back to life after your Mac decides to take a nap? If you're tired of battling sluggish wake-up times and want to keep your development environment humming 24/7, you're in the right place. We're going to dive into the nitty-gritty of macOS power settings, specifically how to prevent hibernation and deep sleep when your Mac is plugged in. This is a game-changer for engineers who rely on VMs and containers and need their systems to stay responsive. Note that many of these settings are not accessible through the standard macOS user interface and must be configured using the Terminal.
TL;DR; Optimal AC Power Settings for Continuous Operation (VMs & Containers)
To ensure your Mac never hibernates or enters deep sleep when plugged in, use these commands in Terminal:
sudo pmset -c hibernatemode 0
sudo pmset -c sleep 0
sudo pmset -c disksleep 0
Settings Changed Today and Why (Engineer Focus)
- hibernatemodeWe changed this to 0 for AC power to completely prevent hibernation. This is crucial for engineers who need their development environments (VMs, containers, etc.) to remain active and responsive.We left it at 3 for battery power to protect your data in case of power loss when traveling.1 and 2 are obsolete modes that should be avoided.
- sleepWe disabled system sleep when on AC power. This ensures your Mac never enters deep sleep, keeping your VMs and containers running without interruption.
- disksleepWe disabled disk sleep when on AC power. This prevents the hard drive from going to sleep, which is essential for applications that frequently access disk resources, such as VMs and container images.
Considerations
- Disabling hibernation and system sleep on AC power ensures that your VMs and containers remain active. This is particularly important for long-running processes, build servers, and development environments.
- If you frequently use network-intensive applications or services, consider keeping networkoversleep disabled for a more responsive network connection.
- Be mindful of disk usage when running VMs and containers. Disabling disk sleep can increase disk activity, so ensure you have adequate storage and backup strategies.
- For those that use external displays, ensure that the external displays are set to never sleep in their own settings.
For those interested in a deeper dive, read on!
Reading Current Configuration
- View settings for active profile: pmset -g
- View custom settings for battery and AC: pmset -g custom
- View custom settings for AC power: pmset -g custom | grep -A 1 "AC Power"
- View custom settings for Battery power: pmset -g custom | grep -A 1 "Battery Power"
Commands for Changing Power Settings
- Battery Power Settings: sudo pmset -b [setting] [value]
- AC Power Settings: sudo pmset -c [setting] [value]
Settings Breakdown
- Sleep On Power Button1: Power button press initiates sleep.0: Power button press may prompt shutdown/restart or no action.
- lowpowermode1: Enables low power mode (reduced performance, extended battery).0: Disables low power mode (optimal performance).
- standby1: Enables deep sleep state after inactivity.0: Disables deep sleep state.
- ttyskeepawake1: Keeps terminal sessions active during sleep.0: Terminal sessions may suspend.
- hibernatemode0: Hibernation disabled (RAM not written to disk).1, 2: Obsolete hibernation modes, rarely used.3: Safe Sleep (hibernation) enabled (RAM to sleepimage).
- powernap1: Allows background tasks during sleep.0: Disables background tasks during sleep.
- hibernatefile/var/vm/sleepimage: Location of hibernation file.
- displaysleep[minutes]: Display sleeps after the specified minutes.
- womp (Wake On Magic Packet)1: Allows wake from sleep via network packet.0: Disables wake from sleep via network packet.
- networkoversleep0: Disables deep network sleep (responsive network).1: Enables deep network sleep.
- sleep[minutes]: System sleeps after specified minutes, 0 disables sleep.
- lessbright1: Dims display on battery power.0: Disables display dimming.
- tcpkeepalive1: Sends TCP keepalive packets.0: Disables TCP keepalive.
- disksleep[minutes]: Disk sleeps after specified minutes, 0 disables sleep.