Skip to main content
added note
Source Link
Freddy
  • 26.3k
  • 1
  • 27
  • 64

My understanding of MBR disks is that the first 446 bytes is the bootstrap code area. And with the subsequent 64 bytes being the partition table makes up the familiar 512 bytes of MBR.

Yes, almost. 446 + 64 = 510 bytes, you forgot two bytes for the disk signature, i.e.0x55aa at offset 510 for MBR style disks.

Is it as simple as dd if=/dev/sdb of=/dev/sdc bs=446 count=1 ?

Yes. Make sure to make a backup of the whole 512 bytes to a file on a different disk before doing so. This can save you a lot of trouble.

Will bootstrap code be the same on every MBR disk, or does it need to be modified to work on the destination disk? If modified, then how?

It depends on the OS and the bootloader (Grub, syslinux, Windows,...), so the code might differ. In your case it shouldn't matter as you clone the disk, just with different partition offsets and sizes.

What does the bootstrap code do?

It's usually used to determine the active partition and load a second stage boot loader off the boot sector of the active partition since the whole boot code doesn't fit into the MBR.

Just as an example: On an old laptop I'm triple booting Win10, Debian and OSX. If I set the the first partition active, it boots Windows, if the second partition is active it loads Grub (installed on the boot sector of the partition, not on the MBR), if the third partition is active it loads a hackintosh bootloader. I'm not sure if the bootstrap code is the original Windows code or from the hackintosh bootloader. They both used to work.

Note: I don't know how you copy the partitions to the destination disk, but I would suggest you resize the partitions on the source disk to their destination sizes (gparted).

Then
a) create a partition table on the destination disk with the same sizes and copy the partitions with dd
or
b) use gparted, create a clean MBR partition table on the destination disk and copy the partitions.

When done, copy the bootstrap code to the destination disk. This way you make sure that all data is copied and the filesystems stay intact. When done, you can resize the partitions on the source disk back to their original sizes.

Related:

My understanding of MBR disks is that the first 446 bytes is the bootstrap code area. And with the subsequent 64 bytes being the partition table makes up the familiar 512 bytes of MBR.

Yes, almost. 446 + 64 = 510 bytes, you forgot two bytes for the disk signature, i.e.0x55aa at offset 510 for MBR style disks.

Is it as simple as dd if=/dev/sdb of=/dev/sdc bs=446 count=1 ?

Yes. Make sure to make a backup of the whole 512 bytes to a file on a different disk before doing so. This can save you a lot of trouble.

Will bootstrap code be the same on every MBR disk, or does it need to be modified to work on the destination disk? If modified, then how?

It depends on the OS and the bootloader (Grub, syslinux, Windows,...), so the code might differ. In your case it shouldn't matter as you clone the disk, just with different partition offsets and sizes.

What does the bootstrap code do?

It's usually used to determine the active partition and load a second stage boot loader off the boot sector of the active partition since the whole boot code doesn't fit into the MBR.

Just as an example: On an old laptop I'm triple booting Win10, Debian and OSX. If I set the the first partition active, it boots Windows, if the second partition is active it loads Grub (installed on the boot sector of the partition, not on the MBR), if the third partition is active it loads a hackintosh bootloader. I'm not sure if the bootstrap code is the original Windows code or from the hackintosh bootloader. They both used to work.

Related:

My understanding of MBR disks is that the first 446 bytes is the bootstrap code area. And with the subsequent 64 bytes being the partition table makes up the familiar 512 bytes of MBR.

Yes, almost. 446 + 64 = 510 bytes, you forgot two bytes for the disk signature, i.e.0x55aa at offset 510 for MBR style disks.

Is it as simple as dd if=/dev/sdb of=/dev/sdc bs=446 count=1 ?

Yes. Make sure to make a backup of the whole 512 bytes to a file on a different disk before doing so. This can save you a lot of trouble.

Will bootstrap code be the same on every MBR disk, or does it need to be modified to work on the destination disk? If modified, then how?

It depends on the OS and the bootloader (Grub, syslinux, Windows,...), so the code might differ. In your case it shouldn't matter as you clone the disk, just with different partition offsets and sizes.

What does the bootstrap code do?

It's usually used to determine the active partition and load a second stage boot loader off the boot sector of the active partition since the whole boot code doesn't fit into the MBR.

Just as an example: On an old laptop I'm triple booting Win10, Debian and OSX. If I set the the first partition active, it boots Windows, if the second partition is active it loads Grub (installed on the boot sector of the partition, not on the MBR), if the third partition is active it loads a hackintosh bootloader. I'm not sure if the bootstrap code is the original Windows code or from the hackintosh bootloader. They both used to work.

Note: I don't know how you copy the partitions to the destination disk, but I would suggest you resize the partitions on the source disk to their destination sizes (gparted).

Then
a) create a partition table on the destination disk with the same sizes and copy the partitions with dd
or
b) use gparted, create a clean MBR partition table on the destination disk and copy the partitions.

When done, copy the bootstrap code to the destination disk. This way you make sure that all data is copied and the filesystems stay intact. When done, you can resize the partitions on the source disk back to their original sizes.

Related:

Source Link
Freddy
  • 26.3k
  • 1
  • 27
  • 64

My understanding of MBR disks is that the first 446 bytes is the bootstrap code area. And with the subsequent 64 bytes being the partition table makes up the familiar 512 bytes of MBR.

Yes, almost. 446 + 64 = 510 bytes, you forgot two bytes for the disk signature, i.e.0x55aa at offset 510 for MBR style disks.

Is it as simple as dd if=/dev/sdb of=/dev/sdc bs=446 count=1 ?

Yes. Make sure to make a backup of the whole 512 bytes to a file on a different disk before doing so. This can save you a lot of trouble.

Will bootstrap code be the same on every MBR disk, or does it need to be modified to work on the destination disk? If modified, then how?

It depends on the OS and the bootloader (Grub, syslinux, Windows,...), so the code might differ. In your case it shouldn't matter as you clone the disk, just with different partition offsets and sizes.

What does the bootstrap code do?

It's usually used to determine the active partition and load a second stage boot loader off the boot sector of the active partition since the whole boot code doesn't fit into the MBR.

Just as an example: On an old laptop I'm triple booting Win10, Debian and OSX. If I set the the first partition active, it boots Windows, if the second partition is active it loads Grub (installed on the boot sector of the partition, not on the MBR), if the third partition is active it loads a hackintosh bootloader. I'm not sure if the bootstrap code is the original Windows code or from the hackintosh bootloader. They both used to work.

Related: