Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can't Eject Disk Because OS X Apps are Using It (Safari, Mail, Calendar, etc.)?

Hey Apple Support Communities,


I've been told this question has been asked somewhere here before, but I couldn't find it. I have many times been unable to eject an extenal hard drive because OS X tells me that an app that should have no business using the app (such as Safari, Mail, Calendar, etc.) is using it. I've tried closing windows and such, but I can only solve it if I quit out of the app. Has anyone else experienced this, or better yet: does anyone know how to make it stop? This has happened on two of my MacBook Pros (original unibody and retina, both 15") running versions of OS X from Snow Leopard to Mountain Lion. I'm at a loss, and kinda fed up with the stupid glitch/setting that causes this...

MacBook Pro with Retina display, OS X Mountain Lion (10.8.4)

Posted on Jun 11, 2013 1:27 PM

Reply
16 replies

Jun 11, 2013 2:04 PM in response to JimMoriarty

The only way to clear open files is to quit the corresponding application or have it close and clear the files. Are you purposefully opening files from this drive in these programs?


If it happens again, open the Terminal utility and run the following command:


diskutil list


In the output of this command, make note of the disk identifier for your external drive (something like disk1 or disk2), and then use it in the following command:


sudo lsof /dev/disk1


This will output all the files that are currently open on that drive, and show you what program has them open. If you cannot figure out what the output means, copy and paste the output to a reply here.

Jun 11, 2013 8:15 PM in response to Topher Kessler

Thank you, yes my issue is that I can't even thin of what would be in use by the said applications. Im not overly proficient in Terminal, and often worry that I'd do more damage in there than good. As I've said, I can have a fairly dormant instance of the application (such as Safari's default "Top Sites" window) and this still occurs. It's been driving me insane for a couple of years, and with my current schedule and need for swapping drives as often as I do, I'm finally at a breaking point.

Jun 11, 2013 8:38 PM in response to JimMoriarty

The Terminal may seem intimidating, but can be very useful. In this case, the first command I mentioned previously lists your attached hard drives:


diskutil list


The output of this will look like a small table, with the right-hand column being a list of device identifiers that will be something like "disk1" or "disk2." For each of these you will see similar ones that end with "s1" "s2" "s3," etc., which represent the various partitions on the drive.


Last login: Tue Jun 11 17:44:52 on ttys001

Tophers-Laptop:~ tkessler$ diskutil list

/dev/disk0

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *500.3 GB disk0

1: EFI EFI 209.7 MB disk0s1

2: Apple_HFS Macintosh HD 499.4 GB disk0s2

3: Apple_Boot Recovery HD 650.0 MB disk0s3

/dev/disk2

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *1.5 TB disk2

1: EFI EFI 209.7 MB disk2s1

2: Apple_HFS Time Machine Backups 1.5 TB disk2s2

/dev/disk3

#: TYPE NAME SIZE IDENTIFIER

0: FDisk_partition_scheme *7.7 GB disk3

1: Windows_NTFS TEST 7.7 GB disk3s1


In the list, you can see the "NAME" column where you can find the name of your external drive, and if you follow over to the right you can see the corresponding identifier for it. For example, here the third device "disk3" has a single partition "disk3s1" which is a Windows NTFS partition that is named TEST.


To list the open files on this drive, you would use the "lsof" command (which means LiSt Open Files), and run it in the following way so it only shows the open files on the drive (you will have to supply your password at the prompt, but as you can see below it does not show when you type it):


sudo lsof /dev/disk3


Last login: Tue Jun 11 20:32:44 on ttys003

Tophers-Laptop:~ tkessler$ sudo lsof /dev/disk3

Password:

Tophers-Laptop:~ tkessler$






















In this case, there are no open files since after entering the password the Terminal drops back to the command prompt without listing any files.


In your case, if there are any files listed, select and copy the listing from the Terminal and paste it into a reply here so we can see what they are and what applications are involved with each.

Feb 19, 2014 11:42 AM in response to Topher Kessler

I get this all the time and it's a massive pain in the neck! In my case, it's an encrypted disk image. Like the OP, OSX tells me it can't eject since safari (or mail) is using it. Those apps should never access any files on that drive.


Also interesting: I had to wipe my drive and reinstall 10.9 a few weeks ago. After I did that, I didn't have the problem anymore!


However, after a couple of weeks of use, it came back!!!


I am proficient in Terminal (longtime Unix/Linux user) and tried the diskutil list (showed it as /dev/disk3) and then lsof /dev/disk2. This didn't output any files! Now what?


Davids-MacBook-Pro:~ david$ diskutil list

/dev/disk0

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *251.0 GB disk0

1: EFI EFI 209.7 MB disk0s1

2: Apple_HFS david_rMBP_SSD 250.1 GB disk0s2

