Here is a very handy tip to backup or make a clone of disks on a Linux server to another server across a network. For testing the concept you can use it on the same machine to get the idea of how to use it.

Lets say we want to copy /dev/sda1 to a remote machine (for testing – our local machine). Then we will mount it back and look at the file system.

First on the destination system, start the nc utility to listen for a network connection and write the data to a file:

So on the destination machine (could be the localhost):

Dest-srv#nc -l 7777 | sda1.img bs=512

On the source machine use:

Source-srv#dd if=/dev/sda1 | nc localhost 7777

Once the file (disk) copies over, you can then mount it using:

Dest-srv#mount -o loop sda1.img /mnt

To view the files on the newly mounted disk copy:

Dest-srv#ls -l of /mnt

and you will have an exact copy of the file system saved as a file and now mounted on the destination machine.


One great use is to create a VM of your physical box, the process would be to first create a VM, mount a rescue CD so you can boot the CD, allocate some disks, then using the code above to copy the disk partitions into the new disk, then reboot the VM and the new disks should boot.

More on this later as I’m about to do it on some production servers!