Thursday, February 28, 2013

Windows 8 Boot Recovery

A bizarre day of hard drive tinkering.

So one of Amber's hard drives started making the telltale grinding noises of impending doom. "It sounds like my computer is driving over a gravelly road... and now it's stuck at the Windows loading screen." she says. I groan; I know that particular sound means I'm probably already too late, and that the odds are distinctly not in my favor for getting any data off, but I promise to try to extract the data that evening.

So, I take the drive from her computer, connect it to one of my many SATA ports, and power up. Sure enough, the drive is sounding truly awful. But sadly, the presence of this drive has apparently confused the Windows 8 boot loader.

Lets take a step back. I have an "interesting" configuration. I run a 100GB RevoDrive, plus a 1TB SATA3 drive; System Partition is on the former. However, the latter is divided into three partitions. First is the "System Reserved" partition (which Windows always insists on putting on the SATA drive for some reason), then my data partition. Due to experimentation back in the Windows 8 Release Preview days, my third partition is a functional Win8RP partition. The configuration is by nature fragile, since the RevoDrive needs non-standard drivers, but I've never had install problems.

Back to the boot process. Windows 8 startup for some reason REALLLLLLLY wants to do stuff with the dying drive, and kicks off some repair. The repair freezes at 100%, the drive is sounding worse and worse. I can't exit back to the normal boot process, so I hard reset. Now this just makes Windows MAD! They decide that it's time to do "automatic repair", and decides to give the old Windows 8 RP build supremacy, presumably for being on the same physical disk as the reserved partition.

Now I'm totally screwed. RP has control, isn't showing any other boot options, and wants to reboot hourly to discourage me from using the pre-release OS any more. The standard recovery tools (notably bootrec.exe) are not actually available live, only in the recovery environment. So I write my Win8 ISO to a USB stick, reboot, and enter a repair command prompt. The recovery tools in Windows 8 should have no problem fixing me up, but unfortunately, the recovery paths that let you load drivers are mutually exclusive with the recovery paths that let me fix repair my boot sequence.

Well, reboots, and further frustration ensure. Long story short:
  1. Copy RevoDrive drivers to a second USB stick.
  2. Reboot to Windows 8 install. Choose "Repair my System".
  3. Find Windows 8 RP mounted on SATA drive.
  4. Run pnputil -i -a J:\path\to\driver.inf
    This loads the drivers from the command prompt! The tool isn't in the recovery environment for some reason, but seems the RP version worked fine.
  5. Run bootrec /fixmbr
  6. Run bootrec /RebuildBcd
    This is the magic. It scans all the fixed disks, and writes out the BCD to boot them properly. Now that the drivers are loaded, it's suddenly not even interested in RP anymore and finds my Windows 8 Pro release build.
After this, a quick reboot and my machine is functional again.

Needless to say, I've permanently deleted the RP partition, so Automatic Repair doesn't get smart with me again. Next up, proper backup recovery.

Want to know the funniest thing? After all that, the dead drive turned out to not be Amber's system drive (or even her data drive). It was just a leftover drive from when she needed the extra space for MMO clients. Her OS, and practically all the data she cared about was intact!  Who knows why Windows 7 refused to boot when the system partition was intact, but once the dying drive was removed, her computer was fine like nothing happened.