Difference between revisions of "Dd - Destroyer of Disks"
Line 1: | Line 1: | ||
[[Category:Engineering]] | [[Category:Engineering]] | ||
+ | == wipe a drive == | ||
+ | |||
+ | This will destroy all data on a drive using `dd`. The downside is that it does not give you an estimate of how much time it will take to finish. | ||
+ | |||
+ | <pre> | ||
+ | dd if=/dev/random of=/dev/sda bs=4096 | ||
+ | </pre> | ||
+ | |||
== Image a drive over a network with dd and nc == | == Image a drive over a network with dd and nc == | ||
Revision as of 19:59, 6 March 2008
Contents
wipe a drive
This will destroy all data on a drive using `dd`. The downside is that it does not give you an estimate of how much time it will take to finish.
dd if=/dev/random of=/dev/sda bs=4096
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.