Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Ejecting a 'busy' disk image System
While playing around with some of the latest OS X releases tonight, I managed to mount a disk image (for an image viewer called "Outlaw", which is pretty cool, BTW, for its instant infinite scaling) which simply would not eject. When I tried, I got a message stating that the image couldn't be ejected because it was in use. I knew this wasn't the case, as I had quit Outlaw and pretty much everything else except OmniWeb. To debug and solve the problem, I opened a new terminal window and typed:

fstat | grep "Outlaw"

fstat is a file status program which identifies open files, and then the pipe (vertical bar) passes the output of fstat to grep, the UNIX search program. I asked grep to find the word "Outlaw", which was part of the disk image name. The output of the command was:

robg TruBlueEnv 804 11 19 drwxrwxrwx 264 r /Volumes/Outlaw-0.1b1

TruBlueEnv is Classic, which somehow had the image file open -- even though I had no Classic apps running! At that point, I returned to the GUI, opened System Prefs and stopped Classic. I could then eject the disk as usual from the contextual menu.

So if you've got a stuck image file, take a look at fstat with a search on part of the volume name (to shorten the returned list!) to find what's making your volume busy. NOTE: There may be easier ways to do this (UNIX wizards, any thoughts?) but this was the first one that came to mind when I was faced with the problem.
  • Currently 3.83 / 5
  You rated: 4 / 5 (6 votes cast)

Ejecting a 'busy' disk image | 10 comments | Create New Account
Click here to return to the 'Ejecting a 'busy' disk image' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
easier yet is lsof
Authored by: vipw on May 06, '01 06:20:05AM

lsof is much like fstat but will search from a path.

lsof /Volumes/ will list all the open files that are volume mounted.
both apps list the pid as well, making it easy to kill the process that has the file opened with
the kill program.

i'm not sure if you need the developer tools to have lsof, i don't have access to a machine without them.

[ Reply to This | # ]
easier yet is lsof
Authored by: Groucho on May 07, '01 01:51:39AM

The disk-in-use-can't-eject problem seems to be a bug, and always seems to come down to Classic. The simplest solution until it's fixed is simply to quit or restart Classic. If it's not running, you can eject anything.

[ Reply to This | # ]
easier yet is lsof
Authored by: RandyMan on Apr 26, '02 12:08:41PM

I have the same problem after I run a Java application that lives on the volume I'm trying to unmount. The application itself is gone, but Java seems to be preventing me from unmounting the drive.

[ Reply to This | # ]
easier yet is lsof
Authored by: Anonymous on May 21, '01 04:49:50AM

Whenever is use lsof, i get a warning that says compiled for darwin 1.0, current version is 1.3.3. Is there a way to recompile this, or should i just not worry about it?

[ Reply to This | # ]
easier yet is lsof
Authored by: garbanzito on Apr 26, '02 06:35:38PM

i currently have a disk image which won't unmount. Classic is not runnng. fstat lists the volume twice, but the associated process is coreservicesd, not something i think i should be killing.

lsof /Volumes/ doesn't show anything at all. lsof with no arguments shows an hdid process has the dmg file open, but doesn't have an entry for the mounted volume.

in short, none of these hints seems to cover my current situation. i run into this very frequently and have been using the little utility "RealEject X", which probably is just doing "hdiutil eject -force".

i'm very comfortable force ejecting disk images and CDs because i don't/can't write to these volumes, so any open files will not have buffers needing to be flushed.

[ Reply to This | # ]
Quick Fix
Authored by: Rampico on Jul 23, '02 01:26:52PM

Same problem here. I've found that after the "unable to eject" message, if I relaunch the Finder, I can eject the disk.

[ Reply to This | # ]
easier yet is lsof
Authored by: pecosbill on Dec 22, '05 10:50:56PM
I couldn't get lsof to work either (on 10.4!!!!!! When is Apple going to report this!?!?!) until I did

lsof | grep Much
where Much is a part of the disk name (case sensitive) that I want to eject. I could not get lsof to work by putting the volume path as a parameter. There is a way to tell those apps to quit in one command line though it's likely best to do it manually. (Check the huge man page examples if you want to give it a try. It involves running lsof inside a ` (back-accent)

Pecos Bill

[ Reply to This | # ]

Easier way...
Authored by: sharumpe on May 08, '01 02:36:34AM
I haven't tried this, but if there are processes that show up, you should be able to kill them from the command line without having to kill Classic itself. Do this:
fstat | grep whateve
Look at the third column - it is a number. Type this:
kill -9 thatnumber
For example:
fstat | grep Outlaw
bob      Outlaw         824   wd        2 drwxr-xr-x     1520 r   /
So we use 824 and type:
kill -9 824
Do this for each process that contains Outlaw, and you didn't have to kill Classic. Mr. Sharumpe

[ Reply to This | # ]
Another cause...
Authored by: robg on Jul 17, '01 12:11:32PM

If you launch an application directly from the disk image, this can also cause the disk to fail to eject when you're done with it. I've had this happen a couple of times, and the only solution was a restart or just waiting -- I did a "ps aux | grep programname" and found that there was a process from the mounted image (even though I quit the app), but then the phone rang. When I came back 15 minutes later, the "kill" command failed and a repeat of the "ps" command failed to find the process. Quite odd!


[ Reply to This | # ]
In Activity Moniter
Authored by: vonnetube on Sep 23, '06 11:18:07AM

You can get rid of a disk image in activity moniter by looking at all your precesses and force quitting the one that says something like "disk image" or "disk image helpe" that worked for me, i dont know about you.

[ Reply to This | # ]