dd [man page] - convert and copy a file


dd [OPERAND]... dd OPTION 

Frequently used options

read from FILE instead of stdin
write to FILE instead of stdout
copy only BLOCKS input blocks


dd command can be use to backup master boot record. Backup MBR:

dd if=/dev/hda of=/mbrbackup.img bs=512 count=1 

Restore MBR:

dd if=/mbrbackup.img of=/dev/hda bs=512 count=1 

We can also create image from floppy disk. Create immage:

dd if=/dev/fd0 of=/my_floppy_image 

Restore image:

dd if=/my_floppy_image of=/dev/fd0 

dd also can manage conversions. We can convert all characters in file from lower case to upper case:

echo linux > commands.txt
dd if=commands.txt of=commands.caps conv=ucase

convert all characters in file from lower case to upper case
We can also use dd to backup entire partitions. In this example we backup entire partition and use gzip to compress image so final file will have smaller size. This way we can backup any possible filesytem. However there are couple problems with this approach:

  • backup image is too large
  • backup image can be restored only on partitions with the same size as the original partition Backup /dev/hda1 partition command example:
dd if=/dev/hda1 | gzip -c > backup_partition_image.dd.gz 

To restore this image we can use command:

cat backup_partition_image.dd.gz | gzip -d | dd of=/dev/hda1 
Please refer all article related questions to:

You may also be interested in: