Given HDD 1TB with a two partitions: one is small ~24GB (for Ubuntu) and all the rest is the second partition with about 10% occupied space for multimedia files.

I want to duplicate it as fast as possible. I boot from USB stick. The second disk is /dev/sdb.

sfdisk -d /dev/sda > a
sfdisk /dev/sdb < a

Then I copy bytewise the small partition:

dd if=/dev/sda1 of=/dev/sdb1 bs=4M status=progress

It takes about two minutes. Then I want to copy in optimal manner contents of the second partition. Just filesystem w/ file attributes:

rsync -avHAX /media/ubuntu/sda2dir /media/ubuntu/sdb2dir

After that I tried to boot from second HDD and can't.

How to copy MBR and other crucial information?

dd if=/dev/sda of=/dev/sdb takes about 1h20m for 1TB HDD. It is not acceptable. And seems also not works.


I would use Clonezilla

Get a Clonezilla iso file, make a USB boot drive, and boot from it.

See the documentation on clonezilla.org.

Use Clonezilla to clone the whole drive. This will work if

  • the target drive is at least as big as the source drive. You can check that (if the sizes are nominally the same) with

      sudo parted /dev/sdx u B p
    

where x can be for example a (/dev/sda) and b (/dev/sdb) for the two drives. The target drive must not be one single byte smaller than the source drive.

  • the physical sector sizes of the two drives are the same. You can check that with

      sudo parted -ls
    
  • if the drive sizes are different, and the partition table is GPT, you must also repair the backup table at the end of the drive. You can do that manually with gdisk or with the shellscript gpt-fix

Clonezilla is smart enough to copy/clone only the used data blocks on the drive and skip unused blocks, so it is faster than cloning with dd, particularly when there is a lot of unused drive space (as in your case).

Clonezilla is also safer than dd, because it has a user dialogue that helps you to check and double-check that you will clone to the correct target device. dd does what you tell it to do without questions. A minor typing error can make you overwrite the family pictures.


Please notice that Clonezilla can

  • clone a drive to another drive of at least the same size
  • create a compressed image (a directory with a number of files)
  • clone a partition and create an image of a partition
  • restore from a compressed Clonezilla image to a drive of at least the same size
  • work locally or via a network