Skip to content

Instantly share code, notes, and snippets.

@shrop
Created July 18, 2012 19:12
Show Gist options
  • Save shrop/3138171 to your computer and use it in GitHub Desktop.
Save shrop/3138171 to your computer and use it in GitHub Desktop.
Script to unmount or mount a disk in OS X (Change /dev/disk1 to match the disk needed)
#!/bin/bash
DISKINFO=`diskutil info /dev/disk1s2 | grep 'Mounted: No'`
if [ -n "$DISKINFO" ] ; then
diskutil mountDisk /dev/disk1
else
diskutil unmountDisk /dev/disk1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment