Rui Aureliano
Rui Aureliano

Rui Aureliano

๐Ÿคฏ Unmount volume on launch

Rui Aureliano's photo
Rui Aureliano
ยทJun 24, 2022ยท

1 min read

So here is my setup, I have 2 volumes (macOS Monterey and macOS Ventura), and my goal is to have just the required volume for each macOS


So when launching macOS Monterey I just want the macOS Ventura volume unmounted.

1) Using diskutil it's very easy to force unmount a volume.

diskutil unmountDisk force /Volumes/macOS\ Ventura

2) Let's create a Launch Agent plist file at $HOME/Library/LaunchAgents and we will call it com.ruiaureliano.unmount.plist.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

        <true />






4) Let's create the that will be executed on launch, it should be placed on WorkingDirectory that we defined on the list, in my case /Users/ruiaureliano/

echo "macOS ventura unmount"
/usr/sbin/diskutil unmountDisk force /Volumes/macOS\ Ventura

3) Now we just load the plist file using launchctl tool.

 launchctl load $HOME/Library/LaunchAgents/com.ruiaureliano.unmount.plist

If we need to unload

 launchctl unload $HOME/Library/LaunchAgents/com.ruiaureliano.unmount.plist

Restart your Mac and voila ๐Ÿง™โ€โ™‚๏ธ๐Ÿง™โ€โ™‚๏ธ๐Ÿง™โ€โ™‚๏ธ

Share this