Fixing the Disk

The beauty of macOS’s design is that the operating system itself is frozen in its perfect, pristine state, impervious to conflicting system extensions, clueless Mac newbies, and other sources of disaster.

That’s the theory, anyway. But what happens if something goes wrong with the complex software that operates the hard drive itself?

Fortunately, macOS comes with its own disk-repair program. In the familiar Mac universe of icons and menus, it takes the form of a program in Applications→Utilities called Disk Utility. In the barren world of Terminal and the command-line interface, there’s a utility that works just as well but bears a different name: fsck (for file system check).

In any case, running Disk Utility or its alter ego fsck is a powerful and useful troubleshooting tool that can cure all kinds of strange ills, including these problems, among others:

The easiest way to check your disk is to use the Disk Utility program. Use this method if your Mac can, indeed, start up. (See Method 2 if you can’t get even that far.)

For best results, restart the Mac into Recovery Mode and run Disk Utility from there. The process goes like this:

If you see the message “The volume ‘Macintosh HD’ appears to be OK,” that’s meant to be good news. Believe it or not, that cautious statement is as definitive an affirmation as Disk Utility is capable of making about the health of your disk.

Disk Utility may also tell you that the disk is damaged but that it can’t help you. In that case, you need a more heavy-duty disk-repair program like DiskWarrior (www.alsoft.com).

Techier folk can boot into the Mac’s raw Unix underlayer to perform some diagnostic (and healing) commands.

Specifically, you can run the Unix program fsck, for which Disk Utility is little more than a pretty faceplate.

Like any Unix program, fsck runs at the command line. You launch it from the all-text, black Unix screen by typing fsck and pressing Return. (You can also use fsck -f.)

You can’t, however, just run fsck in Terminal. You have to run it when the usual arsenal of graphic-interface programs—like the Finder and its invisible suite of accessory programs—isn’t running.

The Terminal program is the best-known form of macOS’s command line, but it’s not the only one. In fact, there are several other ways to get there.

In general, you don’t hear them mentioned except in the context of troubleshooting, because the Terminal program offers many more convenient features for doing the same thing. And because it’s contained in a macOS-style window, Terminal is not as disorienting as the three methods you’re about to read.

All these techniques take you into console mode, shown in Figure B-4. In console mode, Unix takes over your screen completely, showing white type against black, no windows or icons in sight. Abandon the mouse, all ye who enter here; in console mode, you can’t do anything but type commands.

To get there in times of startup troubleshooting, press -S while the Mac is starting up. (If you’re stuck at the frozen remnants of a previous startup attempt, you may first have to force restart your Mac; hold down the button for 5 seconds.)

Instead of arriving at the usual desktop, you see technical-looking text scrolling up a black screen as the Mac runs its various startup routines. When it finally stops at the localhost# prompt, you’re ready to type commands. You’re now in what’s called single-user mode, meaning that the Unix multiple-accounts software has yet to load. You won’t be asked to log in.

At the root# prompt, type fsck -y (note the space before the hyphen) and press Return. (The y means “yes,” as in “Yes, I want you to fix any problems automatically.”)

Now the file-system check program takes over, running through five sets of tests. When it’s complete, you’ll see one of two messages:

Type exit at the prompt and press Return to get back to the familiar world of icons and windows.