0

I have a laptop with 500GB internal HD and a external 500GB USB HD.

I boot up with a linux live cd over the top of my Windows 8.1 machine.

My goal is to clone the MBR, partition 1(350mb), and partition 2(40GB)

The command I will be using to clone the /dev/sda MBR is

dd if=/dev/sda of=/dev/sdb bs=512 count=1

Below is what our source /dev/sda looks like via fdisk -l

Disk /dev/sda: 465.9 GiB, 500277790720 bytes, 977105060 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xb77d45d7

Device    Boot     Start       End   Blocks  Id System
/dev/sda1 *         2048    718847   358400   7 HPFS/NTFS/exFAT
/dev/sda2         718848  81922047 40601600   7 HPFS/NTFS/exFAT

Below is what our target drive looks like

Before running dd cmd

Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 488386584 sectors
Units: sectors of 1 * 1024 = 1024 bytes
Sector size (logical/physical): 1024 bytes / 1024 bytes
I/O size (minimum/optimal): 1024 bytes / 1024 bytes
Disklabel type: dos
Disk identifier: 0xb77d45d7

After running dd cmd

Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 488386584 sectors
Units: sectors of 1 * 1024 = 1024 bytes
Sector size (logical/physical): 1024 bytes / 1024 bytes
I/O size (minimum/optimal): 1024 bytes / 1024 bytes
Disklabel type: dos
Disk identifier: 0xb77d45d7

Device    Boot     Start       End   Blocks  Id System
/dev/sdb1 *         2048    718847   716800   7 HPFS/NTFS/exFAT
/dev/sdb2         718848  81922047 81203200   7 HPFS/NTFS/exFAT

We can see that our target block size for both partitions is double the source block size partitions after running the dd cmd.

What can cause this?

Putting this matter aside, I continued with my dd attempt to clone my HD with

dd if=/dev/sda1 of=/dev/sdb1 bs=4096
dd if=/dev/sda2 of=/dev/sdb2 bs=4096

However this fails to boot - I am wondering if its because of the double size data have some other bad effect.

The BIOS does show the external HD as a boot option with the same name of the internal HD, but it just hangs after selecting it as the boot disk (no error returned)

  • After you overwrite a partition table with something like dd, you should reboot or run `partprobe‘. Try that and see if things look better. – Mark Plotnick Jul 17 '16 at 14:03
2

The dd command copied exactly 512 bytes as requested.

Your main source of confusion comes from the fact that /dev/sda has a logical sector size of 512 bytes while /dev/sdb sectors are 1024 bytes.

The partitions otherwise appear identical.

The MBR in no way affects the size used by files on the partitions either. The fact that it doesn't boot is probably much more reflected by the fact that the MBR is not adapted to that drive's configuration.

To make it bootable, mount it, mount required mounting points like /dev/, /proc, /sys on it, and use chroot to run your boot loader.

Update: As pointed out by @sourcejedi, the partition table is corrupted on /dev/sdb. This is obviously the result of the copy of the MBR which holds the partition information.

If you didn't change anything on the filesystem and know the original configuration, which I suspect matched the other drive, simply delete and recreate the partitions to fix this.

  • Good catch but "identical" is misleading. The "Blocks" column is always in units of 1Kb. The partitions on the second drive are actually twice as large - they're not matched up with the copied data! – sourcejedi Jul 16 '16 at 18:05
  • @sourcejedi: You're right! I updated my answer to address it. – Julie Pelletier Jul 16 '16 at 19:19
  • @JuliePelletier When you say to "simply delete and recreate the partitions to fix this" - If I delete them I will have to run dd on them again as the data would be gone(os, system partition), doing this will result in the partitions being made twice as large again. - Back to square one. – Jimbo'sGun's Jul 17 '16 at 12:29
  • @Jimbo'sGun's: Deleting the partitions only affects the partition table at the beginning of the disk. If the data was copied properly and you recreate the partitions exactly like they were, you will not have to recopy the contents. – Julie Pelletier Jul 17 '16 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.