2

This question already has an answer here:

I have two HDDs: the first of 150gb (/dev/sdc) with 30gb in use, the second of 100gb (/dev/sdd). There are sdc1 and sdd1 partitions with the same format.

I want to clone the 30gb from the first disk to the second with differences sizes. What is the best way? Clone it with dd or with cat?

Two possibilities:

From the sdc disk:

dd if=/dev/sdc of=/dev/sdd
cat /dev/sdc >/dev/sdd

From the sdc1 partition:

dd if=/dev/sdc1 of=/dev/sdd1
cat /dev/sdc1 >/dev/sdd1

Other questions:

Assuming that /dev/sdd1 already exists with data, could I overwrite it?

Could it cause an error in a sector of the hdd /dev/sdd?

marked as duplicate by Eliah Kagan, WinEunuuchs2Unix, Tim, TheWanderer, David Foerster Dec 29 '16 at 2:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    It's not possible to clone 150GB partition to 100GB destination drive*. You either want to copy the 30GB data to new partition or you have to shrink the 150GB partition first and than clone. *in some corner cases it might work, but not worth consideration – Cieniek Dec 28 '16 at 18:19
  • @Cieniek Are you sure? – Milor123 Dec 28 '16 at 18:21
  • You will truncate everything that lies beyond the capacity of destination drive during the cloning attempt. – Cieniek Dec 28 '16 at 18:26
  • Thank you dude, how could I clone without problem?, I cant resize the first partition. @Cieniek – Milor123 Dec 28 '16 at 18:31
  • If you really need a clone of that 150GB partiton without shrinking it, you either have to find a bigger destination drive or clone in parts. – Cieniek Dec 28 '16 at 18:41
2

Since you're doing partition cloning then the option to use would be:

dd if=/dev/sdc1 of=/dev/sdd1
cat /dev/sdc1 >/dev/sdd1

Now the command to use will depend on what you want to achieve:

  1. cat advantages:

    • fast
    • excellent at handling text files
    • copying the content of a partition to a new unformatted partition
  2. dd advantages:

    • has more options
    • handles binary files well
    • can be used to copy n bytes or skip/seek
    • lets you specify block size

Things to consider:

  • Make sure both source and destination partitions are the same size. Generally if you just want to copy over then cat is ok, but for more options dd will suffice.
  • Data will be overwritten with cat, but dd can avoid this (man dd for more info)

Additional information:

Important:

It's not possible to clone a 150GB partition to a smaller 100GB destination drive*. You either want to copy smaller data (say 30GB) to new partition or you have to shrink the larger (150GB) partition first and then clone. Otherwise, you will truncate everything that lies beyond the capacity of destination drive during the cloning attempt.

*In some corner cases it might work, but not worth consideration.

  • Thank you bro, what happen if I try use cat /dev/sdc >/dev/sdd ? – Milor123 Dec 28 '16 at 18:09
  • 1
    The whole dev gets copied over but any binaries won't fair so well if you used cat – George Udosen Dec 28 '16 at 18:11

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