Thursday, 13 July 2017

How to repair bitlocker enabled Windows 7 boot sector.

At our office we are allowed to use only Windows on our laptops. However I am a looooong time Linux user.
I decided to install Linux OS on a USB pen drive and use it from there. However in process, when doing EFI stuff my windows boot loader was completely wiped out, rendering win 7 unbootable.

I have two partitions one 500MB hidden windows boot partition, second 2970GB C: with NTFS.

Now my laptop boots to a grub> prompt, which doesn't boot any thing further.

I used following steps to repair windows installation, if you are in same boat, these steps may help you.

1. Restore windows boot sector: Boot PC with windows repair disk and launch command prompt. Use following commands to repair boot sector.
        C:/> bootrec.exe /FixMbr
        C:/> bootrec.exe /FixBoot
        C:/> bootrec.exe /RebuildBcd

If you don't have bitlocker, the above mentioned steps should help you to recover win 7 installation. If you have bitlocker enabled, read on.

2. After this step my Laptop booted to following screen


3. Collect your bitlocker key. It should be a 48 byte key, normally 6 bytes are grouped in following format.
111111-111111-111111-111111-111111-111111-111111-111111

4. Boot your PC to command prompt by using windows recovery disk/usb. If your partition is hidden use following commands to unhide partition and associate drive letter to it. Mine partition was hidden and had to use disk part.

C:>DISKPART
This command will land you in diskpart shell.

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0                      NTFS   Partition    512 MB  Healthy    System
  Volume 1        SYSTEM       NTFS   Partition    297 GB  Healthy    Boot

DISKPART> select volume 1

Volume 1 is the selected volume.

DISKPART>assign letter=c
DISKPART>attributes volume clear hidden
DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0                      NTFS   Partition    512 MB  Healthy    System
* Volume 1     C   SYSTEM       NTFS   Partition    297 GB  Healthy    Boot

5. Unlock partition with following command and repair BDE
C:>manage-bde –unlock E: -recoverypassword 111111-111111-111111-111111-111111-111111-111111-111111

If this command is successful use following command to repair BCD
        
C:/> bootrec.exe /RebuildBcd

Reboot system.

After reboot bitlocker will ask 48 byte key.  Once you enter correct key, windows should boot normally.

Pl note bitlocker will ask 48 byte key at every boot. If you want to disable this behavior, open command prompt as administrator and use following commands.

C:>manage-bde –protectors –disable c:
C:>manage-bde –protectors –enable c:

Regards