title: How to read an intermittent hard drive consistently?
body: <p>I have a faulty hard drive that works intermittently. After cold booting, I can access it for about 30-60 seconds, then the hard drive fails. I'm willing to write a software to backup this drive to a new and bigger disk. I can develop it under GNU/Linux or Windows, I don't care.</p>
  
  <p>The problem is: I can only access the disk for some time, and there are some files that are big and <strong>will take longer than that to be copied</strong>. For this reason, I'm thinking of backing up the entire hard disk in smaller pieces, something like bit torrenting. I'll read some megabytes and store it, before trying to read another set. My main loop would be something like this:</p>
  
  <pre><code>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; }
  }
  </code></pre>
  
  <p>The problem is the check_harddrive() function. I'm willing to write this in C/C++ for maximus API/library compatibility. I'll need some control over my file handlers to check if they are still valid, and I need something to return bad data, but return, if the drive fails during the copy process.</p>
  
  <p>Maybe C# would give me best results if I abuse "hardcoded" hardware exceptions?</p>
  
  <p>Another approach would be measuring how much time would I need to power cycle my harddrive and code a program to read it during this time only, and flagging me when to power cycle.</p>
  
  <p>What would you do in this case? Are there any tools/utilities that already do this?</p>
  
  <p>Oh, there is a GREAT app to read bad optical medias <a href="http://www.geocities.com/marsoupilamis/DocEnglish.htm" rel="nofollow noreferrer" title="IsoPuzzle">here</a>, it's called IsoPuzzle, it's not mine, I just wanted to share something related to my problem.</p>
  
  <p>!EDIT!</p>
  
  <p>Some clarifications. I'm a home user, a student of computer engineering at college, I'd rather lose the data than spend thousands of dollars recovering it. The harddrive is still covered by Seagate's warranty, but since they gave me 5 years of warranty, I wanna try everything possible until the time runs out.</p>
  
  <p>When I say cold booting, I mean booting after some seconds without power. Hot booting would be rebooting your computer, cold booting would be shutting it down, waiting a few seconds then bootting it up again. Since the harddisk in question is internal but SATA, I can just disconnect the power cable, wait a few seconds and connect it again.</p>
  
  <p>Until now I'll go with robocopy, I'm just searching for it to see how I can use it. If I don't need to code myself, but script, it'll be even easier.</p>
  
  <p>!EDIT2!</p>
  
  <p>I wasn't clear, my drive is a Seagate 7200.11. It's known that it has a bad firmware and it's not always fixable with a simple firmware update (not after this bug appears). The drive physically is 100% in working condition, just the firmware is screwed, making it enter on a infinite busy state after some seconds.</p>