# com.startup.sysctl.plist As of at least macOS Catalina 10.15.3, `/etc/sysctl.conf` values are no longer respected and/or the file straight up doesn't exist (confirmed on macOS Monterey 12.4.) Ran across a `fio` shm error: `failed to setup shm segment` while benchmarking SSDs. The fix was to set `shmmni` to `4096`. The following has to happen: * [Disable SIP](https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection) * **Disclaimer from Apple** > Warning > > Disable SIP only temporarily to perform necessary tasks, and reenable it as soon as possible. Failure to reenable SIP when you are done testing leaves your computer vulnerable to malicious code. * Download `com.startup.sysctl.plist` * Move to `/Library/LaunchDaemons/com.startup.sysctl.plist` * Load the PLIST after a few housekeeping items ```bash # sanity check sysctl -a | grep shm # set permissions sudo chown root:wheel /Library/LaunchDaemons/com.startup.sysctl.plist # validate key-value pairs plutil /Library/LaunchDaemons/com.startup.sysctl.plist # load plist sudo launchctl bootstrap system /Library/LaunchDaemons/com.startup.sysctl.plist # check logs tail -f /tmp/sysctl.out tail -f /tmp/sysctl.err # recheck sysctl values sysctl -a | grep shm ``` * If the `shmmni` or other values didn't change, a reboot is in order * Known good output when values are changed successfully ``` λ tail -f /tmp/sysctl.out kern.sysv.shmmax: 4194304 -> 4194304 kern.sysv.shmmin: 1 -> 1 kern.sysv.shmmni: 32 -> 4096 kern.sysv.shmseg: 8 -> 8 kern.sysv.shmall: 1024 -> 1024 λ sysctl -a | grep shm kern.sysv.shmmax: 4194304 kern.sysv.shmmin: 1 kern.sysv.shmmni: 4096 kern.sysv.shmseg: 8 kern.sysv.shmall: 1024 security.mac.posixshm_enforce: 1 security.mac.sysvshm_enforce: 1 ``` ## Sources [macos - Values from sysctl -A don't match /etc/sysctl.conf even after restart - Unix & Linux Stack Exchange](https://unix.stackexchange.com/questions/689295/values-from-sysctl-a-dont-match-etc-sysctl-conf-even-after-restart) [Setting shared memory in Catalina | Apple Developer Forums](https://developer.apple.com/forums/thread/669625) [c++ - Shared memory "Too many open files" but ipcs doesn't show many allocations - Stack Overflow](https://stackoverflow.com/questions/70988547/shared-memory-too-many-open-files-but-ipcs-doesnt-show-many-allocations) [kernel - How do I increase the max open files in macOS Big Sur? - Super User](https://superuser.com/questions/1634286/how-do-i-increase-the-max-open-files-in-macos-big-sur) [A launchd Tutorial](https://www.launchd.info/) [macos - Values from sysctl -A don't match /etc/sysctl.conf even after restart - Unix & Linux Stack Exchange](https://unix.stackexchange.com/questions/689295/values-from-sysctl-a-dont-match-etc-sysctl-conf-even-after-restart/710645) [macos - "No space left on drive" when trying to allocate more shared memory - Stack Overflow](https://stackoverflow.com/questions/70884304/no-space-left-on-drive-when-trying-to-allocate-more-shared-memory/73058877)