Warning: This article is about trying to accomplish some things in Mac (or iMac) single-user mode when your system is in trouble. In this article I assume that you’re an experienced Unix administrator, so I don’t bother to explain each command. If you don’t know what the commands in this article do, don’t use them, just take your Mac to an Apple store or Mac dealer. Be careful with all of these steps. When you’re logged in, you’ll be logged in as the root user, which means you can do a lot of damage to your system, including deleting all of the files on the system.Back to top
The partial death of a 2008 iMac
My 2008 iMac running Mac OS X 10.6.x partially died last night. I was working with iMovie, put it into full-screen demo mode, and the display went nuts and the system locked up.
Now it won’t boot up all the way; it stops after showing a gray screen with an Apple logo on it. The little timer animation runs briefly, then stops, and the system just sits there.
Additionally, there are 30 thick vertical lines on the screen, probably an 1/8th of an inch thick or more. I assume this means there is a problem with the video card or display. Here’s what it looks like in single-user mode:
After many repeated attempts I was just now able to get the system to boot into hardware test mode with the install CD, but the short test showed no errors, even though the 30 lines are still on the display. The longer test just showed a possible “HDD” error, but I can’t read much of the message (because of the stripes).
I can get the Mac to boot into single-user mode, where I can work at the command line. Peering through the 30 vertical lines, I can see that the hard drive is there, and all of my files are still there, so I thought I’d try to make another backup of them.
For a long time I couldn't get the iMac to recognize the USB drive I was plugging into the USB port, but after a while I finally figured out the magic formula. Here are the steps I used to get the iMac to recognize the USB drive (thumb drive).Back to top
fsck and mount
I recommend not plugging in your USB drive yet. Then boot the system into single-user mode. When you do, you’ll be logged in as root at a command line prompt. (Which seems like a security risk. I could walk into any office, reboot a Mac into single-user mode, then wipe their hard drive. But that’s another story.)
The first things you’re supposed to do are to run these commands:
fsck -fy mount -uw /
fsck command takes a while to run, maybe 5 or 10 minutes, although that will vary depending on the size and speed of the drive.
mount command is necessary because your hard drive is mounted read-only by default, so this re-mounts it in read/write mode.
Run some launchctl commands
Before running the following commands, I recommend running this
This shows which disk devices are currently on your system. I’m not logged into my system at the moment, but when I did this on my iMac, I saw three outputs here, all beginning as
/dev/disk0. Because I didn’t plug in my USB drive yet, I know those device listings are for the drives already in the computer.
Next, plug in your USB drive. After a few moments you should see some sort of message on screen. With the vertical stripes I can’t really read that message on my monitor, but it’s an indicator that the Mac hardware at least recognized the USB device was plugged in. (I think part of the message showed “USB,” or possibly "USBUHC".)
If you’re lucky
If you’re lucky, you can run that
ls command again, and you might see some new device files:
If you see new files here, congratulations, you’re in better shape than I was. If so, and assuming that your USB drive is formatted as a Windows/DOS filesystem, just follow these steps to mount the device:
mkdir /Volumes/usb mount_msdos /dev/disk1s1 /Volumes/usb
If your USB device is formatted differently, use another
mount command. I think there's a command named something like
mount_hfs for devices formatted with a Mac filesystem.
Once that's done, you should be able to see the new filesystem with the
/Volumes/usb refers to the root directory of your USB device, when you copy files to that directory, you're actually copying them onto the device. If these steps have worked for you, great, begin copying your files.
If the USB device didn’t show up
In my case, my iMac didn't immediately create any
/dev/disk* device files for my USB drive, so I had to dig deeper. In short, here's what I had to do. First, per some other websites, I ran these
launchctl load /System/Library/LaunchDaemons/com.apple.kextd.plist launchctl load /System/Library/LaunchDaemons/com.apple.notifyd.plist launchctl load /System/Library/LaunchDaemons/com.apple.configd.plist launchctl load /System/Library/LaunchDaemon/com.apple.DirectoryServices.plist
Those may have helped, I don't know. One of them caused the system to start posting information to my display, which combined with the vertical lines was a real pain in the butt.
While that's what was recommended on other websites, I didn't see the new
/dev/disk* files until I also ran these commands:
launchctl load /System/Library/LaunchDaemon/com.apple.disk*
There are two "com.apple.disk" files in that directory, and I can't remember their names now, but the last time I was in my system I just used that command, and it worked fine. Shortly after this, the
/dev/disk device files showed up.
Once the /dev/disk* files show up
My system created the new files with names like
/dev/disk1s1, and based on information I found on other sites, I thought that was the correct device to mount. So I created my mount point like this:
and then mounted the USB drive like this:
mount_msdos /dev/disk1s1 /Volumes/usb
After that, I copied all the files I wanted to the
/Volumes/usb directory (which is really the filesystem on the USB device), and then unmounted the USB device like this:
Once I saw that the
/Volumes/usb result no longer showed up in the output of the
df command, I removed my USB drive.
Shutting down the system
I haven't looked into those plist files yet, but something about loading them was keeping my Mac from being shut down properly. So to shut my system down, I first unloaded all of the plist files like this:
launchctl unload /System/Library/LaunchDaemons/com.apple.*
At that point I think you can shut down your system by typing
exit, but I was trying to do something else next, so I used the
reboot command instead.
Regarding that mount point, I don't think there's anything special about using the
Volumes directory. In my younger days as a Unix admin, I'd create a mount point wherever I wanted to, so unless OS X is doing something unique, you can probably create a mount point wherever you want.
As mentioned at the beginning of this article, these notes pertain to a 2008 model iMac running Mac OS X 10.6.x. Other Mac operating systems are probably at least slightly different.Back to top
I hope these notes have been helpful, and will save you a little time. I know they would have saved me several hours if I knew about all of this last night.Back to top
I'm just an average computer guy trying to get my grip on CLI. Google some commands I can use to troubleshoot in Single User Mode. I was reading all these stuffs about 'dscl' 'dsenableroot'. And all of a sudden, I found you. Amazing. Well writen!
Thanks this really saved the most important data in my mac .
You are a savior really. Thanks again
I needed to get some data off a Mac that wouldn't boot in any sort of graphical mode, due to GPU issues (apparently a known issue that happens to a lot of Macs) so I wanted to copy off the most important data before handing it off to Apple. I'm a developer, so I'm comfortable with the command line, but this is stuff I've never touched (I'm not exactly the sysadmin type!). Thanks so much for the detailed instructions!
this just helped recovering my wife's documents on a failed SSD after she "forgot" to connect to Time machine for.... about a year!