Data recovery, corrupted OSX repair, if your Mac won't boot.

March 2, 2013

sheepfixes-data

This article is for moderate to savvy users. It is not a precise, step by step guide.

My goal is to point people who have some computer know how in the right direction. I will not be going into detail with each particular step. If you are somewhat computer savvy, but just need somewhere to start, this is the guide for you.  This is mac-centric, however, ddrescue & HDD Regenerator are equally adept at recovering any operating system along with your data.

Help! It doesn't work!

You go to turn on your computer one day and it won't boot. Oftentimes, home users do not have the tools necessary to do their own data recoveries. If you do have any, I am going to walk you through the steps you can take to get your entire install back - a bootable drive with your full setup on it is my goal. Reinstalling software and reconfiguring every setting so you can work the way you used to can be an incredible pain in the ass, which we are hoping to avoid. They may require a mixture of Apple & Windows machines available.

First thing's first. Understand that drives get worse - not better.

The most important thing to understand with data recovery is that dying drives can worsen in condition as you access the data. Using software like Data Rescue Pro or UFS Explorer to obtain specific files prior to attempting a full recovery, or before attempting to repair the volume is always prudent. I did mention that my goal is to get you a full recovery - but if you have one session file, one document, or one notepad file with winning lotto numbers in it - grab that before we move forward with full recovery!

On a Mac, here's one of the easiest points to start from.

On a mac, the first step to boot up into single user mode. This means holding apple-S from the second you turn the computer on. You'll be transported to a black, command prompt, DOS looking screen. Type the following at the prompt.

fsck -fy

A series of checks will undergo on the primary drive in the laptop/desktop. Any errors you see are not necessarily signs of a failing hard drive. However, if a drive is failing, you can almost guarantee errors when performing this check. Oftentimes after repairing these errors, the machine will boot again. Reboot when it is done, and see what happens.

Do we have bad sectors? It's important to check. This can help you with Windows drives as well.

If it boots after fscking, great! However, this doesn't mean you're out of the water. Your filesystem could have become corrupted for a number of reasons, and we need to rule out the hard drive as one of them before we allow it to stay in service. One thing you should do is run a bad sector check on the drive. There is no software I can recommend better for this purpose than HDD Regenerator. HDD Regenerator looks for bad sectors, and can be asked to repair them as it finds them. Bad sectors occur over time on any hard drive. You have an arm moving around a platter 90+ times per seconds and grabbing data from microscopic sectors via magnetism. It is a miracle that this works – and not surprising that bad sectors arrive over time. When bad sectors begin to appear, this is a good time to replace the drive. Considering how cheap hard drives are, it is a good idea to replace it once it reaches this point. It may still work, but is it really worth another heart attack 1 month from now when you're right back where you started?

If it doesn't boot after fscking, than I would attempt running HDD Regenerator in full – with the option to repair bad sectors as it finds them, on this drive. HDD Regenerator does something similar to what SpinRite does, with the difference being HDD Regenerator actually works. The concept behind Spinrite is great – I respect it a great deal, but every drive I've given SpinRite for six years has ended the same way – 6 days in, 0-1 bad sectors repaired, no progress.

After running HDD Regenerator and repairing the bad sectors - does your machine boot into the OS upon completion? If it does, great - let's skip to the ddrescue section of this guide, and get  your data copied onto a good drive while it still works.

Still not booting? Perhaps the directory structure is corrupt. This is for the Mac people.

If it doesn't boot, you can try a program called Diskwarrior. If you can't boot, diskwarrior won't do you much good, as Diskwarrior is run from within OSX. There are ways to install OSX onto a flash drive – and install diskwarrior onto the flash drive. Or, you can install Diskwarrior onto another Mac and plug your drive into this machine. The first tab when you open Diskwarrior has everything you need to rebuild the directory. Diskwarrior is excellent at making drives reappear, that do not show up in the finder otherwise.

If this completes, check and see if you have a bootable OS. One way or the other, skip below to the ddrescue step, and give diskwarrior a shot at repairing the directory once we have all of this data on a working disk.

Introduction of ddrescue - let's copy the data to a safer place. This can help you regardless of operating system.

Programs like ddrescue on linux are excellent tools for data recovery. ddrescue is a combination of a traditional linux tool called dd(used for creating exact copies of files, partitions,and full discs) and a plethora of smart data recovery techniques.ddrescue uses several metods to ask for data from a drive in order to receive it. ddrescue is an intelligent program, understanding that each time you mess with the disk, you are potentially making it worse. A sensible way to copy data is to copy only what is easy to copy – this prevents stressing the disk. Get as much as you can off. Then, in a second pass, grab the information that was unusable the first time around. If the drive dies during this second pass, at least all the recoverable data has been retrieved.

It is not optimal to run, say, Ubuntu linux off of a USB pendrive, but it is very doable. Once you install Ubuntu on the pen drive, open a terminal and type the following.

sudo apt-get update

sudo apt-get install build-essential

wget http://gnu.mirrors.pair.com/gnu/ddrescue/ddrescue-1.16.tar.gz

tar xvf ddrescue-1.16.tar.gz

cd ddrescue-1.16

./configure

make

make install

Now, ddrescue is installed. You'll have to figure out which drive is your original drive, and which is your recovery drive.

ddrescue -f -g -n /dev/sdb /dev/sdc /root/rescue.log

This command tells ddrescue to copy all data from /dev/sdb, which may be our dead drive, to /dev/sdc, which is our new drive. -f forces the data over whatever is on the new drive. -g tells ddrescue to keep track of what it did/did not copy in a logfile – the point of this will come apparent soon. -n tells ddrescue to not drive itself nuts trying to copy corrupted sections of the drive over.

Then, we will do this.

ddrescue -d -f -r3 /dev/sdb /dev/sdc /root/rescue.log

This tells ddrescue to copy data again – this time, only copying data it skipped the last time. The difference between -n and -r3 is that -n tells it to ignore corrupt data, whereas -r3 tells it to try to retrieve data from corrupted blocks three times before giving up.

Once this is done, see if you can boot into your system. If you can, great! If not, we still have our options.

Try Diskwarrior again – this time, on your new drive. This is for Macs.

Diskwarrior cannot write a new directory, or read information properly off of a very bad drive. However, if you put that same information on a new drive, Diskwarrior now has a fighting chance – a possibility to recover the data. Often directories too far gone on dead drives, are recoverable after using ddrescue to copy everything to a new drive.

If this works and allows you a bootable system, congrats. You don't have to reinstall all your apps from scratch, or deal with a 2 month old time machine backup missing everything you've recently done. If not, it's time to cave and attempt recovering data that is important, piece by piece – if you can get either drive to show up with software such as Data Rescue Pro or UFS Explorer.

Good luck!

If you do wind up failing, we offer simple data recovery, advanced data recovery, and physical data recovery.

Leave a Reply

Your email address will not be published. Required fields are marked *

Website Design & SEO by DE Digital