Contents[Hide]

1. Name

dd [man page] - convert and copy a file

2. Synopsis

dd [OPERAND]... dd OPTION 

3. 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

4. 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

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 

Free Linux eBooks

Linux Technical Writer

LinuxCareer, Casual, Volunteer, Home Based

Do you wish to join Linuxcareer.com project and find out how to be a technical writer? We are now looking for volunteers to help us write tutorials and share them with Linux community

  • Casual work from home
  • 10 articles / year

Any active Linuxcareer.com’s author will be entitled to following benefits:

  • actively participate in Linuxcareer.com’s decision making process
  • feedback and help

APPLY

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top