Is it possible to add the noatime mount option to /System/Volumes/Data?

I run a server farm of Mac minis. For performance and SSD-longevity reasons, I have (≤ Mojave) partitioned the SSD in APFS and mounted the new partition with the noatime option, and confine builds to that partition. Now that Catalina and beyond have the /System/Volumes/Data partition as part of the OS, I am wondering if there is a way to enable the noatime option for that partition without digging into /etc/fstab, i.e. in an Apple-sanctioned way.


Solution 1:

Yes, I could add the noatime mount option to the /System/Volumes/Data partition in a persistent fashion with a launchd daemon. This worked for me on macOS Catalina, Big Sur and Monterey.

I created a /Library/LaunchDaemons/local.noatime.plist file with this 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">
<!-- Install: copy to /Library/LaunchDaemons/, chown root:wheel and chmod 644 -->
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>local.noatime</string>
    <key>ProgramArguments</key>
    <array>
      <string>/bin/bash</string>
      <string>-c</string>
      <!-- first get the current mount options to see if there are any default options that we missed to provide here -->
      <!-- as mount overwrites the default options except the ones it reads out from the filesystem table -->
      <string>mnt=/System/Volumes/Data; mount | grep -F " $mnt "; mount -vuwo nobrowse,noatime "$mnt"</string>
    </array>
    <!-- launchd appends the output to the log file so write it to /tmp that is removed on each reboot -->
    <key>StandardOutPath</key>
    <string>/tmp/noatime.log</string>
    <key>StandardErrorPath</key>
    <string>/tmp/noatime.log</string>
    <key>RunAtLoad</key>
    <true/>
    <key>LaunchOnlyOnce</key>
    <true/>
    <key>KeepAlive</key>
    <false/>
  </dict>
</plist>

You could pick whatever LaunchDaemon name you would like instead of local.noatime that does not exists yet, but I think the Label in the config and the filename (without the .plist extension) must be the same.

Normally, this LaunchDaemon will start on each boot so it will add the noatime flag after a reboot.

But I see that you have a server farm and I guess a reboot for all those machines is not ideal, so you could manually trigger the daemon without a reboot:

sudo launchctl bootstrap system /Library/LaunchDaemons/local.noatime.plist

If you check the log file you should see sth like this:

cat /tmp/noatime.log
/dev/disk3s1 on /System/Volumes/Data (apfs, local, journaled, nobrowse)
/dev/disk3s1 on /System/Volumes/Data (apfs, local, journaled, noatime, nobrowse)

The first line contains the original mount options and the second line the new ones. I think its a good idea to keep around the original mount options in case Apple adds some other default options beside nobrowse (the other options are auto-added from the file system table) as I didn't find a way to append the noatime option without removing the previous mount options. With that said use this at your own risk.