I took an extra day off at the start of the year to use up my annual leave and play computer games all day. I ended up spending half of the day trying to fix my PC which wouldn’t boot, and the other half playing the very well put-together Ratchet and Clank: A Crack In Time on the PS3.
What follows is a geeky but therapeutic (for me) account of how I fixed the problem with my PC over two days.
The problem: my BIOS settings had all disappeared, the keyboard wouldn’t work and Windows 7 wouldn’t boot. I don’t yet know how these two things are related.
I have no idea what is going on with the BIOS settings. Perhaps the motherboard is faulty. This has happened twice, and both times after hibernating, so I suspect there is some problem with that. I eventually found that unplugging and plugging the keyboard enough times in enough different USB sockets got the keyboard working and I could sort out my BIOS settings.
The next problem is that the disk booted to the GRUB rescue prompt. I still don’t understand why. My system disk is an Intel SSD, and I only once ever installed Linux on it when I first got it. After playing for a while I installed Windows 7 over the top. So perhaps Grub was not removed by Windows and the master boot record was corrupted leaving it the first thing to boot. I booted to an old Ubuntu live CD and used dd to look at the MBR. It contained the srting “GRUB” and nothing about Windows. Hmm.
I booted the Windows 7 DVD and tried the automatic “Startup Repair” option. It said that the partition table was missing and had fixed the problem, but it made no difference. So I tried the diskpart.exe tool using the rescue command prompt. This revealed only one big partition.
I was expecting more because I was using BitLocker to encrypt the drive. It’s possible Startup Repair doesn’t work with BitLocker and all I had achieved was creating a bogus partition table. I quickly gave up hope of fixing anything.
Enter the repair-bde.exe tool. This is a download from Microsoft but is also included on the Windows 7 DVD. It promised to be able to fix the BitLocker boot sector, but this failed with a cryptic error message about the meta-data not being aligned on a cluster boundary. I put this down to the dodgy partition table. The other thing repair-bde.exe can do is decrypt your data to another disk. Once I obtained a big enough disk, this seemed to work fine. I could now see all my files on the new disk.
Before restoring these files to my SSD, I wanted to check that Windows would boot from the disk I had restored my files to. The disk wouldn’t boot, so I used diskpart.exe to make the partition active and bootrec.exe /FixMbr and /FixBoot to make it bootable. This left me with a “BOOTMGR not present” message on boot. Booting to the Windows 7 DVD revealed a dialogue saying that problems had been detected and could automatically be fixed. But that didn’t work, so next time I tried the Startup Repair wizard again. Finally, “Starting Windows”!
Next I wanted to clone the recovered disk back to the SSD. Enter CloneZilla. Not only is it free as in speech and beer, it runs off a bootable CD, which is handy when you’re fixing PCs with broken system disks. And it is easy to use: its beginner mode is as simple as selecting source and destination disks.
Schoolboy error: the disk I’d recovered my files to was bigger than the SSD, so CloneZilla refused to clone the big one to the small one. Back into Windows 7, I thought I could use the Shrink Volume option in Disk Management to make the partition smaller. But it reported that the smallest size I could go to was 240GB — still bigger than the original disk. Aargh! Even defragmenting didn’t help, and in any case trying to shrink failed with the message, “parameter is incorrect”. The same happened when using diskpart.exe to shrink.
Then I found Parted Magic, another bootable ISO for managing partitions. This boots into a (very pretty) graphical interface that includes the GParted tool, which managed to resize my partition to 120GB with no fuss whatsoever. I have no idea why the Windows tools had to make such a song and dance about it.
Things were looking up. CloneZilla was still making a bit of a fuss, this time saying that the filesystem needed checking, probably because I had just resized it. It helpfully said that booting into Windows would solve this, and sure enough it did. Error messages that tell you how to solve the problem are always good.
The cloning took 12 minutes and then finally, mercifully, I was booting from my SSD once more. The last step was to re-grow the partition back to the full 160GB of the SSD using Disk Management, which was trivial.
Later when I am feeling braver, I will re-encrypt and perhaps try hibernating again to see if that will reproduce the problem. If the problem comes back randomly then a new motherboard may be needed. Hopefully not a new SSD though, diagnosing that sort of problem would be painful.
I will also be using my new hard disk and CloneZilla to take regular images of my system disk — I am newly converted to the idea that this is a useful thing to do.
To sum up, I was impressed with a lot of the tools I used. I was impressed that the Windows 7 rescue command prompt was so powerful. I was impressed that repair-bde.exe was included and worked so well. But mostly I was impressed with CloneZilla and Parted Magic: that two such mature and easy-to-use tools are freely available is a testament to the open source community.
Update: Re-BitLocker-ing the system disk was more urgent that I thought because Windows can’t automatically unlock other disks unless the system disk is encrypted. Because whereas Windows 7 reserves a small partition when it is installed, but the above process left me with one single partition on the system disk, the automatic BitLocker drive preparation failed. Each time I tried it, the reboot left me with the “BOOTMGR not present” message, and I had to run the startup repair wizard. The solution was to manually prepare the disk with the command bdehdcfg -target c: shrink .