Recently in the backup, restore test of the disk, use the DeviceIoControl in WindowsAPI to back up, restore the disk layout, and then sequentially, in the corresponding order, copy the data from each partition of the source disk, but when you start the target disk as the startup disk, The screen appears with a black screen and a blinking cursor, viewing the data as a problem with the MBR being destroyed. Use Winhex to view the MBR of the target disk, boot code good, look at the boot partition DBR, found that the BPB parameter in the number of tracks sector, the number of heads and the source drive is different, so modify these two parameters, so that the same as the source hard disk, modified disk can start, the system starts normally.
However, when testing the program under WindowsXP, it was found that the target disk could not be started even if the BPB parameter of the boot partition was modified. After careful analysis of the MBR discovery of the target disk, there is a problem with the CHS parameter in the partition table that initiates the partition, the CHS parameter computed from the start sector is different from the partition, the CHS parameter is recalculated and the disk is populated with the MBR, and the disk can be started.
After many experiments, the following conclusions are drawn:
1: The system at boot will check the CHS parameter in the MBR and the BPB parameter of the boot partition is correct, but it is not always the case, after testing XP, Vista, 2003, 2008, Windows7, WINDOWS8, found only XP, 2003 the system is required to be so strict at startup;
2: After you set up disk layout with WindowsAPI DeviceIoControl, the CHS parameter in the disk MBR partition is not necessarily correct, but does not affect the use of the partition, but if the CHS parameter of the boot partition is incorrect, the system may not start and needs to be modified manually.
3: The BPB parameter in the partition DBR is automatically generated when the partition is formatted, the disk is restored without modification, the system can be started after the modification, the root cause is that the CHS parameter in the disk MBR is wrong, resulting in the need to use the wrong BPB parameter (number of track sectors, number of heads).
This article is from the "jsl_mes" blog, make sure to keep this source http://jslmes.blog.51cto.com/5008224/1627743
MBR and DBR repair after disk restore