I'm trying to duplicate the entire environment on one machine to another. Will simply copying all files from the source machine to the destination one work? My main concern is that typically, when copying a file from one machine to another, the permissions/ownership aren't copied correctly, so I'm thinking that might cause some issues. But I'm thinking if I copy the entire file system, then all the user configuration should be copied over as well and it might work?

On original machine:

dd if=/dev/sda of=/some/device/image.img conv=noerror

On target machine:

dd if=/some/device/image.img of=/dev/sda conv=noerror 

The OS is Centos 7 and it's a desktop workstation (dev box). Both boxes are using UEFI. Source drive is 59 GB and dest is 143GB so there's plenty of space.

  • Please edit your original question to add more details. How is it booted (in UEFI mode or BIOS mode)? Please specify the source drive and target drive (size, physical block size (by 'parted`) ... – sudodus Sep 18 at 13:20
  • On original machine: dd if=/dev/sda of=/some/device/image.img conv=noerror On target machine dd if=/some/device/image.img of=/dev/sda conv=noerror – john doe Sep 18 at 14:30
  • 1
    What command are you using to copy the files? If you edit your question to include this, there might be a mistake or omission we can see that prevents it retaining permissions/ownership. – roaima Sep 19 at 22:23
  • 1
    @johndoe please, no. (1) Fix the block size; 512 bytes per syscall is terribly inefficient (not to mention generating 8 writes per SDD block). (2) Use cat instead of dd and it'll not only be no slower, it may actually be faster. – roaima Sep 19 at 23:22
  • 1
    @AnthonyGeoghegan suprisingly perhaps, I really do mean cat. See Is there a way to determine the optimal value for the bs parameter to dd for some timings. (But I did misspell SSD.) – roaima Sep 20 at 9:51

As answered here here you can attach the drive of the second machine to your machine and simply do dd block level copy.

Please note the second HDD has to be at least the size of the first HDD. If its larger you may need to extend the filesystem after.

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.