Original URL: http://xiaozhuang.blog.51cto.com/4396589/850657
Original works, allow reprint, please be sure to use hyperlinks in the form of the original source of the article, author information and this statement. Otherwise, the legal liability will be investigated. http://xiaozhuang.blog.51cto.com/4396589/850657Usage rights: All user dd This directive is defined in manual as convert and copy a file
How to use: DD [option]
If you want to see manual online, you can try it: DD--help or info DD
If you want to see this version how to: DD--version
Input or output DD If=[stdin] of=[stdout]
Force the input or output SIZE to how many bytes Bs:dd-ibs=[byte]-obs=[size]
Forced to do only a few Bytes at a time cbs=bytes
Skipping over a period of time before outputting seek=blocks
Skip a paragraph before entering skip=blocks
Of course you can use this to facilitate the copy of the disc (note that your CD-ROM is the standard iso9660 format to do so yo!) )
DD If=/dev/cdrom Of=cdrom.iso
The contents of the if and after are adjusted according to your needs.
Then give the system this command to burn:
Cdrecord-v Cdrom.iso
This is not about Cdrecord, so the instructions above are the simplest but not necessarily compatible with your hardware environment ...
Function: Copies the specified input file into the specified output file, and can be converted in format during the copy process. You can use this command to implement the diskcopy command under DOS. First use the DD command to write the data on the floppy disk to a storage file, and then the storage file written to the second floppy disk, complete the function of diskcopy. It should be noted that the storage file on the hard disk should be removed with the RM command. The system uses standard input files and standard output files by default.
Syntax: DD [Options]
if = input file (or device name).
of = output file (or device name).
IBS = Bytes Reads bytes bytes At a time, that is, the number of bytes read into the buffer.
Skip = Blocks skips the ibs*blocks block that reads into the beginning of the buffer.
Obs = bytes Writes bytes bytes At a time, that is, the number of bytes written to the buffer.
BS = bytes Sets the number of bytes in the read/write buffer (equal to the set IBS and OBS).
CBS = Byte converts bytes bytes at a time.
The count=blocks only copies the input blocks blocks.
CONV = ASCII Converts the EBCDIC code to Ascil code.
Conv = EBCDIC converts ascil code to EBCDIC code.
CONV = IBM converts ascil code to alternate EBCDIC code.
CONV = Block Converts the change bit to a fixed character.
CONV = Ublock Converts the fixed bit into a change bit.
CONV = UCase Converts the letter from lowercase to uppercase.
CONV = LCase converts letters from uppercase to lowercase.
CONV = Notrunc does not truncate the output file.
CONV = swab swaps each pair of input bytes.
CONV = NoError does not stop processing when an error occurs.
Conv = sync puts the size of each input record to the size of the IBS (filled with nul).
Example 1: To copy the contents of one floppy disk to another floppy disk, use/TMP as the temporary storage area. Insert the source disk into the drive and enter the following command:
$ dd if =/dev/fd0 of =/tmp/tmpfile
After the copy is complete, remove the source disk from the drive, insert the target disk, and enter the command:
$ dd if =/tmp/tmpfile of =/dev/fd0
After the floppy copy is complete, the temporary files should be deleted:
$ rm/tmp/tmpfile
Example 2: Write the net.i file to a floppy disk and set the number of read/write buffers.
(Note: The contents of the floppy disk will be completely overwritten)
$ dd if = net.i of =/dev/fd0 bs = 16384
Example 3: Copy the file sfile to the file Dfile.
$ dd If=sfile Of=dfile_____________________________________DD is a very useful command under Linux/unix, which is to copy a file with a block of the specified size and make the specified conversion at the same time as the copy.
Main options for DD:
Specify the number of digits at the end of the following character multiplied by the corresponding number:
b=512, C=1, k=1024, w=2, Xm=number m
If=file
Enter a file name, which defaults to standard input.
Of=file
The output file name, which defaults to standard output.
Ibs=bytes
Reads a bytes byte at a time (that is, a block size of bytes bytes).
Obs=bytes
Write bytes bytes at a time (that is, a block size of bytes bytes).
Bs=bytes
The size of the read-write block at the same time is bytes, which can replace IBS and OBS.
Cbs=bytes
Converts bytes bytes at a time, that is, the size of the conversion buffer.
Skip=blocks
Skip blocks blocks from the beginning of the input file before copying begins.
Seek=blocks
Skip blocks blocks from the beginning of the output file before copying begins. (usually only valid if the output file is a disk or tape)
Count=blocks
Copies only blocks blocks, and the block size equals the number of bytes specified by IBS.
Conv=conversion[,conversion ...]
Converts the file with the specified parameters.
Conversion parameters:
The ASCII conversion EBCDIC is ASCII.
EBCDIC convert ASCII to EBCDIC.
IBM converts ASCII to alternate EBCDIC.
Block converts each row to a cbs-length record, and the insufficient portion is padded with spaces.
Unblock
Make each line the length of the CBS, the less part filled with spaces.
LCase converts uppercase characters to lowercase characters.
UCase converts lowercase characters to uppercase characters.
Swab swap each byte of the input. Unlike the
Unix DD, this works when an odd number of
Bytes is read. If the input file contains
An odd number of bytes, the last byte is
Simply copied (since there is nothing to
Swap it with).
NoError
Do not stop when an error occurs.
Notrunc
Does not truncate the output file.
Sync fills each input block into IBS bytes, and the less part is padded with empty (NUL) characters.
Because the DD command allows the binary to read and write, it is particularly suitable for input/output on the original physical device. For example, you can use the following command to create an image file for a floppy disk:
DD if=/dev/fd0 of=disk.img bs=1440k
Interestingly, this image file can be read out by Hd-copy, WinImage and other tool software. If you save the first 512 bytes of a hard disk as a file:
DD If=/dev/hda of=disk.mbr bs=512 count=1full parse of Linux DD commandOriginal URL: http://blog.itpub.net/26686207/viewspace-717558/
Linux/unix DD command is a very good command for managing disks
DD Command function: Specify the size of the block to copy a file, and at the same time the copy of the specified conversion, play the role of an initialization disk
1. Introduction to Commands
DD The main options:
specify the number of digits at the end of the following character multiplied by the corresponding number :
b=512, C=1, k=1024, w=2, Xm=number m
If=file
Enter a file name, which defaults to standard input.
Of=file
The output file name, which defaults to standard output.
ibs=bytes
Reads a bytes byte at a time (that is, a block size of bytes bytes).
obs=bytes
Write bytes bytes at a time (that is, a block size of bytes bytes).
bs=bytes
The size of the read-write block at the same time is bytes, which can replace IBS and OBS.
Cbs=bytes
Converts bytes bytes at a time, that is, the size of the conversion buffer.
Skip=blocks
Skip blocks blocks from the beginning of the input file before copying begins.
Seek=blocks
Skip blocks blocks from the beginning of the output file before copying begins. (typically only valid if the output file is a disk or tape).
Count=blocks
Copies only blocks blocks, and the block size equals the number of bytes specified by IBS.
Conv=conversion[,conversion ...]
Converts the file with the specified parameters.
conversion Parameters :
The ASCII conversion EBCDIC is ASCII.
EBCDIC convert ASCII to EBCDIC.
IBM convert ASCII to alternate ebcdic.
Block converts each row to a record with a length of CBS, and the insufficient portion is filled with spaces.
UNBLOCK  The length of each line is CBS, The insufficient parts are filled with spaces.
LCASE  convert uppercase characters to lowercase characters.
UCASE  convert lowercase characters to uppercase characters.
SWAB  swap each pair of bytes entered.
NoError does not stop when an error occurs.
Notrunc does not truncate the output file. Do not take the whole instruction
Sync each input block is populated with IBS bytes, and the less part is padded with empty (NUL) characters.
DD Application Example
1. Back up the local/dev/hdb full disk to the/DEV/HDD
DD if=/dev/hdb F=/DEV/HDD hdb–> memory-HDD
2. Back up the/DEV/HDB full data to the image file of the specified path
DD if=/dev/hdb f=/root/image hdb–> Memory--image file
3. Restore the backup file to the specified disk
DD if=/root/image f=/dev/hdb image file –> memory--HDB
4. Back up the/DEV/HDB full data and compress it with the Gzip tool to save to the specified path
DD If=/dev/hdb | Gzip>/root/image.gz
5. Restore the compressed backup file to the specified disk
gzip-dc/root/image.gz | DD F=/dev/hdb
6. Backup disk starts with 512 byte-sized MBR master boot record information to the specified file
DD If=/dev/hda f=/root/image count=1 bs=512 By default reads 512 bytes from the hard 0 cylinder 0 Track 1 sector
Count=1 refers to copying only one block; bs=512 refers to a block size of 512 bytes.
Recovery: DD If=/root/image F=/dev/hda
7. Backup floppy disk
DD if=/dev/fd0 f=disk.img count=1 bs=1440k (i.e. block size 1.44M)
8. Copy the memory contents to the hard disk
DD If=/dev/mem F=/root/mem.bin bs=1024 (Specify block size 1k)
9. Copy disc contents to the specified folder and save as Cd.iso image file
DD If=/dev/cdrom (HDC) Of=/root/cd.iso
10. Increase Swap partition file size
The first step: Create a file of size 256M:
DD If=/dev/zero of=/swapfile bs=1024 count=262144
Step Two: Turn this file into a swap partition file:
Mkswap/swapfile
Step three: Enable this swap swap partition file:
Swapon/swapfile
Fourth step: Edit the/etc/fstab file to automatically load swap partition files at each boot:
/swapfile Swap swap default 0 0
11. Destroying disk data
DD If=/dev/urandom F=/DEV/HDA1
Note: Populating the hard disk with random data can be used to destroy the data in some necessary situations.
12. Test the read/write speed of the hard drive
DD If=/dev/zero bs=1024 count=1000000 f=/root/1gb.file Write speed
DD If=/root/1gb.file bs=64k | DD F=/dev/null Read speed
With the command execution time of the above two commands output, the read and write speed of the hard disk can be calculated.
13. Determine the best block blocks size of the hard disk: Initialize the hard drive
DD If=/dev/zero bs=1024 count=1000000 f=/root/1gb.file initialize the hard drive
DD If=/dev/zero bs=2048 count=500000 f=/root/1gb.file initialize the hard drive
DD If=/dev/zero bs=4096 count=250000 f=/root/1gb.file initialize the hard drive
DD If=/dev/zero bs=8192 count=125000 f=/root/1gb.file initialize the hard drive
By comparing the execution time of the command shown in the above command output, you can determine the optimal block size for the system.
14. Repairing the hard drive: self-initializing the hard drive
DD IF=/DEV/SDA F=/DEV/SDA SCSI hard disk or DD If=/dev/hda F=/dev/hda IDE
When the hard disk is placed unused for a longer period of time (more than one year), the magnetic flux point electromagnetic dot phenomenon is generated on the disk, which can cause difficulties when the heads are read to these areas and may result in I/O errors. When this condition affects the first sector of the hard disk that is MBR (Master boot 446, hard disk partition table 64, hard disk Identification 2 bytes), the hard disk may be retired. The above command may bring the data back to the dead. And the process is safe and efficient.
"Go" Linux in the DD command to use the detailed