What’s the difference between diskutil unmount and diskutil eject?
On macOS (eg. Mojave 10.14), what is the difference between the diskutil unmount
and diskutil eject
commands?
For example, if I want to execute this from the command line (eg. bash in terminal), but I want to have the same, ‘safe’ result as though I had clicked the eject icon in the Finder:
- which command(s) should I use (and why)?
- what are the differences and side-effects between these two?
Solution 1:
You can at least be certain that diskutil eject
does all that diskutil unmount
does, plus (sometimes) more. Examples given in the man page mention removable media readers equipped with a motor to physically eject a volume, such as a CD-ROM player. Also, when there are more than one filesystem on the media, diskutil eject
will unmount all volumes on the media, while diskutil unmount
just unmounts the one filesystem you mention explicitly.
When in doubt, I'd always go for the eject
verb.
Solution 2:
You unmount a volume, and eject a drive. For non-removable media, eject and unmount are equivalent. If the media is removable, eject tells the OS the media is to be removed and the OS releases all links to the drive. This question was asked on the apple discussion board and you can review the responses here.