Using dd and dd_rescue

Following up on a post about recovering bad disks and reiser file systems, here is a list of ddrescue commands to help make life that little bit easier:

Backup MBR (boot code + partition table):

<code>dd if=/dev/hda of=mbr count=1 bs=512</code>

Restore boot code + partition table:

<code>dd if=mbr of=/dev/hda</code>

Restore, not including partition table:

<code>dd of=/dev/hda if=mbr bs=448 count=1</code>

Saving partition sizes to text file:

<code>fdisk -l /dev/hda >partition-info.txt</code>

Backing up to gzipped file:

<code>dd if=/dev/hda | gzip >hda.gz</code>


<code>gunzip -c hda.gz | dd of=/dev/hda</code>

Backing up to archive split into 1GB chunks:

<code>dd if=/dev/hda | split -b 1024m -d - hda.</code>


<code>cat hda.* | dd of=/dev/hda</code>

Backing up over ssh tunnel to remote machine (blowfish = faster):

<code>dd if=/dev/hda | ssh -c blowfish user@machine "dd of=hda"</code>

copying files over ssh tunnel:

<code>tar cv /source | ssh -c blowfish user@machine "cd /destination ; tar x"</code>

Thanks to colinm over at Digg for putting these so succinctly