0

I have used dd before to clone hard drive's but I'm now attempting to clone an entire hard drive consisting of 3 partitions to another drive.

My partitions are named nvme0n1p1 to 3, I tried leaving the last number of but dd doesn't accept that, it requires one of the partition names.

What is the best approach to do this? Do I first have to create 3 partitions on the target disk or is there an easier way?

The nvme0n1p3 is the largest partition holding all the data, I guess the others are boot partitions (512m and 732M) or something, do I even need to clone them?

dazz
  • 293
  • 2
  • 11

1 Answers1

1

If the disk is of equal or larger size, you should be fine. This clones the disk as-is:

dd if=/dev/nvme0n1 of=/dev/target conv=sync status=progress

It's unclear what you want to achieve though. You may have trouble if your OS (and I'm assuming you are cloning a disk containing an OS as you mentioned boot partitions) you are cloning detects the disk differently (Windows HAL or Linux' fstab entries).

edit

As you mentioned Ubuntu, check that your /etc/fstab and your boot-loader use UUIDs to mount your filesystems. In that case, it should just work (tm).

fuero
  • 9,413
  • 1
  • 35
  • 40
  • Yes, that's what I'm trying. I have a new hard drive for my laptop and I want to clone the old one with Ubuntu on it to the new one. But I think I just realized my error from your example, I tried to use 'if=/dev/nvme0n1p' io 'if=/dev/nvme0n1'. Which of course makes more sense. I'll try it out. – dazz Feb 14 '21 at 13:03
  • @fuero, what if the target disk is smaller (with already shrunk partitions to fit in size to the target disk, but with non-used extra space on the source disk)? Would dd command work anyway? – Tedo Vrbanec Feb 13 '22 at 15:47
  • you may use `dd` with the *partition* device as well, e.g. `dd if=/dev/nvme0n1p1 of=/dev/target_partition` - as long as the source fits inside the target. This doesn't replicate GPT, MBR, or any other partitions to the target *disk*. Obviously. – fuero Feb 14 '22 at 06:47