When your hard drive starts to fail, Disk Utility might not be powerful enough to save you. Instead, you might want to turn to one of the big guns: fsck
. fsck
, which stands for “File System Consistency Check,” is a command-line tool that reviews and repairs the underlying structure of a hard drive. If you’re wondering, it’s no coincidence that it looks like the thing you say when you hard drive fails. We all hope we never have to use it, but if you do, here’s a brief introduction into its functionality.
- Macos Terminal Commands To Check Disk For Errors Mac
- Macos Terminal Commands To Check Disk For Errors In Linux
- Macos Terminal Commands To Check Disk For Errors Cmd

If you’re familiar with the fsck
from Linux, you’ll notice a lot of similarities in the macOS version. This article is written with a focus on the Mac’s user interface. Uniquely, fsck
needs to be run in single user mode to be even sort of useful, representation a significant limitation in comparison to the Linux version.
Finding the Right Disk
The same is the case from the command line. There are two commands for moving and copying: mv and cp.The first does the same as dragging a file to a new location on the same hard disk; the second. May 25, 2017 Pro Terminal Commands: Using diskutil. May 25, 2017 by Alexander Fox 3 Comments. Diskutil is the command line version of Disk Utility, the macOS application used to manage hard drives. Just like Disk Utility, you can use the command to format disks, erase drives and more. Once you’re familiar with it, you’ll find that the command is often. In Linux, the check disk command is represented by fsck, which is an abbreviation for file system consistency check. Simply put, it is a utility that helps a user scan the file database for any existing errors and repairs them if need be. If unable to unmount drive on Mac. You can try booting from OS X recovery by holding CMD + R at the time of startup. Once booted from OS X recovery, select Terminal from the utilities and then at the unix prompt enter. May 24, 2012 Every Mac user should check their Mac hard drive health on regular basis. It helps to prevent you from any disaster of data loss. Disk utility is good one but I have used other one i.e Stellar Drive ToolBox. Drive status module of this software helps to check health of Mac drive with advanced options. Thanks for shairing this information.
Before you can run fsck
, you’ll need to find the device node and identifier of the disk you want to target. We’ll use Terminal’s diskutil
command to accomplish that. If you can’t run Terminal from inside macOS, you can access the same data with /sbin/diskutil
inside Single User mode.
The same is the case from the command line. There are two commands for moving and copying: mv and cp.The first does the same as dragging a file to a new location on the same hard disk; the second. Jul 09, 2018 Find Log Files on Disk. These logs are plain-text files you can find on your Mac’s local disk, too. This means you can browse to them in Finder or via the Terminal, open them in other applications, use command-line tools with them, and back up the files. To find these log files, look in the following locations: System Log Folder: /var/log.
1. Open Terminal (/Applications/Utilities/Terminal.app)
2. Type the following command, then press “Enter.” This will run the command line version of Disk Utility, which provides more data.
3. You’ll be given a list of all currently connected hard drives. This includes mounted and unmounted drive
4. Locate the disk you want to fsck
and find its device identifier. It will look like /dev/disk1
. You’ll find this information along the left margin of the Terminal window. Write this ID down: you’ll need it in the next steps.
Running fsck from Single User Mode
Because fsck
can edit the core file system, macOS won’t let you run it from inside the operating system. You might think you can run fsck
on a non-booting disk, but you’d be wrong. fsck
is basically non-functional while in macOS’s userland. You’ll need to reboot into Single User mode, a text-only superuser interface for macOS. If you familiar with the basics of Terminal, you’ll recognize Single User mode.
1. Restart your computer.
2. Hold down “Command + S” while your computer restarts to enter Single User mode. You can release the keys once you see white text start to appear on the startup screen.
3. Some white text will scroll by quickly. When it stops, you’ll see a command prompt at the bottom of the screen that reads root#
.
If the text stops scrolling but you don’t see this prompt, press the “Enter” key once to reveal it.
4. To repair the boot disk, type in the following command, then press “Enter.”
This runs fsck
two flags:
-f
forces it to check journaled file systems like HFS+-y
automatically says “yes” to any prompts thatfsck
might encounter.
The -y
flag can be a little dangerous, so use it carefully. As fsck
’s man page points out, “this should be used with great caution, as this is a free license to continue after essentially unlimited trouble has been encountered.” If you’re concerned about giving fsck
free reign over your file system, you can leave it off and press the “y” key manually when prompted.
5. You can also use fsck
to repair non-booting disks, but you’ll need to know the file system type. If you’re not sure about the file system, it’s probably HFS+. You can find out for sure with the diskutil command we ran earlier.
For example, if I wanted to run fsck
on /dev/disk2, I might use the following command:
That command runs the HFS version of fsck
on the target drive. Other available file systems include fsck_msdos
, which runs Windows’ FAT file systems; fsck_exfat
, which examines ExFAT filesystems; and fsck_udf
, which looks at UDF file systems.
4. fsck
will check the file system and attempt to repair any damage that it finds. If it finds no damage, it will exit with “OK.”
5. When fsck
is finished checking and repairing the filesystem, type reboot
into the command prompt and press “Enter.”
When fsck Fails
fsck
is powerful, but it can’t fix everything. If the utility can’t repair your disk, you’ll be told through a brief failure message. This is typically pretty short on detail, but it does tell you that you’ll need a more powerful solution.
You can use two programs to save your disk: DiskWarrior and Data Rescue. Data Rescue is geared towards recovering files from damaged hard drives, while DiskWarrior can also get corrupted drives running again. Both programs are expensive but capable.
In either case, you’ll need to connect the hard drive to a different Mac and run those applications from inside a functioning version of macOS. Because of file system incompatibilities, you can’t easily fix a Mac-formatted disk from within Windows.
Conclusion
fsck
on the Mac isn’t as powerful as fsck
on Linux, but it can still be a lifesaver if you end up with a corrupted boot disk or damaged hard drive.
You might also like:
Pro Terminal Commands: Using diskutil
Improve Productivity with Regular Expressions
iOS 11 Brings a Heap of New Features This Fall
diskutil is the command line version of Disk Utility, the macOS application used to manage hard drives. Just like Disk Utility, you can use the command to format disks, erase drives and more. Once you’re familiar with it, you’ll find that the command is often more powerful and faster than Disk Utility, with more features to boot.
Getting Acquainted with diskutil
If you simply type diskutil
into the command line and press Enter, you’ll receive a list of “verbs” that diskutil
can operate on.
Just like in the English language, these verbs are things that diskutil
can accomplish. The most basic verb for diskutil
is list
, which you’ll enter like so:
This command will list all the disks attached to your machine. It indicates information like partitions, format and, importantly, mount points. The mount points start with /dev/disk
and are used to specify disk operations in diskutil.
Partitions (called “volumes” in diskutil
parlance) are specified by their identifier on the right.
Disk identifiers follow the format disk_s_, where the underscores are replaced with identifying numbers.
Using verbs
We can use the other verbs to get more information about our drives and run specific operations.
The info verb gets more information about a specific disk (disk1, in this case). Use the mount point to specify the target disk to grab information on. You’ll see tons of stuff you might care about and a lot of stuff you won’t. This is the most information you can get about your disk in one place, and it’s helpful when troubleshooting drive problems.
Unmounting and Ejecting with diskutil
The umount
verb unmounts a specified volume. Unmounting is just like ejecting a volume from Finder, but it can be done to internal disks. In this example, I’ve specified the volume I want to unmount with the disk identifier. You can also specify the volume using the partition name. Unmounted disks become inaccessible via Finder, but they can still be seen via diskutil list
and manipulated with other diskutil
commands. Also, note the command is umount
, with no “n”.
The unmountDisk
verb is similar to umount
, but it unmounts an entire disk instead of one volume. Disks are specified with their mount point, as seen above. You can’t unmount your boot disk or volume, and you’ll get an error if you try to unmount a disk or drive that’s currently in use.
The eject
verb is a lot like unmounting a drive, but only for removable disks. Removable disks are things like USB hard drives and flash drives. If it connects through an interface on the outside of your computer, it qualifies as a removable drive. Once a drive is ejected, it won’t appear in Finder or diskutil list
until it’s physically unplugged and plugged in to its interface again.
The mount
verb is the inverse of the umount verb. It mounts volumes on internal disks manually. Only unmounted volumes can be mounted, obviously. To mount all volumes on a disk, use diskutil mountDisk disk1
, for example.
Fixing Problems with diskutil
The verifyVolume
verb will run a verification pass on a specific volume. Verification involves checking the contents of the disk against the expected values. If any mismatches are found, the disk will be identified as in need of repair.
If it turns out that your volume needs to be repaired after you’ve verified it, you can run the repairVolume verb. This will run a repair pass on the volume and attempt to fix any problems found in the verification process.
Format and Erase Drives with diskutil
The eraseDisk verb handles reformatting disks, which erases all data and volumes on a single disk. The verb takes as inputs the format, new disk name and disk identifier, in that order. This example will erase disk2 and reformat it as journaled HFS+. The new disk will have one volume named
The reformat
verb will erase a single volume on the disk while keeping the same name and format. It rewrites the same file system that the volume started with, resetting the volume to a blank state.
Partition Drives with diskutil
The partitionDisk verb runs an command-line version of Disk Utility, allowing you to create multiple partitions on a single disk. It’s a little complicated, but it follows this format for it’s arguments:

diskutil partitionDisk MountPoint[numberOfPartitions] [APM|MBR|GPT] [part1Format part1Name part1Size part2Format part2Name part2Sizepart3Format part3Name part3Size ...]
Partition sizes can be specified in gigabytes with the G suffix (2 G) or terabytes with the T suffix (2 T). My favorite way to specify partition sizes, however, is with percentages (25%, for example). The size of the final partition can be specified with “R” to indicate that it should take up the remainder of the disk.
Macos Terminal Commands To Check Disk For Errors Mac
For example, the following command will create three partitions:
They’ll be formatted with JHFS+, APFS and ExFAT, and named Volume1, Volume2 and Volume3 respectively. Volume1 and Volume2 will each take up 25 percent of the disk, and Volume3 will occupy the remainder. It will also use the GUID Partition Table (GPT) which is one of the more flexible partition table options.
You can see the results of the operation at the end of the Terminal window to determine everything went okay. Using partionDisk
isn’t the easiest way to partition a disk, but if Disk Utility is complaining, its a good alternative.

You might also like: