Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kandj39

macrumors newbie
Original poster
Apr 5, 2025
3
0
My main Photos library is stored on my internal drive, while I have several Photo libraries on an external drive. (I switch between them when opening using the option key.). However, when I want to eject my external drive (a 40gbs Acasis enclosure with a WD 2TB SSD) I get a message that it cannot be ejected because "one or more programs may be using it". I have switched the Photos program back to the main System Photos Library located on my internal drive. The Photos program is closed. Note that the external SSD only has Photos libraries on it, nothing else.

Looking online I noticed comments that you must leave it plugged in for some time for facial recognition, indexing, etc. to complete. It has been plugged in for many days, so this should not be an issue. I have also read that it could be caught up in Spotlight Search indexing. But that doesn't seem logical.

Anyway, looking for a way to eject the external disk without "Force Eject". Any solutions?
 
Have you tried quitting Photos (assuming it's open), and then ejecting the drive?

Have you tried logging out, then logging back in, and then ejecting the drive?

Have you tried SHUTTING DOWN the Mac -- all the way off -- and then physically disconnecting the drive?
 
Have you tried quitting Photos (assuming it's open), and then ejecting the drive?

Unfortunately that doesn't usually work -- especially with older versions of macOS/Photos (haven't tried with the latest).

Have you tried logging out, then logging back in, and then ejecting the drive?

That really should work but it still often doesn't with older versions of macOS/Photos.

Note this issue has been discussed before:

Have you tried SHUTTING DOWN the Mac -- all the way off -- and then physically disconnecting the drive?

That will definitely work!

But really shouldn't be necessary with a proper OS and applications.

Note some fixes in Sequoia around *related* issues:

Can't say whether upgrading to Sequoia would address this issue and/or Sequoia's own issues would just make things worse...
 
Have you tried quitting Photos (assuming it's open), and then ejecting the drive?

Have you tried logging out, then logging back in, and then ejecting the drive?

Have you tried SHUTTING DOWN the Mac -- all the way off -- and then physically disconnecting the drive?
Thanks for the response.

1) I have quit the Photos app and this does not work;
2) Logging in and out does not work;
3) Turning the computer off and disconnecting DOES work, but not I don't really want to turn my iMac off each time;

I should note that I am on the most current operating system and running a Mac mini M2 Pro.

Also, if I have the external disk connected, but have not opened any of the photo libraries, the disk will eject with no issue.
 
Unfortunately that doesn't usually work -- especially with older versions of macOS/Photos (haven't tried with the latest).



That really should work but it still often doesn't with older versions of macOS/Photos.

Note this issue has been discussed before:



That will definitely work!

But really shouldn't be necessary with a proper OS and applications.

Note some fixes in Sequoia around *related* issues:

Can't say whether upgrading to Sequoia would address this issue and/or Sequoia's own issues would just make things worse...
Thanks for the response. I am on Sequoia 15.4, which is the most current update. I looked through the previous post, which is somewhat related, but seems to be questioning several other things. It is not the drive, as I have tested other enclosures and SSD's. I have turned Spotlight off, etc. and that doesn't work either.

I should also note that I have other drives that I can eject with no issues (just the one with Photo libraries, and if I have opened one of them).
 
I created a Shortcut that:
1. Quits Photos
2. Uses a bash script to find all the processes using my external drive. It tries to quit them gracefully and then force quits them if they ignore the request.
3. Ejects the disk

It seems to work pretty consistently, if a bit slowly. If you wanted to speed it up you could update the bash script to force quit immediately, but I like giving it time to exit gracefully if it can. Make sure you run the script as an administrator.

Here's the script:

#!/bin/bash
pids=$(lsof -t +D "/Volumes/YOUR DRIVE NAME HERE/")
# Loop through each PID
for pid in $pids
do
# Send SIGTERM (-15) to the process
kill -15 $pid

# Wait for 5 seconds to give the process a chance to terminate gracefully
sleep 5

# Check if the process is still running
if ps -p $pid > /dev/null; then
# Send SIGKILL (-9) to forcefully terminate the process
kill -9 $pid
fi
done

Here's my Shortcut:
eject photos library.png


You can use the Shortcuts app to add it to the Dock or to the menu bar, if you'd like.
 
  • Like
Reactions: Slartibart
Thanks for the response. I am on Sequoia 15.4, which is the most current update. I looked through the previous post, which is somewhat related, but seems to be questioning several other things. It is not the drive, as I have tested other enclosures and SSD's. I have turned Spotlight off, etc. and that doesn't work either.

Agree, there was a contingent on that thread that wanted to blame the drive rather than macOS/Photos but I don't think it is a drive issue. I think Apple's current developers don't understand the UNIX philosophy on which macOS was originally built/designed and don't write software that is robust outside a narrow range of configurations.

I should also note that I have other drives that I can eject with no issues (just the one with Photo libraries, and if I have opened one of them).

Yes, once Photos and friends gets going on your Photos library it doesn't want to let go. Then I take from your post that the issue is not fixed with the latest macOS...
 
  • Like
Reactions: _Mitchan1999
I created a Shortcut that:
1. Quits Photos
2. Uses a bash script to find all the processes using my external drive. It tries to quit them gracefully and then force quits them if they ignore the request.
3. Ejects the disk

Thanks for sharing your script and solution with the Macrumors audience as that may be useful for others in similiar situation.

Just note however that I don't think what you are doing is much different than the builtin Force Eject. Force Eject may not give the processes quite the grace period you do but otherwise I believe it also tries to kill all the processes using a volume/filesystem before unmounting it.

One other alternative if you don't need all the object/facial recognition, etc would be to disable those various processes from starting in the first place.
 
I created a Shortcut that:
1. Quits Photos
2. Uses a bash script to find all the processes using my external drive. It tries to quit them gracefully and then force quits them if they ignore the request.
3. Ejects the disk

It seems to work pretty consistently, if a bit slowly. If you wanted to speed it up you could update the bash script to force quit immediately, but I like giving it time to exit gracefully if it can. Make sure you run the script as an administrator.

Here's the script:

#!/bin/bash
pids=$(lsof -t +D "/Volumes/YOUR DRIVE NAME HERE/")
# Loop through each PID
for pid in $pids
do
# Send SIGTERM (-15) to the process
kill -15 $pid

# Wait for 5 seconds to give the process a chance to terminate gracefully
sleep 5

# Check if the process is still running
if ps -p $pid > /dev/null; then
# Send SIGKILL (-9) to forcefully terminate the process
kill -9 $pid
fi
done

Here's my Shortcut:
View attachment 2499571

You can use the Shortcuts app to add it to the Dock or to the menu bar, if you'd like.
I think you can improve the elapsed time substantially with a bit of refactoring.

It's not necessary to wait 5 seconds per killed process. You can send all of them a kill -15, then wait a single 5-sec interval, then go thru all the pids again and send the kill -9 to any that remain. This changes the overall elapsed time from pid_count * 5 secs to essentially 5 secs, assuming it takes a negligible amount of time to issue each series of kills.
 
Here's my Shortcut:
Any particular reason for using the Eject action and not diskutil unmountDisk/diskutil eject?

One other alternative if you don't need all the object/facial recognition, etc would be to disable those various processes from starting in the first place.

Disabling mediaanalysisd, photoanalysisd and photolibraryd discussed here https://forums.macrumors.com/threads/mediaanalysisd-photoanalysisd-and-photolibraryd.2445597/
 
  • Like
Reactions: bzgnyc2
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.