Monday morning. Arrive at the office with lots to do. Switch on the computer, and…
That’s not what I wanted to see. There’s lots of advice out there on the web about fixing this problem, but it turned out not to be so straightforward.
The first step was to get hold of a bootable Windows 10 installer. That entailed installing a desktop and web browser on my office Debian Linux machine which normally runs withou a monitor. Downloading the image from Microsoft was easy enough, though it’s 4.5GB in size so takes a while. I wrote it to a USB stick (which I had to go and buy, of course) and…nothing. It turns out that the Windows 10 .iso image is only suitable for writing to a DVD, and is not a ‘hybrid’ image which can work also on a USB stick. Of course, I didn’t have any blank DVDs lying around, did I?
Luckily Linux was able to mount the .iso image so I could see the files inside it. That meant it was possible to reformat the USB stick, creating a single partition formatted FAT32, and copy the files on to it.
This ran in to a problem because the main archive of Windows files, /sources/install.wim, is just over 4GB in size and thus can’t be written to a FAT32 filesystem in its entirety. I tried to fix this by formatting the stick in ExFAT or NTFS, but my PC’s motherboard (an Asus Z77-Wifi) can’t boot from those filesystems so that didn’t get anywhere. I suspect the right answer is to use UEFI boot, creating a FAT32 partition with the EFI folder on it, and a separate NTFS partition with the other files on. But I was in too much of a hurry for that and decided to just put up with a slightly truncated install.wim file.
Now I had a bootable Windows 10 recovery/install USB stick. Great! The advice from Microsoft is to use the ‘fix startup problems’ option available on the menu. So I did that, and it spent a while diagnosing, then proclaimed that it couldn’t fix my PC. Great. I tried the other options (returning to a system restore point, removing the latest updates) but they all denied that my PC had Windows 10 on it at all.
This is getting annoying. Time to break out the command line, which is probably the most useful tool in the Windows 10 recovery toolkit. The official advice from Microsoft is to do this:
bootrec /scanos bootrec /rebuildbcd bootrec /fixmbr bootrec /fixboot
But the /rebuildbcd stage failed for me, with a ‘The requested system device cannot be found’ error. The next advice I found was to manually reconstruct the BCD (the Boot Configuration Data, which tells the boot process where to find the operating system) by doing:
But that didn’t work either.
I had to dig deeper. Luckily I’m not the only person to have had this problem. This page at screwloose.com.au explained more advanced use of bcdboot, in which it’s possible to tell the tool where the Windows installation lives, and where the System partition which holds the boot information is. I had to rummage round with diskpart to find the right drive letters, because the layout of the partitions on my drive meant that they were not the same as during normal operation. However, I came up with the following:
bcdboot e:\windows /l en-gb /s g: /f all
which worked! It completed successfully! Reboot and…the error was still there. Looking more deeply with diskpart, it turned out that the 100MB partition (drive G:) that was supposed to be the startup partition was formatted NTFS and wasn’t marked as active. The screwloose page indicates that the startup partition needs to be formatted as FAT32 and marked as active. Clearly, formatting it FAT32 deleted all the data on it, so I ran the bcdboot command again to re-create it.
Success! After a shutdown, the PC booted and came up as if nothing had happened. I’m happy that it’s working again, but it’s still a mystery how the error occurred. Something must have got corrupted, but I can’t believe that the entire contents of the startup partition got erased and replaced with an NTFS filesystem.