Dr. Mac's OS X Tip-of-the-Day

Terminal Technique to Eject A Stuck Disk Without Restarting or Resorting to Open Firmware Trickery
By BOB LEVITUS
This one appeared as one of our very own OSXFAQ Reader Reports last week,
but it's so good, I'm going to recycle it as today's Tip-of-the-Day.
If you've ever had a stuck disk (or disc) inside your Mac's optical drive,
you'll understand why I like it so much...
The tip was originally submitted by Chuck Bouldin and I've verified that it
works perfectly. Here are Chuck's instructions:
I read with stunned disbelief the Apple knowledge base article suggesting
that you reboot (!) and use Open Firmware (!) to eject an un-ejectable CD or
FireWire drive. This is a bit like cracking a peanut with an hydraulic press.
How about just doing this from the terminal:
- fstat | grep Diskname (to see if any files are open)
- df (to get the /dev name of the drive)
- hdiutil eject -force /dev/drivename (where you got drive name from df)
This works fine for me and has never, to my knowledge caused any troubles with
the FireWire drive that I use. The OSX Finder just seems to have trouble knowing
when a drive is/isn't "in use". If you use fstat to first verify that the disk is not
in use, then I don't see how this can harm the drive or cause data loss.
For what it's worth, after you issue the df command, you'll see a bunch
of lines of text like this:
- /dev/disk0s5 156288496 9844008 146444480 6% /Volumes/GiggleHurts
There will be a line like this for each mounted disk. The drive name you're
looking for in this example is /dev/disk0s5, which is Mac OS X's internal name
for the drive I know as "GiggleHurts." So the command I'd type to eject GiggleHurts is::
- hdiutil eject -force /dev/disk0s5
So there you have it. Copy it down and stash it wherever you store your
useful Unix commands. And thanks again to Chuck, for submitting it in the first place.
To discuss this tip (or anything you like) in Dr. Mac's OSXFAQ Forum, click here:
http://forums.osxfaq.com/viewtopic.php?topic=354&forum=100
Bob LeVitus is a leading authority on Mac OS and the author of 37 books,
including Mac OS X For Dummies and The Little iTunes Book.
|