is there a way to eject all external hard drives from the command line? (OS X)

前端 未结 5 699
刺人心
刺人心 2021-02-07 13:41

Is there a way to eject all the mounted hard drive volumes on an OS X computer from the command line? Applescript is OK if I can wrap that in a shell script.

5条回答
  •  爱一瞬间的悲伤
    2021-02-07 14:43

    In Terminal try:

    • umount -a (All the filesystems described via getfsent(3) are unmounted.)
    • umount -A (All the currently mounted filesystems except the root unmounted.)

    Fore more information see man umount.

    Update:

    Seems like you can also use this:

    diskutil unmountDisk /dev/disk*
    

    Didn't test it, though. If it doesn't work, try to use "unmount" instead of "unmountDisk".

    Oh, I also found the eject argument (instead of unmountDisk). That might also be of interest.

    Update 2:

    diskutil eject /dev/* seems what you are looking for (see comments).

提交回复
热议问题