3: Apple_Boot Recovery HD 650.0 MB disk0s3

/dev/disk1

#: TYPE NAME SIZE IDENTIFIER

0: Apple_partition_scheme *3.1 GB disk1

1: Apple_partition_map 32.3 KB disk1s1

2: Apple_HFS my_data1 2.6 GB disk1s2

/dev/disk2

#: TYPE NAME SIZE IDENTIFIER

0: Apple_partition_scheme *32.2 GB disk2

1: Apple_partition_map 32.3 KB disk2s1

2: Apple_HFS my_data2 32.2 GB disk2s2


Davids-MacBook-Pro:~ david$ sudo lsof /dev/disk2

Password:

Davids-MacBook-Pro:~ david$

Feb 19, 2014 8:00 PM in response to Phil Stokes

Thanks. That shows:


Davids-MacBook-Pro:~ david$ sudo lsof /dev/disk2s2

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

mds 57 root 17r DIR 1,9 476 2 /Volumes/_data2_mb_

mds 57 root 28r DIR 1,9 476 2 /Volumes/_data2_mb_

mds 57 root 55r DIR 1,9 476 2 /Volumes/_data2_mb_

Safari 6624 david txt REG 1,9 407224 278205 /Volumes/_data2_mb_/data2/login.keychain

Dashboard 8077 david txt REG 1,9 407224 278205 /Volumes/_data2_mb_/data2/login.keychain


From what I understand, the mds tasks are part spotlight indexing, which I don't think are an issue (or maybe they are).


I have no clue what Safari and Dashboard are doing accessing keychains on this drive image. Like I said, I'm good at *nix (awk, vi, emacs, grep, find, xargs, etc) but this is OSX-specific stuff.


So I killed the task:

kill 6624

Davids-MacBook-Pro:~ david$ sudo lsof /dev/disk2s2

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

mds 57 root 28r DIR 1,9 476 2 /Volumes/_private_mb_

Dashboard 8077 david txt REG 1,9 407224 278205 /Volumes/_private_mb_/private/login.keychain


Now, when I try and eject, I get the same pop-up I would get if I quit Safari:


The disk "_data2_mb_" wasn't ejected because one or more programs may be using it.

You can try to eject the disk again or click Force Eject to ject it immediately.


So, I try killing the other tasks:


Davids-MacBook-Pro:~ david$ sudo kill -9 57

Davids-MacBook-Pro:~ david$ sudo lsof /dev/disk2s2

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

Dashboard 8077 david txt REG 1,9 407224 278205 /Volumes/_private_mb_/private/login.keychain

mds 12497 root 9r DIR 1,9 476 2 /Volumes/_private_mb_

mds 12497 root 11r DIR 1,9 476 2 /Volumes/_private_mb_

mds 12497 root 13r DIR 1,9 476 2 /Volumes/_private_mb_


But they come right back and I get the same pop-up.


I have to click OK and get more pop-ups warning the world will end if I force-eject the disk 🙂


Like I said, after I re-installed OSX, it didn't do this for a while but eventually came back.




David

Feb 20, 2014 2:06 AM in response to unfrostedpoptart

Has that flash drive (I'm assuming from the size) got any executable scripts or binaries on it? Did it come with any pre-installed vendor software?


Do


$ls -alF


and take a good hard look through the list. Seems to me something could be running everytime you mount that disk.


Also, check your login items and make sure there's nothiing in ther that is calling that disk when you log in.

Feb 20, 2014 11:52 AM in response to Phil Stokes

Phil, thanks for the suggestions. FYI, it's not a flash. It's an encrypted disk image created in diskutil.


Anyway, I poked around the directories more and did some google searches and found this:


http://blog.hostilefork.com/trashes-fseventsd-and-spotlight-v100/


http://forums.macrumors.com/showthread.php?t=1103654


I tried the suggestions from the first and think it might have fixed the problem. It might also explain why I didn't have the problem right after re-installing OSX; I didn't start up Time Machine for a couple of weeks and it looks like that's what's been causing the problems. I'll have to try some more tests but right now lsof doesn't show any tasks associated with the disk and it ejects properly.

Oct 8, 2015 6:22 AM in response to Topher Kessler

I have the same issue:



When trying to eject my disk it says, that Safari is using my disk and therefore can't be ejected

The disk-name is "Backup_MacMini_HD"


I went into "Activity Monitor" and found this under the process "Safari"

/Volumes/Backup_MacMini_HD/_CCC SafetyNet/2015-09-29 (September 29) 20-33-02/Users/MYUSERNAME/Library/Keychains/login.keychain


so its got something to do with CCC , i am using.


May be this helps someone to find a specific solution


So I hope that i helped to get help for others and me😁


thnx

Can't Eject Disk Because OS X Apps are Using It (Safari, Mail, Calendar, etc.)?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.