The DD command copies a file with a block of the specified size and makes the specified conversion at the same time as the copy.
How to use: DD [OPERAND]
Parameter comment:
bs=BYTES read and write BYTES bytes at a time (also see ibs=,obs=) cbs=BYTES convert BYTES bytes at a time conv=CONVS convert the file as per the comma separated symbol list count=n copy only n input blocks ibs=bytes read bytes bytes at a time (default: 512) if=FILE read from file instead of stdin (default is standard input) iflag= flags read as per the comma separated symbol List obs=bytes write bytes bytes at a time (Default:  512) of=file write to file instead of stdout (default to standard output) oflag=flags write as per the comma separated symbol list seek=BLOCKS skip blocks obs-sized blocks at start of output skip =blocks skip blocks ibs-sized blocks at start of input status=WHICH WHICH info to suppress outputting to stderr; ' Noxfer ' suppresses transfer stats, ' None ' suppresses all
Optional parameters for Convs
ascii from EBCDIC to ASCII ebcdic from ASCII to EBCDIC ibm from ascii to alternate ebcdic block pad newline-terminated records with spaces to cbs-size unblock replace trailing spaces in cbs-size records with newline Lcase change upper case to lower case nocreat do not create the output file excl fail if the output file already exists notrunc do not truncate the output file ucase change lower&nbsP;case to upper case sparse try to seek rather than write the output for NUL input blocks swab swap every pair of input bytes noerror continue after read errors sync pad every input block with NULs to ibs-size; when used with block or unblock, pad with spaces rather than nuls fdatasync physically write output file data before finishing fsync Likewise, but also write metadata
Optional parameters for flags
append append mode (makes sense only for output; conv=notrunc suggested) direct use direct i/o for data directory fail unless a directory dsync use synchronized I/O for data sync likewise, but also for metadata fullblock accumulate full blocks of input (iflag only) nonblock use non-blocking i/o noatime do not update access time noctty do not assign controlling terminal from file nofollow do not follow symlinks count_bytes treat ' Count=n ' as a byte count (iflag only)
Note: Where the number is specified, it is multiplied by the corresponding number if it ends with the following characters:
C =1, W =2, b =512, KB =1000, K =1024, MB =1000*1000, M =1024*1024, XM =m
GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y
Ii. Examples of Use
1, the local/DEV/HDB full disk backup to/DEV/HDD
DD If=/dev/hdb OF=/DEV/HDD
2. Back up/DEV/HDB full data to the image file of the specified path
DD If=/dev/hdb Of=/root/image
3, backup/DEV/HDB overall data, and use the Gzip tool to compress, save to the specified path
DD If=/dev/hdb | gzip >/root/image.gz
4. Split a file into 3 files
#文件大小为2.3k[[email protected] ~]$ ll db1_db_links.sql -rw-r--r-- 1 oracle oinstall 2344 nov 21 10:39 db1_db_links.sql# this file into every file 1k,bs=1k,count= 1, use the skip parameter to specify how many BS support reads are skipped in the input file [[Email protected] ~]$ dd if=db1_db_links.sql of=dd01.sql bs=1k count=11+0 records in1+0 records out1024 bytes (1.0 KB) copied, 4.5536e-05 s, 22.5 mb/s[[email protected] ~]$ dd if=db1_ Db_links.sql of=dd02.sql bs=1k count=1 skip=11+0 records in1+0 records out1024 bytes (1.0 KB) copied, 0.000146387 s, 7.0 mb/s[[email protected] ~]$ dd if=db1_db_links.sql of=dd03.sql bs=1k count=1 skip= 20+1 records in0+1 records out296 bytes (296 b) copied, 0.000204216 s, 1.4 mb/s# SplitThe file [[email protected] ~]$ ll dd*sql-rw-r--r-- 1 oracle oinstall 1024 May 20 14:58 dd01.sql-rw-r--r-- 1 oracle oinstall 1024 May 20 14:58 dd02.sql-rw-r--r-- 1 oracle oinstall 296 may 20 14:58 dd03.sql
5. Merge the split files into 1
#合并操作, the Seek parameter is used to specify the number of BS skipped in the input file [[email protected] ~]$ dd of=1.sql if=dd01.sql 2+0 records in2+0 records out1024 bytes (1 .0 KB) copied, 0.000176 s, 5.8 mb/s[[email protected] ~]$ dd of=1.sql if=dd02.sql bs=1k seek=11+0 Records in1+0 Records OU t1024 bytes (1.0 kB) copied, 0.000124038 s, 8.3 mb/s[[email protected] ~]$ dd of=1.sql if=dd03.sql bs=1k seek=20+1 Records In0+1 Records out296 bytes (296 B) copied, 0.00203881 S, 145 kb/s# and pre-split file verification [[Email protected] ~]$ diff 1.sql Db1_db_lin Ks.sql[[email protected] ~]$
6. Inserting data in the location specified in the output file without truncating the output file
Need to use conv=notrunc parameter [[email protected] ~]$ dd if=2.sql of=1.sql bs=1k seek=1 count=2 conv=notrunc
Reference: http://blog.csdn.net/xizaihui/article/details/53307578
http://blog.csdn.net/jijiagang/article/details/42192049
This article is from the "DBA fighting!" blog, so be sure to keep this source http://hbxztc.blog.51cto.com/1587495/1927774
The DD command in Linux