6

I have a 5TB USB-C drive attached to my 16" MacBook Pro running Big Sur 11.2.3. I use this drive exclusively for Time Machine. When ejecting the drive, it takes anywhere from 90 - 120 seconds before the drive is ejected. This happens even when Time Machine is not actively backing up to the drive. A couple OSs back, I remember thinking 15 seconds was a long time to wait for a drive to eject, but now, 90+ seconds feels like forever.

What steps can I take to troubleshoot and shorten the ejection time?

Update

I plugged the drive in this morning. After letting Time Machine run, I waited for it to finish and ran the command from @jaume :

Anthony@Vincent ~ % sudo lsof +d /Volumes/LaCie.Backup
COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mds      90 root   21r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   25r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   27r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   31r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   34r   DIR   1,16      510    2 /Volumes/LaCie.Backup

I waited another 10 minutes ran the command a second time to see if mds was still using the drive and the results were the same.

While ejecting the drive, I ran the command and the output was:

Anthony@Vincent ~ % sudo lsof +d /Volumes/LaCie.Backup
lsof: WARNING -- child process 72811 may be hung.
Anthony@Vincent ~ % 

Update #2

I added the drive to Spotlight exceptions and reran the lsof command. I noticed that there are now 3 mds processes rather than 5:

Anthony@Vincent ~ % sudo lsof +d /Volumes/LaCie.Backup
COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mds      90 root   21r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   24r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   28r   DIR   1,16      510    2 /Volumes/LaCie.Backup

Right-clicking and selecting Eject from the context menu still takes quite a while to eject the drive. During that time, I ran the lsof command and received the following output:

Anthony@Vincent ~ % sudo lsof +d /Volumes/LaCie.Backup
lsof: WARNING -- child process 73283 may be hung.
COMMAND PID    USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
Finder  431 Anthony   15r   DIR    1,6      160 23740 /Volumes
Finder  431 Anthony   16r   DIR    1,6      160 23740 /Volumes

The Finder commands appeared in the results right before the drive disappeared from the desktop.

However, running diskutil unmount /dev/disk3 from Terminal ejects the drive almost immediately.

Why would Finder take so long to eject the drive? I would've thought Finder was using diskutil in the background.

Update #3 (final update)

After a reboot, Finder, diskutil, and Alfred -- the 3 ways I use to eject this drive -- all seem to work fine. My Mac also restarts and shuts down much faster.

Thank you @jaume for the constructive comments. Can a comment be marked as an answer?

Update #4 (Final, FINAL, update, post accepted answer)

A month or so on from this, I was still having slow eject times. My tests ejecting the drive were done after a reboot but before Time Machine had a chance to run.

The answer from Jaume was helpful but I don't think it solved the problem.

The drive was purchased when I was running Catalina and I don't think Catalina supported Time Machine disks formatted with APFS. Now that Big Sur does support the format, I updated the drive to APFS and the eject times are now in the 5 second range.

After numerous restarts and Time Machine backups, the disk is quickly ejecting.

Also, in Big Sur, Time Machine drives are no longer able to be added to Spotlight Privacy:

enter image description here

8
  • Do you really mean 4gb?
    – Gilby
    Apr 15, 2021 at 1:14
  • While ejecting the Time Machine hard drive, could you post the output of sudo lsof +d /Volumes/<Time Machine hard drive name>? This command lists processes that access the hard drive. To run it, open Terminal, paste the command and press Enter. Since the command uses sudo, type your password when requested.
    – jaume
    Apr 15, 2021 at 6:56
  • 1
    @jaume Post has been updated with output, thank you!
    – Anthony
    Apr 15, 2021 at 15:44
  • Thank you for posting the output, apparently the drive is being indexed by Spotlight. You could add the drive to the Spotlight exceptions: connect the drive, open System Preferences > Spotlight, select the Privacy tab, press (+) and add the drive. Could you test it ejecting is now faster?
    – jaume
    Apr 15, 2021 at 15:49
  • @jaume Added to Spotlight privacy. Noticed Finder might be causing the delay. See update #2 above. Thank you!
    – Anthony
    Apr 15, 2021 at 16:17

1 Answer 1

5

Some process (or processes) seem to be accessing the drive and preventing it from ejecting. You can list those processes with this command:

sudo lsof +d /Volumes/<Time Machine hard drive name>

which displays all running processes that are accessing the folder /Volumes/<Time Machine hard drive name>

From the information in your post, the culprit is mds:

sudo lsof +d /Volumes/LaCie.Backup
COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mds      90 root   21r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   25r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   27r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   31r   DIR   1,16      510    2 /Volumes/LaCie.Backup
mds      90 root   34r   DIR   1,16      510    2 /Volumes/LaCie.Backup

which is the metadata server used by Spotlight.

If your Time Machine disk is formatted as HFS+, you can prevent this from happening by adding it to the Spotlight exceptions:

  1. Open System Preferences > Spotlight.
  2. Select the Privacy tab.
  3. Press the + button, select the Time Machine disk and select "Choose".

You may need to reboot your Mac for changes to take effect.

Note that the you can't add a Time Machine disk formatted as APFS to the Spotlight exceptions.

6
  • Except that Spotlight doesn't allow a Time Machine drive to be added to its Privacy list.
    – Edward
    Mar 31 at 7:07
  • @Edward I've tested it and it works for me, it's even added automatically to the Privacy list. Note that when the Time Machine disk is not connected, it doesn't appear in the Privacy list.
    – jaume
    Mar 31 at 7:24
  • @jaume I am having the same issue as Edward. If I try to add the Time Machine drive to the privacy list it says you cannot add such a drive to the privacy list. This is maddening.
    – garyrob
    Jun 1 at 18:00
  • @garyrob Do you experience a delay when ejecting your backup drive, too? Reading the OP's latest comments and similar reports elsewhere (here: apple.stackexchange.com/a/386979/32815 and here: eclecticlight.co/2016/06/20/…) I'm starting to wonder whether this is related to APFS. My backup drive is formatted as HFS+. If you have a spare drive, you may want to format it as HFS+, set it up as a backup drive and see if you can add it to Spotlight's privacy list (don't forget to remove it from Time Machine afterwards).
    – jaume
    Jun 2 at 7:45
  • 1
    @jaume... yes it takes a long time to eject; that's interesting about HFS+... I don't have spare backup drive right now to test that idea with though. :( Thanks for those other references... also interesting
    – garyrob
    Jun 12 at 0:54

You must log in to answer this question.

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