Clone/Copy hdd/MBR

sfdisk -d /dev/sda | sfdisk /dev/sdb   (clone partition table sda to sdb)

Backing up the MBR

The MBR is stored in the the first 512 bytes of the disk. It consist of 3 parts:

  1. The first 446 bytes contain the boot loader.
  2. The next 64 bytes contain the partition table (4 entries of 16 bytes each, one entry for each primary partition).
  3. The last 2 bytes contain an identifier
If you only want to restore the boot loader,
but not the primary partition table entries, 
just restore the first 446 bytes of the MBR:

dd if=/dev/sda of=/dev/sdb bs=446 count=1 
dd if=/dev/sda | ssh username@host "dd of=/mnt/hdd.img" (dump image over network)
ssh username@host "dd if=/mnt/hdd.img" | dd of=/dev/sda (clone network image to ur drive)
dd if=/dev/sda1 of=/dev/sdb1 bs=4096 conv=notrunc,noerror (copy partition )
To increase the speed use bs=100M for instance
To view the copy progress find dd PID and watch -n 5 'kill -USR1 PID' 
or install pv and use :
dd if=/dev/sda1 bs=4M | pv -s 60G | dd of=/dev/sdb1 bs=4M

The bs=4M argument sets the blocksize for dd operations to 4MB, which 
drastically improves the clone speed.
And the -s 60G argument tells pv how big the operation is expected to be, 
so it can give you an ETA as well as a current speed.
This entry was posted in Linux and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *