Difference between revisions of "Dd - Destroyer of Disks"

From Noah.org
Jump to navigationJump to search
Line 6: Line 6:
 
nc -l -p 2222 > disk_image.gz
 
nc -l -p 2222 > disk_image.gz
 
</pre>
 
</pre>
 
  
 
Then start sending:
 
Then start sending:
Line 13: Line 12:
 
</pre>
 
</pre>
  
=== Notes ===
+
== Image a drive over a network with dd and ssh ==
 +
 
 +
I like this method better because this does it all from a single command on the sending side and the traffic is encrypted:
 +
<pre>
 +
dd if=/dev/sda | gzip -c - | ssh user@example.com "dd of=disk_image.gz"
 +
</pre>
 +
 
 +
== Notes ==
  
 
If you are doing this on a live server you will need to unmount the drive or switch to single user mode (reboot and set single for boot option in GRUB) or you can boot from a live CD. If you boot into single user mode, don't forget to manually start the network. I have not done a lot of testing with copying a mounted disk in single user mode. This is  not the ideal way, but it seems to work. It's better if the drive is not mounted.
 
If you are doing this on a live server you will need to unmount the drive or switch to single user mode (reboot and set single for boot option in GRUB) or you can boot from a live CD. If you boot into single user mode, don't forget to manually start the network. I have not done a lot of testing with copying a mounted disk in single user mode. This is  not the ideal way, but it seems to work. It's better if the drive is not mounted.

Revision as of 13:15, 19 October 2007

Image a drive over a network with dd and nc

Start the receiving side first. This assumes machine 192.168.1.100:

nc -l -p 2222 > disk_image.gz

Then start sending:

dd bs=1M if=/dev/sda | gzip -c - | nc 192.168.1.100 2222

Image a drive over a network with dd and ssh

I like this method better because this does it all from a single command on the sending side and the traffic is encrypted:

dd if=/dev/sda | gzip -c - | ssh user@example.com "dd of=disk_image.gz"

Notes

If you are doing this on a live server you will need to unmount the drive or switch to single user mode (reboot and set single for boot option in GRUB) or you can boot from a live CD. If you boot into single user mode, don't forget to manually start the network. I have not done a lot of testing with copying a mounted disk in single user mode. This is not the ideal way, but it seems to work. It's better if the drive is not mounted.