Ejecting external drives in macOS 11 “Big Sur”

Does anyone have problems ejecting/disconnecting external USB drives with macOS 11 “Big Sur”, e.g. your Time Machine drive? – You are not alone. … I don’t have a real solution for you, but a viable workaround.

(Originally published by me earlier to day at forum.macrumors.com.)

I skipped macOS 10.15 “Catalina” (because I wanted to be able to run 32-bit software) and went straight from 10.14 “Mojave” to 11.0 “Big Sur”. One of the major annoyances that I experienced right away and up until (at the time of writing this blog post) also macOS 11.1: External drives, which could be my Time Machine drive or some other external drive, take forever to eject; and during that period, my desktop pretty much freezes.

A suggested solution in above mentioned MacRumors forum discussion by user 55 in post #7 is: Don’t eject the drive by right-clicking the volume and then clicking „Eject“ (and neither by dragging the volume to the trash can – yes, some people still do that), but by opening the Disk Utility app and ejecting the entire drive, not just the respective volume. Like so:

And indeed – that seems to work, yay! … Oh-kay, that’s a workaround, but that ain’t convenient.

But then I remembered: Back in the day (probably with High Sierra, I can’t really remember) I had a different drive ejecting issue which required to carry out the exact same stunt (if you must know why: to help ejected disks to actually spin down, which they often didn’t).

Being a programmer, what I did back then was: I created a tiny Python script that resides on my desktop and ejects the (first) external drive (it finds).

Caveat: You need to have the Python interpreter installed on your computer, which should be the case on pretty much any new Mac. Otherwise, Homebrew is your friend.

This is what the script looks like:

#!/usr/bin/python

import os,re

diskUtilList = os.popen('diskutil list').read()
diskUtilList = diskUtilList.replace("\n", " ")

externalPhysicalRegEx = r".*\/dev\/(disk(?:\d+)) \(external\, physical\).*"

match = re.match(externalPhysicalRegEx, diskUtilList)
if match:
    print "Ejecting " + match.group(1) + " ..."
    os.popen('diskutil eject '+match.group(1))

It first gets a list of all available drives with „diskutil list“, puts them all together in one line, and then it finds the first external, physical drive that is available. … That regular expression is dark magic, as always. Here be dragons. If there is such a drive, it ejects it with „diskutil eject“.

… For your convenience, I attached named Python script for easy download to this blog post:

However, if you prefer to not download script files from the interwebs but edit them yourself on your local computer (Kudos! Good for you!):

Start by putting what you copy & paste from above into TextEdit after setting it to plain text by hitting Shift/Cmd-T. Save the file somewhere in your home directory, perhaps under „Documents“, and name it „EjectTimeMachine.py.command“ („.command“ to be able to double click it from Finder, „.py“ to indicate that it’s a Python script).

Now open a Terminal window and type "chmod a+x " without the quotation marks, but including the blank character “ ” at the and – but don’t hit the Enter key just yet.
Now drag the „EjectTimeMachine.py.command“ file icon from the Finder into your Terminal window. — Yes, you read that correctly: The file won’t actually be moved, but the file name including its path will be added to the command line.

It should look similar to this:

chmod a+x /Users/yourname/Documents/EjectTimeMachine.py.command

… depending on what your user name is and where you stored that file. — Now hit Enter. This will make this file executable for „all“ – hence the code „a+x“ („all plus eXecute“).

To create a shortcut of it on your desktop, proceed as follows: Drag the file icon from wherever you stored it to your desktop while holding the Alt/Command keys down. This will create a shortcut on your desktop, while the actual file remains wherever you stored it. … You may rename the shortcut to whatever comes to your mind, e.g. „Eject Time Machine“. … Like shown at the top of this blog post:

Please note: This will work only if you have just one external physical drive, or if the Time Machine drive is the first one that it finds. If that’s not what you are looking for, find a programmer who can modify my Python script to suit your needs.

Keine Kommentare möglich.