Mac – What’s the difference between diskutil unmount and diskutil eject

command linemac

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?

Best Answer

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.