How to read intermittent hard drive constantly?

I have a faulty hard drive that works intermittently. After a cold boot, I can access it for about 30-60 seconds, then the hard drive fails. I am willing to write software to back up this drive to a new and larger drive. I can develop it under GNU / Linux or Windows, I don't care.

The problem is this: I can access the disk for some time, and there are some large files, but it will take longer than copied . For this reason, I am thinking of backing up the entire hard drive in smaller parts, something like a bit torrent. I will read a few megabytes and save them before trying to read another set. My main loop would be something like this:

while(1){
    if(!check_harddrive()){ sleep(100ms); continue; }
    read_some_megabytes();
    if(!check_harddrive()){ sleep(100ms); continue; }
    save_data();
    update_reading_pointer();
    if(all_done){ break; }
}

      

The problem is with the check_harddrive () function. I want to write this in C / C ++ for Maximus API / library compatibility. I will need to monitor my file handlers to check if they are all valid, and I need something to return bad data, but return if the disk fails during the copy process.

Can C # give me better results if I abuse "hardcoded" hardware exceptions?

Another approach would be to measure how long it takes me to use my hard drive and code a program to read it during that time, and tag me when the power cycle is on.

What would you do in this case? Are there any tools / utilities that already do this?

Oh there is a GREAT bad optical media reader app here , it's called IsoPuzzle, it's not mine, I just wanted to share something related to my problem.

! EDIT!

Some clarifications. I am a home user, a computer science student in college, I would rather lose data than spend thousands of dollars recovering it. The hard drive is still covered by Seagate's warranty, but since they gave me a 5-year warranty, I want to try my best until time runs out.

When I say cold boot, I mean booting after a few seconds without power. Hot boot will restart your computer, cold boot will shut it down by waiting a few seconds and then rebooting it. Since this hard drive is internal, but SATA, I can just unplug the power cable, wait a few seconds and plug it back in.

So far, I'll go with robocopy, I'm just looking for it to see how I can use it. If I don't need to code myself, but a script, it will be even easier.

! EDIT2!

I was unclear, my drive is Seagate 7200.11. He knew he had bad firmware and didn't always fix it with a simple firmware update (not after this error appeared). The actuator is physically 100% in working order, only the firmware is screwed, forcing it to go into an infinite busy state for endless seconds.

+2


source to share


4 answers


I think the easiest way for you is to copy the entire disk image. Under Linux, your disk will appear as a block device, for example /dev/sdb1

.

Start copying the disk image before the read error appears. Then wait for the user to "repair" the disk and start reading from the last position.



You can easily mount a disk image and read its contents, see -o loop

for mount

.

Refrigerate disc before use. I heard it helps.

+2


source


I would work from a hardware angle first. This is an external drive - if so, can you try it another way?

You mentioned a cold start job, then it quits. Is it warm related? Have you tried using your hard drive for an extended period in the form of a freezer?



On the programmatic side, I will have a second thread keeping track of some progress counter, updated by a re-loop reading small amounts of data, then it can signal an error through the timeout you defined.

+6


source


You may be interested in robocopy ("Safe copy of a file"). Robocopy is a command line tool and it can carry over network outages and resume copying where it was previously disabled (incomplete files are datestamped as 1980-01-01 and contain a recovery entry so Robocopy knows where to proceed ).

You know ... I like being "lazy" ... Here's what I'll do:

I would write 2 simple scripts. One of them will start robocopy (with resiliency features disabled) and start copying, while the other will check periodically (perhaps trying to list the contents of the root directory and if it takes more than a few seconds then it's dead ... again ..) whether the disk is still working, and if the HDD stops working, it will restart the machine. Run them after logging in and set up automatic login so that when the machine is rebooted it will automatically continue.

+2


source


In terms of "I need to get my data back", if your data is really valuable to you, I would recommend sending the disk to a data recovery specialist. Depending on how valuable the data is, the cost (probably several hundred dollars) is trivial. Ideally, you will find a data recovery technician who doesn't just run any kind of recovery software - if the software approach doesn't work, they should be able to do things like swapping the board in a disk to disk, and possibly others (I not a data recovery specialist).

If the value of the data on the disk is not quite up to this level, you should consider purchasing one of the many data recovery software components. For example, I have personally used and recommend GetDataBack from the Runtime software http://www.runtime.org . I used it to repair a failed drive, it worked for me.

And now for more general information ... The standard process for recovering data from a failed disk is to do as little as possible on the disk itself. You should unplug the drive and stop trying to do anything. The drive is not working and it will probably get worse and worse. You don't want to play with him. You need to maximize your chances of data yield.

The way this process works is to use software that reads the block block by block (not file by file) and creates a copy of the disk image. The software tries to read each block and will repeat the read if they fail, and writes an image file that is an image of the entire hard drive.

After the hard drive has been mapped, the software then works against the image to identify the various logical parts of the drive โ€” partitions, directories, and files. And then it allows you to copy files from the image.

Software can usually "infer" structures from an image. For example, if the partition table is damaged or missing, the software scans the entire image, looking for things that might be partitions, and if they look like partitions enough, they will treat them as a partition and see if it can find directories and files. So good software is written using a lot of knowledge about the various structures on disk.

If you want to learn how to write this kind of software then good for you! My recommendation is that you start with books on how various operating systems organize data on hard drives, so you can start to get an intuitive feel for how software can work with disk images to extract data from them.

+1


source







All Articles