2

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?

Milor123
  • 231

1 Answers1

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.

George Udosen
  • 36,677