Skip to content

Instantly share code, notes, and snippets.

@nicdoye
Created April 18, 2017 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicdoye/eb159456e7f35abf83a15d948c04f6a1 to your computer and use it in GitHub Desktop.
Save nicdoye/eb159456e7f35abf83a15d948c04f6a1 to your computer and use it in GitHub Desktop.
Unmounting installation disks on macOS
#!/bin/bash
# IMPORTANT ASSUMPTION:
# YOU DO NOT HAVE ANY OTHER DISKS MOUNTED WITH AN `s1` PARTITION!
# A better way would be to use `diskutil list --plist` and parse the
# plist using ruby/python/javascript/your-language-of-choice
for disk in $(mount | egrep 'disk.+s1' | awk '{print $1}' | sed -e 's_^/dev/__' -e 's_s1$__')
do
diskutil eject ${disk}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment