With the major breakage, much needs to be done to get the system back to a usable state. But perhaps more importantly, I need to make a plan to make future recovery less frustrating.

A situation summary

I have explained what had happened here, but perhaps a description of my disks before the failure would make things clearer.

Hard Disk 0 (3TB, dead): rEFInd bootloader, two Linux installations, data partition for all systems;
Hard Disk 1 (1.5TB, near failing): Windows, Backup partition for important stuff.
SSD (1TB): Compilation cache and Linux Steam games.
Portable Disk 0 (2TB): Backup from 2015.
Portable DIsk 1 (2TB): Empty because I forgot its existence, the new Windows boot disk.
Flash Disk (8 GB, was missing when I needed it the most, but found later): Ubuntu 14.04 boot disk.

Installing Linux

With the flash disk missing, I had to borrow one to do the necessary stuff. Thankfully, both rEFInd and Gentoo Linux are terribly simple to install as long as one has access to gparted and efibootmgr. I created an installation in my SSD, then another one when my healthy replacement hard disk arrived.

And here is the trick: installing Linux when you already have a minimal but working one is even easier than the various installation guides and wizards tell you. All you need to do is a cp -ra command.

Following this logic, perhaps the Ubuntu boot disk was a bit overvalued by me. It was convenient, but if it were a live installation, it could have been more convenient by having all the tools I need at hand and without requiring a network connection.

Restoring Windows

Since my Windows installation was not actually wiped out, all I needed to do is to restore its boot information.

It happens in two steps: making a boot disk, and use the boot disk to restore things.

Making Windows boot partition

The usual guide goes thus: create a FAT32 partition, mount the ISO file downloaded from Microsoft, and copy everything into the said partition.

Well, then you see that most of such articles are pre-2018 where this procedure actually worked. But now, the ISO contains an install.wim file that is a bit too large for the old partition format to handle.

Unfortunately, 99% search results are crap in this regard. They either offer entirely wrong advice such as formatting the partition to exfat (won’t work unless you have a really weird BIOS), ask you to do something under Windows (which is a chicken-and-egg problem for me), or suggest me to use third-party tools with questionable credibility.

The real answer is simple but it took time to find out. It was an article by Ville Korhonen, with an adept subtitle, “What were they thinking?”

Basically, all I needed to do was to install the magical tool, wimtools. The tool can split install.wim into smaller files with an invocation like this:

wimlib-imagex split install.wim install.swm 250

Then I could just copy all the files except the original install.wim and I get a rescue partition.

Why, why are all the other articles unnecessarily complicated and obscure? What were they thinking?

(EDIT: another article suggests that one could also use wimlib-imagex optimize to compress the archives, which turned to be good enough for controlling the file size as well. I did not try that, but that definitely sounds simpler.)

Rebuilding Windows boot information

Again, there are many articles floating around on the Internet, but if you can prepare the partitions yourself, it is simpler than most of them suggest.

Actually, all I did was to look at this article and entered one command:

bcdboot C:\windows

Since I have only one Windows-recognizable partition and it was automatically assigned to C:.

And as expected, it created a working boot record but also automatically adjusted the boot order above rEFInd. It is… just part of life of dealing with dual boots. At least, there is no reason to panic when you already have two rEFInd installations and you knew that bcdboot would destroy at most one of them. (in reality, bcdboot did not harm either rEFInd, it only touched the boot order)

Conclusion

With multiple rEFInd partitions and multiple Linux installations, my system has not only returned to a working state, but probably more robust than ever.

I will also copy my mini-installation to all my external disks to further improve my chance of having something handy when another disk failure happens.

Windows remains a weak point since I am still not sure how to properly back up it, though.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.