Mac: Un-mount a Hard Drive using Command Line
Have you ever wanted to un-mount your hard drive from Terminal on your Mac? Probably not. Well guess what? I’m going to show you anyway. I had a hard drive plugged in to my iMac at home and thought it was making my computer crash. I wasn’t at home so I had to SSH in and un-mount it by using command line. I ended up having to use diskutil (disk utility).
Usage: diskutil u[n]mount [force] MountPoint|DiskIdentifier|DeviceNode
I first had to find out the full path name of the drive I wanted to un-mount. You can do this by typing df (disk free).
Example
# df
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/disk0s2 487725344 77926824 409286520 16% /
devfs 218 218 0 100% /dev
map -hosts 0 0 0 100% /net
map auto_home 0 0 0 100% /home
/dev/disk1s2 1951479728 126652704 1824827024 7% /Volumes/Time Machine Backups
I want to un-mount /Volumes/Time Machine Backups.
All I have to do is type diskutil unmount
Example
# diskutil unmount /Volumes/Time\ Machine\ Backups/
Volume Time Machine Backups on disk1s2 unmounted
As you can see, /Volumes/Time Machine Backups is no longer mounted.
# df
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/disk0s2 487725344 77926824 409286520 16% /
devfs 218 218 0 100% /dev
map -hosts 0 0 0 100% /net
map auto_home 0 0 0 100% /home