ICloud – Photos media library on external hard drive

hard driveicloudiphotophotos

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?

Best Answer

$ 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.