2

I moved my Photos media library to an external hard drive. Everything works fine except the ejection of the hard drive. Everytime I try to eject it my Mac says that it is in use:

$ sudo lsof +D "/Volumes/[Drive]
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
mds        86 root   18r   DIR    1,9      544      2 /Volumes/[Drive]
mds        86 root   20r   DIR    1,9      544      2 /Volumes/[Drive]
mds        86 root   22r   DIR    1,9      544      2 /Volumes/[Drive]
photoanal 608 xxxx  txt    REG    1,9    32768 653409 /Volumes/[Drive]/Pictures/Fotos.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db-shm
photoanal 608 xxxx   27u   REG    1,9  8323072 653402 /Volumes/[Drive]/Pictures/Fotos.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db
photoanal 608 xxxx   28u   REG    1,9   214272 653408 /Volumes/[Drive]/Pictures/Fotos.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db-wal
photoanal 608 xxxx   29u   REG    1,9    32768 653409 /Volumes/[Drive]/Pictures/Fotos.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db-shm

I use iCloud to sync my photos with my iPhone. It is not important that the photos are on my Mac immediately. I also would be okay with starting Photos from time to time.

Is there a way to eject the hard drive without shutting down?

  • Do you have any other applications that could use the drive? For example, my photo library is located on an SD card. I couldn't eject it until I stopped Google Drive that was also using the SD card to sync with my data from Google. – Jules Oct 20 '17 at 12:17
  • No, it is only the photoanalysis process which hinders me from ejecting the drive. – Elastic Lamb Oct 20 '17 at 17:51
2
$ launchctl kill -TERM gui/$UID/com.apple.photoanalysisd

This command will stop the current instance of the photoanalysis daemon. Afterwards it is possible to eject the hard drive without any problems.

  • How do you reenable photoanalysis? – Scott Walter Nov 19 '17 at 15:38
  • After a reboot the service is restarted automatically. I do not know a command to restart the service manually. For me it is fine if it runs once a week. – Elastic Lamb Nov 19 '17 at 16:08
0

You have a program that is/was using the hard drive.

You could try ejecting it using Disc Utility.

Logging out should also always work, although the only programs that get terminated are the ones in the user account that is logged out.

If you don't want to log out, quit any apps you are no longer using.

Mac Mail is notorious for hanging onto files that have been attached to emails. If you attached a file from an external disk, Mail might not have let it go. Quitting Mail solves this problem.

The Finder sometimes doesn't let go of files either, like after you do a QuickLook on a file. Normally you can't quit the Finder except using Activity Monitor (Utilities folder) and also check and see what programs are open that may be using it.

  • Sorry, but that does not answer my question. Thanks anyway! – Elastic Lamb Oct 19 '17 at 9:12
  • The question was "Is there a way to eject the hard drive without shutting down?" Have you tried any of the options that I offered? – Melvin Jefferson Oct 19 '17 at 16:44
  • 1
    Sorry for the ambiguous wording! The only problem is with the photo analysis process which starts after I mount the drive. That is, I think so, because the Photos Library on the hard drive is my system mediathek. If the photoanalysis does not run I can eject the hard drive immediately. – Elastic Lamb Oct 20 '17 at 17:57
  • Understood. Thanks for the clarity. Try these two options out (lets hope you don't need to use terminal) and see if they help disable that feature for you. idownloadblog.com/2015/12/28/how-to-stop-photos-mac-auto-launch – Melvin Jefferson Oct 20 '17 at 18:14
0

It might be that your Finder is still indexing those files that you have in your hardisk.

  1. Try quit Photos application first
  2. Switch off hardisk indexing for finder sudo mdutil -Ei off "/Volumes/Name_of_Drive"
  • The finder is not indexing any files anymore. I already disabled that service with mdutil. Qutting Photos application will not have an effect because the background processes run only if the application is not running. – Elastic Lamb Oct 20 '17 at 17:53
0

just type in the following command:

kill [PID of photoanal] (in your case the PID was "608")

That should terminate the photoanal process

mds is part of spotlight, it stands for "metadata server" I believe. It might be indexing your drive so I don't know how dangerous it is the terminate it as well.

Once you have terminated all processes using your drive you can then easily eject it (the following command should return nothing: lsof | grep 'name of your drive').

My photos library has been on my external drive for over 1 year and I have only recently started to experience the same issue that you described. This is what solved it for me. (I'm running macOS 10.13)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .