feed-image  ISSN 1836-5930



Receive Your Complimentary Guide to Linux NOW!


A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)




Poll

Do you care about your privacy when using a FACEBOOK?
 

linuxconfig.org
is hosted by:



Partner Linux Sites
TuxMachines
DebianAdmin
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
FreeSoftwareLinux
All For Linux

dd
Article Index
1. Name
2. Synopsis
3. Frequently used options
4. Examples

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