TimeLinux1

Wednesday, October 27, 2010

Linux HowTo: dd command


The dd command is an old command carried over from the Mainframe computing days of the yore. It stands for 'Data Dump'. Also known as 'data destroyer' as a pun, in case not used carefully (since it can destroy disk partitioning very innately and cleanly). It is considered as a good choice of disk to disk backup methods at a very native level, it can even be used to copy whole partitions or filesystems. For details refer below:

-dd backup method:
           . sequential file image of a partition irrespective of the filesystem knowledge that reside on the partition. dd cmd does so.
           . backup of partition using only the used fs. dump cmd does so.
-dd requires that the restore be done on an equal or bigger partition.
-dump can restore to partition that is sufficient to hold the used fs.

-dd cmd syntax:
           # dd if=<input file path> of=<output file name>
-eg:     # dd if=/dev/sda3 of=backup-1                     [ copies /dev/sda3 partition to a file called 'backup-1' in pwd ]
           # dd if=/dev/sda3 of=/dev/fd0                      [ copies /dev/sda3 partition to floppy drive ]
           # dd if=/dev/sda2 | gzip > backup-2            [ copies /dev/sda2 partition as a gzipped file 'backup-2' in pwd ]

-note:
          . dd cmd copies all blocks - whether used or unused (ie empty); also the output location needs to be atleast as big as the input.
          . dd cmd can be used an easy way to troubleshoot IO:
           # time dd if=/u03/oradata/devenv/one.dbf of=/dev/null                 [ reads file and times it ] 
           # dd --help                                                   [ or man dd for more help/details ]




No comments:

Post a Comment