Thursday, February 16, 2023

Ejecting External Disks With macOS 13

Howard Oakley:

Among the rough edges in macOS is that infuriating message you may see when you try to eject or unmount a volume: it failed because the volume is in use.

[…]

In Disk Utility, the answer seems to be to try again, several times if necessary. It’s unusual for this not to work at all, although it may take a couple of attempts.

[…]

My personal favourite of them all is Sloth, from here. Although it’s not notarized, it does everything that I’d want in terms of matching lsof or fuser’s features. Most importantly, if you click its padlock at the lower right and authenticate, it will show all processes running as root.

This has been happening a lot for me since Catalina. Typically, I don’t get an error message at all—it just doesn’t eject.

The bigger problem is that sometimes Finder does show that it ejected, but then when I switch off the drive I get a warning saying that I ejected a drive that was still in use.

Aristotle Pagaltzis:

Ever since upgrading to a recent Mac that came with the disk formatted with AFPS, a perennial irritation has been Time Machine. I use a USB hard drive for backups, which of course needs unplugging when I want to take the machine with me somewhere. There are long stretches of time when I don’t even think about this because it works just fine. And then there are the other stretches of time when this has been impossible: clicking the eject button in Finder does nothing for a few ponderous moments and then shows a force eject dialog.

[…]

Unfortunately when this happens, there is no help for it: even closing all applications does not stop the mystery program from using it. So what is the program which is using the disk? The Spotlight indexer, it turns out.

There doesn’t seem to be a way to get Spotlight to stop, other than to kill the mds process and then try to unmount the drive before it respawns. I’m not keen on doing that, though, because I don’t want to corrupt the index file. It’s not that I want to be able to search my Time Machine backup—I wish I could disable indexing on that volume entirely—but that, with a damaged index file, indexing may keep running continuously.

Pierre Igot:

None of its volumes is currently mounted.

None of its files is currently open anywhere.

Yet somehow the disk is “in use” and cannot be safely ejected.

David Bureš:

I don’t know what it is with the recent releases of macOS and disks, but it’s been a complete disaster.

macOS would not unlock one of my encrypted drives. Just that single one. I even had to write a script to automatically unlock it when it got mounted, because it was juch a pain in the ass. And then one day, it fixed itself and never happened again.

Now, one of my drives just refuses to get mounted, which completely freezes the entire OS.

I have seen these behaviors, too.

Previously:

Update (2023-02-21): Drew:

The culprit is always QuickLook for me.

If you run a lsof /Volumes/MY_DRIVE you should see a bunch of QuickLook processes.

Issuing a killall -KILL QuickLookUIService should allow it to immediately be ejected.

This just happened to me shortly after reading this post. The Quick Look process in question was for a file I had previewed about 12 hours earlier.

2 Comments RSS · Twitter · Mastodon

The best application identify culprit to force quit it and fix the message "The disk… wasn't ejected because one or more programs may be using it” is "What's Keeping Me?"
https://www.macupdate.com/app/mac/27807/whats-keeping-me

Unfortunately, it has been discontinued. Hopefully someone could continue its development.

When Force Eject doesn't, and you reallyrealy need to, shutting down the computer will "eject" the rive...a crude, but effective, solution.

I connect a USB, APFS-formatted Time Machine drive only to do a once-per-day backup. There's usually only a few GB to back up, but the drive light continues to go crazy for an hour or more: Spotlight. I gave up on trying to eject the drive because of the Force Quit dialogs that won't, and don't try killing mds* or shutting down the computer because the next time the drive is connected, Spotlight would just restart indexing where it left off. So, I do my TM backup when I make and eat dinner, and try to jump up and eject the drive before another TM backup starts. Yes, Apple, I plan my life around my Time Machine backups.

Ever since I updated to Monterey, not being able to eject a USB-attached drive sometimes happens with my APFS-formatted Carbon Copy Cloner drives. I run the backup and quit CCC, and if the drive light is still going nuts, run lsof, which reports that Finder, and only Finder, is accessing the drive. Running lsof again a minute later again reports only Finder, accessing different files. What? Why is Finder rooting around in my CCC backups? If I'm in a hurry, I'll restart Finder, which usually causes it to let go; if restarting Finder doesn't, and I'm in a hurry, I'll shut down the computer. Else I just watch and shake my head.

I am assuming that restarting Finder or shutting down issues some sort of Super-I'm-Not-Kidding-Eject-All-Drives-Now command and this happens cleanly...

Leave a Comment