0

Note: I am using ubuntu server.

I have an nvme main drive, and I have two of the same 2tB hard drives.

I connected one of my hard drives and ran dd if=/dev/nvme0n1 of=/dev/sda2 status=progress

It copied about 40gB of data, then I restarted and booted from the hard drive and I had a working clone.

Then I removed that hard drive and connected the other hard drive, then ran sudo dd if=/dev/nvme0n1 of=/dev/sda2 status=progress

I added sudo the second time, because I wasn't sure if I had used it the first time (I probably did not).

It is currently at 805gB copied and still going. Why the massive discrepancy?

Update: I started over and ran dd if=/dev/nvme0n1 of=/dev/sda status=progress

but it said permission denied. So I added sudo, and now it's cloning everything again -- currently at 129gB. I am still confused as to why I was able to clone with only 40gB of transfer the first time.

icor103
  • 101
  • Normally the permissions of block devices are limited for ordinary users, but with sudo you have full permissions. Please check the ownership and permissions of the source and target devices. I think it can help explain the different behaviour. – sudodus Sep 26 '23 at 15:56
  • 1
    note that dd is byte-for-byte copying, including 'empty space'. It's not designed to exclude free space, it will iterate until the entire disk is copied byte-for-byte. This is just how dd was designed. There are other mechanisms such as partclone or others (utilized by things like Clonezilla) which will be free-space-aware and makes cloning data and not free space easier, but that's not how dd was designed. – Thomas Ward Sep 26 '23 at 16:01
  • Looking further at your question, I notice that you write that you copied the whole nvme drive to a partition on sda. Is that your intention, did you do that at all or is there a typing error? 2. I agree with Thomas Ward, that it is a good idea to use Clonezilla instead of dd. See also this link.
  • – sudodus Sep 26 '23 at 16:06
  • Clonezilla could not recognize my hard drive at all and that's why I used dd. I'm not sure why Sudodus said I copied to a partition. – icor103 Sep 26 '23 at 16:11
  • @icor103, 1. /dev/sda2 is partition #2 on the drive /dev/sda; 2. I use Clonezilla with nvme drives, SATA drives and USB drives without problems. Which version of Clonezilla did you try? – sudodus Sep 26 '23 at 16:18
  • @sudodus Okay, I thought you were telling me that I had used it differently each time. Now I understand. It is currently running sda2... I need to start over with this drive. – icor103 Sep 26 '23 at 16:23
  • Please see my edit. I ran it again, without sudo, and it gave me an error. – icor103 Sep 26 '23 at 17:32
  • SInce you copied to partitions, the partions may have diferent size? – mook765 Sep 26 '23 at 17:46
  • @mook765 see the edit, I copied to the drive instead of a partition. – icor103 Sep 26 '23 at 17:52
  • @icor103, 1. Maybe the size of /dev/sda2 was limiting the size of the transfer; 2. And cloning with dd needs sudo; 3. Anyway, I suggest that you try again with Clonezilla. It should work, and is much more efficient because it will only copy used data blocks (and skip those that are not used). Furthermore it is safer because there are 'checkpoints' that let you double-check that your target is the correct one. – sudodus Sep 26 '23 at 19:44