Skip to content

Instantly share code, notes, and snippets.

@MauricioKruijer
Created November 24, 2017 09:57
Show Gist options
  • Save MauricioKruijer/a988e2cb12d86e27228c48885c03daf8 to your computer and use it in GitHub Desktop.
Save MauricioKruijer/a988e2cb12d86e27228c48885c03daf8 to your computer and use it in GitHub Desktop.
Unmount volumes with macOS installed

Unmount volumes that contain a macOS installation

For testint purposes I have a few partitions with a clean install of macOS, these partitions contain applications I use daily. Somtimes spotlight starts applications from that volume.. that is just super annoying I use this script to unmount them after start up.

Installation

You just have to move these files

mv nl.mauriciokruijer.unmountvolumes.plist ~/Library/LaunchDeamons/
sudo mv unmountVolumes.sh /usr/local/bin/
<?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>nl.mauriciokruijer.unmountvolumes</string>
<key>LaunchOnlyOnce</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>/usr/local/bin/unmountVolumes.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
#!/bin/sh
volumes=("Rescue" "10.12 Omni test" "10.13 Omni test" "Base 10.12" "Base 10.13")
for i in "${volumes[@]}" ; do
volume="/Volumes/$i"
if [ -d "${volume}" ]
then hdiutil unmount "${volume}" -force
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment