An Experience of Fixing Windows under Arch Linux
Issues began while I forced poweroff my laptop when win was updating itself after shutdown...
Background
Months ago I just stepped into Arch and made my laptop into a dual boot with win. After using Arch I found it actually pretty well so my main OS turned into it.
Begin
Days ago my win updated itself and stuck, then I forced poweroff.
This was just like what happened
as usual
, so I didn’t pay much attention to it.
And the next day on Arch I found one of the partitions was locked by win’s protection mechanism - turns the all partitions (of course ones it can recognize) into read-only
if it was not closed properly before shutting down. So the first thing I reminded was to reboot the win…
First Attempt to Fix - Using PE
So I tried to reboot into win, but it took me a long time to load and finally nothing happened, and my fan spinning loudly.
I’ve rebooted my computer many times, but it still doesn’t work. So I realised that I should try to run PE to check the problem.
By the way my USB drive was used to install Arch and formatted before so I need to reinstall PE.
By the way again EtchDroid is easy to use. The last time I haven’t installed Arch to save my win it helped me a lot.
Then plugged into my laptop and tried to boot in PE, but also stuck on the same screen.
Reboot. And stuck on black screen and my fan spinning loudly.
This time I started being scared. Quick rebooted my computer and tried to boot into Arch, and it worked.
Reasoning
So, Arch could boot but not for Windows, there was an horrible idea came to my mind - the bootloader has been corrupted. Then I realised the last time I saved the bootloader with PE and when I’m going to use it to fix, “Wait, I just could not boot PE innit?”
Facing these problems, there was another horrible idea came to my mind - the motherboard has been corrupted.
But my Arch booting was based on systemd-boot, which is UEFI-based while my Windows bootloader is also UEFI-based.
So both of them are UEFI-based, WHY THE HELL CAN’T I BOOT PE?
So I try to rebuild the bootloader. Having checked the ESP was mounted on /efi instead of /boot, here I used efibootmgr
.
I removed the loader of Windows’, then removed the config file to avoid BIOS rebuild itself. After that I tried to boot PE again, but still nothing.
Later I’ll use
A
to refer to one of my disks that contains Windows,B
for Arch contains.
The next day I removed disk A
and tried to boot PE, it worked!
So what happened to my drive A
it went without saying. Returning to my Arch, I tried to check the problems under it…
Fixing in Arch
I supposed that while booting PE, it will mount all of the partitions of each drive. So I tried one thing…
sudo gdisk /dev/nvme0n1 # that's drive A
btw the first time to use fdisk simmilar to gdisk was the first install of Arch…
Command (? for help): t
Partition number (1-9): 3
Current type is 700 (Microsoft basic data)
Hex code or GUID (L to show codes, Enter = 700): 8300
Changed type of partition to 'Linux filesystem'
Command (? for help): w
Do you want to proceed? (Y/N): y
So I changed the partition 3 (system partition) to linux filesystem and I had the confidence that I was going to be able to boot into PE. Finally the target became more exactly.
Went through all the way I’ve gone, the culprit was the auto-update of win on July 26th. For a long time searching, target locked to the Registry
.
Mount the partition 3 to /mnt/windows, then
sudo chntpw -e /mnt/windows/Windows/System32/config/SYSTEM
> cd \ControlSet001\Services
\ControlSet001\Services> cd storport
output:
Key storport not found!
So, with my poor knowledge of registry, and the power of Google, I just created a new key named storport and do some other actions…
Alright, I don’t wanna fix it anymore. For one, I don’t know what to do with it because I’m not familiar with Windows registry. For another, it bothers me a lot!
Before Reinstalling
I supposed that there must be one kit by Microsoft to fix this problem. But before this I have to boot PE with this corrupted 0700 partition instead of linux filesystem. Then I realized one thing - there is
diskpart
in Windows (or PE), which is just like fdisk
and gdisk
in linux.
So the route is:
- gdisk the partition 3 into 8300
- boot PE
- diskpart the partition 3 into 0700
- use some kit to fix the issue of registry
- my Windows will recover
My disk A
uses a GPT partition scheme so there is a little difference to set.
But… it failed with its sticking for a long time 😅
Reinstalling
If you can’t fix it, reinstall it.
Since I can boot Arch and mount the partition, I started to backup my data and reinstall Windows. Different from the previous experience of BCD lost, there may be no way for me to fix the issue. And as we all know, Windows, provides too less measure to touch the underlayer, quite different from Linux.
btw I dont wanna use win anymore