How to Repair Hard Drives with fsck in MacOS

When your hard drive starts to fail, Disk Utility provides useful disk repair tools. But if they don’t do it for you, you may want to turn to one of the big guns: fsck. fsck, which stands for File System Consistency Check, is a command-line tool that examines and repairs the structure behind a hard disk. And while we all hope we’ll never get to use it, here’s a quick introduction to its features.

Observe: fsck The tool on the Mac is the same as on Linux. This article is written with an emphasis on the Mac interface.

Find the right disc

Before you can run fsck, you must find the device node and disk ID that you want to target. We use terminals diskutil command to do this.

1. Open the terminal (/Applications/Utilitaires/Terminal.app)

2. Type the following command and then press “Enter”.

3. This will create a list of all connected drives, both installed and removed.

terminal-diskutil-list-result

4. Find the disk you want to drive fsck and search for its device ID. It looks like /dev/disk1, and you will find this information on the left side of the terminal window. Write this information somewhere because you will need it in the next steps.

terminal-diskutil-list-result-2

Running Fsck from single user mode

fsck is a powerful utility, but macOS does not allow it to run from within the operating system. You might think that you can run an fsck disk that doesn’t boot, but you’re wrong: fsck isn’t basically inoperable in macOS user mode. You will need to restart in single user mode, which is a simplified, text-only interface for macOS.

See also  Top 4 Mac Calendar Apps in 2021

1. Restart the computer.

fsck-restart-mac

2. Press and hold “Command + S” when the computer restarts. You can release the keys when you see white text appear on the home screen.

3. White text scrolls quickly. When it stops, you will see a command prompt at the bottom of the screen that says root#.

fsck-single-user mode-1

If the text stops scrolling but you do not see this prompt, press Enter once to display it.

4. To repair the startup disk, type the following command, and then press Enter.

fsck-single-user mode-2

It works fsck with -f a flag that forces it to scan journaled file systems, such as HFS +, and -y a flag that automatically says “yes” to any prompts that fsck may encounter. Remember that -y a flag can be a little dangerous: like fsck man page points out, ” this should be used with extreme caution as this is a free license that can be renewed after unlimited problems have occurred.

5. You can also use fsck to repair non-bootable disks, but you need to know the file system type. For example, if I wanted to run fsck “/ dev / disk2. I could use the following command:

fsck-single-user mode-3

This command executes the HFS structure fsck on this drive. Other available file systems include fsck_msdos, which runs on FAT file systems; fsck_exfat, which examines ExFAT file systems; and fsck_udf, which examines UDF file systems.

4. fsck scans the file system and tries to repair any damage it detects. If it does not find any damage, it will exit with the “OK” button.

See also  How to install tvOS 15 public beta

5. When fsck has finished checking and repairing the file system, type reboot at the command prompt and press “Enter.”

Conclusion

fsck on a Mac is not as effective as fsck on Linux, but it can still save your life if you end up with a corrupted boot disk or a damaged hard disk.

About the author

admin

Leave a Comment