Anecdotes from a Linux Systems Administrator. /root

Home About Books Blog Portfolio Archive
25 November 2011

Securely cloning Linux partitions to a different system

by Alpha01

Getting a bit-by-bit copy of a partition or an entire hard drive is quite simple using the tool dd. Depending on what you’re trying to accomplish, there are two ways to get a copy of your partitions/drives.

One option is to clone the partition/drive directly to an actual partition or drive of your different system.

dd if=/dev/sdb1 | ssh [email protected] of=/dev/sdb1

Another option is to clone the partition or drive to a raw file on your second system, and associate the raw file to a loopback on your secondary host. This will give you the ability to easily mount the file as it were an actual partition or drive stored on your drive.

dd if=/dev/sdb1 | ssh [email protected] of=/root/rubysecurity_sdb1
[email protected] # losetup /dev/loop2 /root/rubysecurity_sdb1
[email protected] # mount /root/rubysecurity_sdb1 /mnt
Tags: [ security ]