Dd
|
From Linuxconfig.org
.. back to the list of Linux Commands
Name
dd - convert and copy a file
Synopsis - man page
dd [OPERAND]... dd OPTION
Frequently used options
if=FILE read from FILE instead of stdin of=FILE write to FILE instead of stdout count=BLOCKS copy only BLOCKS input blocks
Examples
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
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















