Skip to content

Instantly share code, notes, and snippets.

@zhanglongqi
Last active January 17, 2025 02:05
Show Gist options
  • Save zhanglongqi/c1ad277a59fcb9a35dd3fa4d76b5b754 to your computer and use it in GitHub Desktop.
Save zhanglongqi/c1ad277a59fcb9a35dd3fa4d76b5b754 to your computer and use it in GitHub Desktop.
Clone disk partition using dd over telnet with bzip compression

Thanks to https://www.thegeekdiary.com/how-to-clone-linux-disk-partition-over-network-using-dd/

Clone using telnet and bzip has advantages to reduce clone time, but make sure you use a secure network.

Lets assume server-B has ip address 192.168.100.2 Run this command in server B (destination):

# nc -l -p 19000 | bzip2 -d | dd bs=16M of=/dev/sda

Run this command in server A (source):

# dd bs=16M if=/dev/sda | bzip2 -c | nc 192.168.100.2 19000

Based on these 2 commands above we will connect to server-B using port 19000.

It's better not to use bzip2 if you are backing up embedded system because the CPU may be too slow.

@TomK32
Copy link

TomK32 commented Jan 16, 2025

I noticed with a Gigabit connection (machines literally sitting next to each other) it's faster not to use bzip2.

@zhanglongqi
Copy link
Author

I noticed with a Gigabit connection (machines literally sitting next to each other) it's faster not to use bzip2.

It's expected like this if you use faster network. It's a trade-off of computing and network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment