Automatic Ejecting of External Drives

I have a series of USB external drives that I hook up to my computer via a hub (Carbon Copy Cloner drive, TimeMachine Drive, other Documents and Media Drive, etc.)

Is there a way to eject all of them in one action and not having to eject them one by one?

I know you could do it by bash script. Just put the link on your bottom bar and they would all get ejected. A simple check and visual feedback would confirm the process completed.


I’ve never heard of a program that does it, but it occurs to me that if you are shutting the computer down anyway, you could wait until that finishes before unplugging the drives.

1 Like

I am not shutting down. I just need to move to another place… say living room from bedroom.

Do you know of a resource that could show how to do this?

Over the years I’ve come across so many examples of data corruptions caused by delayed writes failing because of USB drives being disconnected (sometimes even after using the Windows disconnect utility) that I only disconnect them now after power-down. Defeatist I know, but I can’t afford the risk.

Bash scripting is rather easy, even on a Mac (though a little different from Linux). The biggest parts are that you can stack commands in the command line with the semicolon and the unmount command is diskutil unmount /Volumes/<name_of_drive_1>; diskutil unmount /Volumes/<name_of_drive_2>.

You can change unmount to eject to fully remove the drive from the system. Unmount is nice as it allows you to remount the drive without having to unplug and replug the drive. However, if you are going to unplug it anyways, just use eject. I linked to some resources below.

General unmounting:

Making a bash script on Mac:

Making a nice pop-up notice when done:

Warning: Bash scripting and automation is easy, fun, and rewarding. You may just find that you start doing a lot of things with it and are sucked into the blackhole that is automation. Just wait until you start putting them in cron. Also if you do start making a bunch, get a Github/GitLab account and save them; makes it easier to move to another machine.

1 Like