Skip to main content
improved formatting and cosmetic fixes
Source Link
monsune
  • 537
  • 2
  • 7

The MBR is basically a 512 byte segment on the very first sector of your hard drive and it is composed of 3 parts: the boot code (446 bytes long), the partition table (64 bytes long) and the boot code signature (2 bytes long). Not sure what went wrong on your side but this works for me:

This will definetly backup the boot code itself and nothing else:

[root@host]# dd if=/dev/sda of=/tmp/mbr.img_backup bs=446 count=1

[root@host]# dd if=/dev/sda of=/tmp/mbr.img_backup bs=446 count=1

Next you want to wipe the MBR clean including partition table which you don't wish to save together with bootcode signature:

[root@host]# dd if=/dev/zero of=/dev/sda bs=512 count=1

[root@host]# dd if=/dev/zero of=/dev/sda bs=512 count=1

And now you restore the boot code:

[root@host]# dd if=/tmp/mbr.img of=/dev/sda bs=446 count=1

[root@host]# dd if=/tmp/mbr.img_backup of=/dev/sda bs=446 count=1

The MBR is basically a 512 byte segment on the very first sector of your hard drive and it is composed of 3 parts: the boot code (446 bytes long), the partition table (64 bytes long) and the boot code signature (2 bytes long).

This will definetly backup the boot code itself and nothing else:

[root@host]# dd if=/dev/sda of=/tmp/mbr.img_backup bs=446 count=1

Next you want to wipe the MBR clean including partition table which you don't wish to save:

[root@host]# dd if=/dev/zero of=/dev/sda bs=512 count=1

And now you restore the boot code:

[root@host]# dd if=/tmp/mbr.img of=/dev/sda bs=446 count=1

The MBR is basically a 512 byte segment on the very first sector of your hard drive and it is composed of 3 parts: the boot code (446 bytes long), the partition table (64 bytes long) and the boot code signature (2 bytes long). Not sure what went wrong on your side but this works for me:

This will definetly backup the boot code itself and nothing else:

[root@host]# dd if=/dev/sda of=/tmp/mbr.img_backup bs=446 count=1

Next you want to wipe the MBR clean including partition table which you don't wish to save together with bootcode signature:

[root@host]# dd if=/dev/zero of=/dev/sda bs=512 count=1

And now you restore the boot code:

[root@host]# dd if=/tmp/mbr.img_backup of=/dev/sda bs=446 count=1

Source Link
monsune
  • 537
  • 2
  • 7

The MBR is basically a 512 byte segment on the very first sector of your hard drive and it is composed of 3 parts: the boot code (446 bytes long), the partition table (64 bytes long) and the boot code signature (2 bytes long).

This will definetly backup the boot code itself and nothing else:

[root@host]# dd if=/dev/sda of=/tmp/mbr.img_backup bs=446 count=1

Next you want to wipe the MBR clean including partition table which you don't wish to save:

[root@host]# dd if=/dev/zero of=/dev/sda bs=512 count=1

And now you restore the boot code:

[root@host]# dd if=/tmp/mbr.img of=/dev/sda bs=446 count=1