Prolong lifetime of MacBook’s SSD by disabling swap and other minor tweaks

0. Prologue

After replacing 128GB SSD with a 500GB one in my 7 year-old MacBook Air, I’ve noticed a serious issue… Since 4GB RAM is very limited (and not designed) for the contemporary macOS, it runs out of memory very often especially when I opens multiple tabs in browser and edits photo in Lightroom simultaneously. It isn’t a big deal because there is swap mechanism, which stores data to disk when the (physical) memory is not enough. However, since the SSDs have finite numbers of P/E (program / erase) cycles, the more intensive the swap uses, the sooner the SSD would be worn out. The lifetime of SSD basically depends on its type of NAND flash. For the SSD I installed, WD SN750 500GB, it uses TLC NAND and declares it has 300TB-write endurance.

SMART information checked with smartmontools

Unfortunately, if the SSD is used as system disk with limited RAM, it will be worn out rapidly by the swap mechanism. For example, my MacBook with new SSD has powered on for 161 hours, and it has been written for ~663GB data(!). To tackle this issue, I should either upgrade my MacBook ($) or try to limit the usage of memory by disabling swap and doing minor tweaks.

1. Disable swap

Be careful! Disable swap would cause kernel panic if there is not enough RAM for processes. Take it at your own risk.

1.0. Disable SIP

From macOS 10.11 to present, there is a built-in system integrity protection (SIP) for preventing malicious modification. To disable swap, first we have to turn SIP off.

  1. Power-off MacBook first, hold Command (⌘) and R, and then start-up the MacBook. For M1 chip based MacBook, hold the power button until seeing “Loading startup options”.
  2. You should see a macOS utilities window.
  3. From the utilities menu, select “Terminal”
  4. Type csrutil disable and press return, the screen should display a message that SIP is already disabled.
  5. From the  menu, press restart to restart MacBook.
Select “Terminal” from the menu bar
Disable SIP via Terminal

1.1. Disable swap

To check the current mode that system manages memory, type sysctl -a vm.compressor_mode in terminal. The default mode is 4, which represents compressing memory and using swap. To disable swap, we should change the mode from 4 to 2, which means compressing memory only.

To modify vm.compressor_mode, type sudo nvram boot-args="vm_compressor=2". The mode won’t be changed until reboot. Again, anyone running computer without swap file should monitor memory usage carefully to avoid kernel panic!

Type csrutil status first to ensure that SIP is already disabled

1.2. Enable SIP (Recommended, for macOS 10.x only)

Note that this only is for macOS 10! If you are using Apple Silicon MacBook (M1) or macOS 11+, enabling SIP will also change back vm.compressor_mode to default.

After disabling swap, we should enable system integrity protection (SIP) again for security reason. The steps are similar to disabling swap, and the only difference is the command. Type csrutil enable instead to enable SIP. If you want to disable spindump furtherer (listed below), you should enable SIP later.

2. Disable unused processes

2.0. Disable spindump and tailspind

Here we use launchctl to unload two services, and rename the files.

  1. sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.spindump.plist
  2. sudo mv /System/Library/LaunchDaemons/com.apple.spindump.plist /System/Library/LaunchDaemons/com.apple.spindump.plist.bak
  3. sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.tailspind.plist
  4. sudo mv /System/Library/LaunchDaemons/com.apple.tailspind.plist /System/Library/LaunchDaemons/com.apple.tailspind.plist.bak

2.1. Disable mds_stores

mds stands for “metadata server”, which is a part of Spotlight in macOS. It indexes for all devices to provide effective search functionality. If you never use Spotlight, you could disable it for saving CPU and memory usage.

To prevent it from indexing all devices, type sudo mdutil -a -i off in terminal.

If you want to enable it again, just replace the command with sudo mdutil -a -i on.

2.2. Disable Adobe CC services

Although Adobe provide amazing products like Lightroom and Photoshop, its background services consume memory and CPU even when the Adobe-related program is not running.

The service corresponding to Adobe CC services is located at /Library/LaunchAgents/com.adobe.AdobeCreativeCloud.plist, to prevent it from auto-launching from log-in, we will use launchctl again: type launchctl unload -w /Library/LaunchAgents/com.adobe.AdobeCreativeCloud.plist in terminal.

To enable it, just replace unload with load in the command.

3. Tab suspender

If you open a lot of tabs in the browser every time like me, you should consider suspending inactive tabs while you are not browsing the website or AFK, to limit the memory usage of browser. The following method is recommended. It is risky to use third-party extensions such as The Great Suspender since it might contain malware.

Microsoft’s Edge has announced built-in “sleeping tab” feature recently (2020/09). To enable it, simply go to Settings → System → Save resources.

Furthermore, you can modify timeout to suspend the inactive and set the allow-list in the configuration page.


A. SMART monitor tools

The disk health information can be inspected with smartmontools. To use it on macOS, either install precompiled package here (download smartmontools-x.x-x.dmg one) or install via brew:

brew install smartmontools

After installing, you can run the command in Terminal.app:

smartctl -a disk0

where disk0 is the device name referring to the inspected disk. Device name can be found via Disk Utility.app:

Disk Utility.app
Device name shown in bottom right corner.

Device information such as serial number, temperature, bytes written and read will be shown in the terminal. Note that some NVMe admin commands are not supported currently via smartctl, therefore some detailed NVMe information will not be shown correctly.

View Comments (4)

  • Followed steps 1.0 to 1.2 on big sur, it seems that the `vm.compressor_mode` setting has been rolled back. Any suggestions?

    • Hello Alex, did you check the SIP status (csrutil status) before change the vm.compressor_mode? Also the mode won't be changed until reboot. If there is any question, please let me know.

    • Update: After testing on a M1 MacBook, I got the problem as you stated :(. The vm.compressor_mode can be altered successfully until re-enabling SIP. Not sure if this is another feature to secure the system or not. Same problem here.

  • As of macOS Monterey 12.2.1, vm.compressor_mode reflects boot-args=vm_compressor=2 on my older intel macbook pro (early 2015) with SIP enabled. OTOH, for my newer m1 macbook pro (2020), vm.compressor_mode reverts back to 4 with SIP enabled. However it does return vm.compressor_mode: 2 with SIP disabled. I could see why Apple wants to clear boot-args with SIP enabled to ensure security. But I'd hope they could whitelist a few flags like vm_compressor eventually.

Related Post