I have two devices & mdash; the first one has 20 partitions and the second has one big partition. I would like to clone specific partition (content + data) from device one to device two.
How can I do this? How can I create in the second device the same partition with same features as the source partition?
For example, I want to duplicate the partition type, filesystem type, flags, ... etc of the original partition.

  • 1
    Since the second device currently has one big partition, how do you plan to make room for the data that you want to copy? Do you want to shrink the existing partition? What does it currently contain? – Gilles 'SO- stop being evil' Mar 15 '15 at 22:00

dd is your friend.

Example syntax:

dd if=/dev/sda1 of=/dev/sdb1 bs=1M

Alternatively you can dd the partition to a file and the dd the file to your target disk at a different offset.

For more information, type man dd in a console to find out the various uses and options.

Edit, modified example to show how to copy a partition.

  • That would copy the content of the whole disk (overwriting what is already there), not a specific partition. In addition, dd is very much not your friend: what you wrote is a complex, error-prone, potentially slower way of writing cat /dev/sda >/dev/sdb. – Gilles 'SO- stop being evil' Mar 15 '15 at 22:00
  • Thanks for the minus one. If you had read the man page it will tell you that you can also use dd to copy a partition. – captcha Mar 15 '15 at 22:02
  • You can, in the same way you can swim across a crocodile-infested swamp. That doesn't mean that the crocodiles are your friends. – Gilles 'SO- stop being evil' Mar 15 '15 at 22:18
  • I'll take personal responsibility if dd chews out a piece of your leg.. :) – captcha Mar 15 '15 at 22:36
  • @Gilles can you expand on why dd is dangerous and cat is good for copying drives (or drive partitions)? (I use dd to make copies of my system partition.) – gogoud Mar 16 '15 at 6:31

the partiton types are set using fdisk or equivalent, I don't know of an automated way to copy them. so you will have to set the type when you create the partition. or update the type manually after the creation.

  • 3
    This is a comment on the potential limitations of an answer, not an Answer. – Jeff Schaller Sep 15 '18 at 21:58

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.