force unmount on mac os x 27. Jun 2008
When using Mac OS X you might have encountered this message.
The disk "foobar" is in use and could not be ejected.
Try quitting appplications and try again.
This message may occur even if you have all closed all programs. The guilty party for this behavious may be Leopard’s FSEvents, which sometimes has a lock on a volume. To force the unmount of a volume just open a Terminal and use umount.
sudo umount -f /Volumes/FooBar
According to a commentator, if that doesn’t work you can also try
sudo diskutil umount force /Volumes/FooBar
On linux machines it is often the case, that you are in the mounted directory when trying to unmount the device. Therefore you have to leave the directory to unmount the device:
The man page tells us: -f Force unmount (in case of an unreachable NFS system). (Requires kernel 2.1.116 or later.)
The -f directive does not work in this case under linux machines. The umount command is still locked. So you have to leave the directory:
This works basically the same way on Mac OS X, but sometimes even changing the directory doesn’t resolve the issue,
then
diskutilcomes to the help.To force the unmount on OS X 10.5 use
What’s the advantage of using diskutil over plain umount?
the advantage is, that if you cant unmount with anything else you can either take the cable away and hurt external drive or you can unmount with
diskutil umount force /Volume/YourowndiskOkay, so diskutil is mightier than umount on Leopard, right?
Hi,
Thanks a lot for this post. It actually solved my problem!
Cheers Christine Fürst (Stinie) from Rotterdam (Netherlands)
Very helpful, thanks!
I found another process that can make a device busy, via the command $ userid root lsof ‘/Volumes/2ndHardrive 1’ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME fseventsd 76 root 8u REG 14,5 0 1892050 /Volumes/2ndHardrive 1/.fseventsd/000000000038f4c5
fseventsd is a daemon that watches for changes to a mounted volume, for the benefit of applications like Finder and Spotlight. It keeps a file open on the volume, so it is “busy”.
Then I read here http://lists.apple.com/archives/Darwin-dev/2008/Sep/msg00039.html that you are not supposed to use the direct command-line tools like “mount” and “umount” on MacOS, and that “DA [Disk Arbitrator] will notify fseventsd to stop looking”. Surprising to me – I thought MacOS X was basically UNIX.
DA appears to be either a GUI or an API. I want a command line. So I found, via “man -k disk”, the commands “disktool” (deprecated) and “diskutil” as mentioned above. diskutil works when umount fails; I guess it tells fseventsd to stop looking.