If your Mac’s hard drive is experiencing problems, you can recover the partition data using ad hoc programs: here are the best ones
Apple’s macOS operating system is known for its robustness and reliability, but that doesn’t mean that an iMac or MacBook can’t have problems from time to time. Among the many possible technical failures of an Apple computer, one of the most fearsome is undoubtedly the malfunction of a partition. In this case, it is possible to lose all the data stored on that partition in one fell swoop and for this reason, we always recommend you to make periodic backups of your most important data. When the damage is done, however, there is still some maneuver you can do to try to save at least part of the data of the failed HFS+ partition. Let’s assume, in this case, that the partition is still visible on your Mac, but not accessible, and that it is not the main partition on which the operating system is running. So your Mac starts up and works properly, but the data on the damaged partition is inaccessible.
First rule: don’t touch anything
If you are trying to fix a malfunction of an HFS+ partition on macOS, you should not try repeatedly to make it work: if you find that the data is no longer accessible, do not try to copy new files to the disk or test the disk to correct any errors. You shouldn’t even try disassembling the disk and reassembling it on another Mac. All of these maneuvers may make the situation worse, preventing you from recovering the data. What you should do, however, is to use specialized tools, developed to solve problems of this kind.
Free tools for trying to recover a damaged HFS+ macOS partition include Testdisk and Photorec. These are two open source programs that you can make work in tandem to regain possession of your data. The first thing to do is to download Testdisk, extract the zip file on the working partition. Then you have to open the Terminal and navigate to the Testdisk directory (usually it is /Downloads/testdisk-NUMBER-VERSION). Now run the /testdisk command and create a new log file for recovery. You will be asked to enter your password and, immediately after, to choose the physical disk on which the damaged partition resides. Then select the partition that doesn’t work properly, if Testdisk doesn’t find it by itself.
Now run the Analyze command and press enter. The tool will perform a series of tests trying to access the data on the disk, identifying the type of partition and other technical parameters needed to try to restore the data by recreating the “partition table”, ie the file that contains the basic data on the partition. Select the partition and then choose Write to rewrite the partition table of the damaged partition. Press Y to confirm, then Ok and finally exit Testdisk and restart the Mac.
If all went well, you will have access to the data of the repaired partition again upon reboot. If not, it means that the damage is more severe than expected and you must also use Photorec. The particularity of this free tool is that it completely ignores the file system and tries to access the data directly. In the same directory where you installed Testdisk, also from the Terminal, run the command /photorec. You will be shown a menu similar to the one already seen for Testdisk and you will have to select again the physical disk with the damaged partition. Photorec will do a series of tests on the disk to find the partition that doesn’t work. If the partition is very badly set up, Photorec will find more than one (in practice it will see it in pieces). So you’ll have to choose Search and, immediately afterwards, Photorec will ask you where it will have to copy the files it can find (make sure you have enough space). At this point a long and laborious work will begin, with which Photorec will try to extract one by one the files from the not working partition. It will take a long time, don’t worry and never interrupt the operation.
If Testdisk and Photorec are two tools that require some basic technical knowledge (like knowing how to use the Terminal), there are also tools to recover a damaged partition on easier to use macOS. Like Data Rescue and Disk Drill, two paid tools ($99 and $89 respectively) that perform more or less the same actions, but offer a very intuitive graphical interface. If you don’t feel like using the Terminal and are willing to spend a few dozen dollars to save your data, then Data Rescue and Disk Drill are two choices you should consider.