Monday, 1 January 2018

Windows Winre.wim missing and Windows fail to boot

Winre.wim Restoration

This is a brief review of the steps to restore Winre.wim in C:\Windows\System32\Recovery

First, we confirm the Win RE tool is activated:
Eins) reagentc /enable

Next, we remove 'hidden' and 'system' attributes:
Zwei) attrib -h -s C:\Recovery\WindowsRE\Winre.wim

Then, we copy the Winre.wim file to Recovery
Drei) xcopy /h C:\Recovery\WindowsRE\Winre.wim C:\Windows\System32\Recovery

We ensure that Win RE tool remains activated
Vier) reagentc  /enable

The windows recovery environment should work.

BootCD repair for a Dual OS (GNU/Linux and Windows)

First we find out the system reserved partition or system partition in short:
A) diskpart

B) list disk

Assuming X is the drive where Windows is installed on,we select to view the ntfs partitions existing on the drive:
C) select disk X

We can see where is the system partition using the below command:
D) list volume

E) exit

NB: The system partition should be between 100MB (Windows 7 upgrade install to Windows 10) to 500MB (normal Windows 10 clean setup)

Now, we proceed to backup the existing BCD file:
F) bcdedit /export C:\backup

NB: Assuming C: is the existing system partition label

We remove the 'hidden', 'read-only' and 'system' attributes of the BCD file:
G) attrib -h -r -s C:\Boot\BCD

We delete the old BCD file:
H) del C:\Boot\BCD

Finally, we rebuild the BCD file:
I) bootrec /rebuildbcd

We should be able to boot into Windows and we proceed to restore grub for GNU/Linux, for  e.g. Ubuntu by booting into a Ubuntu Live CD or any of its variants.

We open the terminal and find out the partition marked as Ubuntu partition:
J) sudo blkid

Then, we proceed to mount the Ubuntu partition (suppose Ubuntu is installed on /dev/sda3)  for repairing grub:
K) sudo mount /dev/sda3 /mnt

We bind mount the respective directories for grub repair installation:
L) for x in /dev /dev/pts /proc /sys /run; do sudo mount -B $x /mnt$x; done

We can now work on the Ubuntu partition live using chroot command and the root tag should be seen in the terminal:
M) sudo chroot /mnt

We install grub on the harddrive mbr (if you are using legacy BIOS):
N) grub-install /dev/sda 

We rebuild the grub configuration file:
O) update-grub

P) exit

We can unmount the respective directories that we mounted in step 'l', we can use 'up' arrow to move back to the previous command; 'ctrl-A' to move to the initial position of the command to edit:
Q) for x in /run /dev/pts /proc /sys /dev; do sudo umount /mnt$x; done

NB: note that '/dev' should be in last position for the 1st part of command (delimited by ';' separator) to work.

Finally, we unmount the Ubuntu partition:
R) sudo umount /mnt

(optional) We use the command below to confirm that Ubuntu partition and the concomitant directories are unmount :
s) lsblk -la

We then exit the terminal and restart.
t) exit