Windows Partition Boot Deleted

From Super Grub Disk Wiki
Jump to: navigation, search

I have deleted my Windows boot partition.

Contents

Other Titles

I have used Windows chainloads Grub but I selected the Windows partition (my mistake!)

Introduction

Windows boot is in fact a two steps process. First we need to be able to chainload the Windows partition, which can be done with Boot of Windows option. Then there should be something at the very beginning of the Windows partition. Usually there is (that why in most of the cases Boot of Windows will boot it) something but sometimes we might deleted it.

One way of deleting it is using the Windows chainloads Grub option and select the Windows partition instead of the Linux one.

It seems that in the NTFS partitions there is a boot record backup at its last sector. Recovering the first boot sector is as easy as being able to copy last sector to first sector. Sometimes, people are unlucky, the last sector is empty and there is no backup in it.

Super Grub Disk option

I am working in an option to do that last sector backup to first sector restore. If you see that the option is too old please complain at the super grub disk forum or mailing list.

Manual method

Introduction

starvingartist was trying to install Linux in a external hard disk and he selected the windows partition in the windows chainload grub step! Now the Boot of Windows option no longer works for him. Let's see how to help him.

Specs

After running sfdisk -lu starvingartist gives us all the information we need to give him the command to issue.

root@ruben-laptop:/home/ruben# sfdisk -l

Disk /dev/sda: 7296 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1   *      0+   7294    7295-  58597056    7  HPFS/NTFS
/dev/sda2          0       -       0          0    0  Empty
/dev/sda3          0       -       0          0    0  Empty
/dev/sda4          0       -       0          0    0  Empty

Disk /dev/sdb: 499 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdb1          0+    470     471-   3783276   83  Linux
/dev/sdb2        471     498      28     224910    5  Extended
/dev/sdb3          0       -       0          0    0  Empty
/dev/sdb4          0       -       0          0    0  Empty
/dev/sdb5        471+    498      28-    224878+  82  Linux swap / Solaris


Last Sector Number

NTFS partition has 58597056 blocks. What's the last 512 bytes of it? 58597056 blocks * (1024 bytes/1 block) * (1 sector / 512 bytes) = 117194112 sectors (of 512 bytes) The last sector is found at: 117194112. How many sectors should be skip before reading 117194112th sector? 117194111 (Yes, you have guessed it, minus 1)

The Restore Command

Now we are using dd command as root to do the actual restore.

dd if=/dev/sda1 of=/dev/sda1 count=1 bs=512 skip=117194111 seek=0

Now if he tries to boot Windows he should be able to do so (unless its backup is empty :().