Clone disk over network

I need to clone one laptop's drive to another one which is basically the same built.

They are M.2 PCIe drives so even if I wanted to open the laptops I can't currently find USB connectors for them.

So I would need then to image the source to an external drive and then play that image back on the new computer.

Doing that for almost a Terabyte of data does take quite some time - and I have to find room for the image as well.

How can I clone the source laptop to the target laptop over the network without creating an intermediate copy of the image? I can boot to USB on both laptops.

1 Answer

No need to find storage for the image - just load up a Linux Live CD (or USB stick), and use netcat.

On the computer that is setup and ready to go, run:

sudo dd if=${SOURCE_DISK} bs=4M | gzip | nc -l 27015

Then, on the computer that will recieve the image and become a clone, run the following... (I feel I should note the obligatory this will destroy all data)

nc ${IP_OF_SERVER} 27015 | gzip -d | sudo dd of=${DEST_DISK} bs=4M

Here, ${SOURCE_DISK} and ${DEST_DISK} need to be swapped for the relevant disks - e.g: /dev/sda or /dev/nvme0n1.

Additionally, ${IP_OF_SERVER} needs to be replaced with the IP of the first computer.

This will transfer the data directly between the two M.2 drives.


For bonus points, you could replace the source dd with pv to keep an eye on progress... or send a SIGUSR1 to the dd instance for a poor-man's update.


Notes:

  • This doesn't cover any modifications that you may need to make to the (unspecified) OS... Windows might get picky about activation, and Linux might get nostalgic about things like network interfaces...
  • This basic approach isn't suitable if your target SSD is smaller than the source.
  • If you're only interested in particular partitions, then check the sizes, and use a suffix of p1 / p2 / etc... on the device names.
4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like