Thursday, May 22, 2008

Drives that Won't Eject


Macfixit.com has a good reminder of why you should love the terminal. If you can't eject a drive it's likely that one file on it is in use for some reason or another. Pop open a Terminal window and type:

lsof /Volumes/VOLUME_NAME

You'll see a list of files that are "in use" on that volume. Lsof literally means List of Open Files. Things get tricky if you have oddly named volumes however. Like mine, which use parentheses in their names (I know...) but still, a good tip for troublesome drives.

Coincidently, macosxhints.com has an article about something very similar, although with a different way to eject stubborn volumes. They propose you download and run a GPL'd applescript.

Turns out there are about a dozen ways till Sunday to eject these ejectless drives. (yes, I'm making that a RealWord™ now). Here are some Terminal commands to eject stuff:

hdiutil detach `mount | sed -ne 's|^\(/dev/[^ ]*\).*/Volumes/'"$VOLNAME"'.*mounted by.*|\1|p'` -force

hdiutil eject -force /Volume/volumeNameHere

No comments: