Explanation of DD commands in Linux

Source: Internet
Author: User
Explanation of DD commands in Linux

Name: dd
Permission: all user dd commands in manual are defined as convert and copy a file.

Usage:
Dd [Option]

If you want to view Manual Online, try:
Dd -- Help

Or
Info dd

If you want to see how this version is:
Dd -- version

Input or output
Dd If = [stdin] of = [stdout]

The number of bytes of the input or output size.
BS: dd-IBS = [byte]-obs = [size]

How many bytes are allowed at a time?
CBS = bytes

Output only after skipping a paragraph
Seek = Blocks

Skip a section before entering
Skip = Blocks

Of course, you can use this to conveniently copy the CD. (Note that your CD is in the standard iso9660 format !)

Dd If =/dev/CDROM of = CDROM. ISO
The content after if and after if is adjusted according to your requirements.

Then run the following command on the system:

Cdrecord-v cdrom. ISO
This article is not about cdrecord, so the above commands are the simplest but may not necessarily meet your hardware environment...
Function: Copies the specified input file to the specified output file, and supports format conversion during the copy process. You can use this command to implement the diskcopy command in DOS. Use the DD command to write the data on the floppy disk as a storage file on the hard disk, and then write the storage file to the second disk to complete the diskcopy function. Note that you should delete the storage file on the hard disk with the RM command. Standard input files and standard output files are used by default.

Syntax: dd [Option]

If = input file (or device name ).

Of = output file (or device name ).

IBS = Bytes: the number of bytes read from the buffer zone.

Skip = blocks skip the IBS * blocks block at the beginning of the read buffer.

Obs = Bytes: the number of bytes written to the buffer zone.

BS = Bytes: set the number of bytes in the read/write buffer at the same time (equal to setting IBS and OBS ).

CBS = byte: bytes are converted once.

Count = blocks only copies the input blocks block.

Conv = ASCII converts the ebcdic code to the ascil code.

Conv = ebcdic converts an ascil code to an ebcdic code.

Conv = IBM converts an ascil code to an alternate ebcdic code.

Conv = block converts a variable bit to a fixed character.

Conv = ublock converts a fixed bit to a variable bit.

Conv = ucase converts lowercase letters to uppercase letters.

Conv = lcase converts uppercase letters to lowercase letters.

Conv = notrunc: the output file is not truncated.

Conv = swab exchange each pair of input bytes.

Conv = do not stop processing when noerror occurs.

Conv = Sync adjusts the size of each input record to the IBS size (filled with NUL ).

Example 1: copy the content of a floppy disk to another floppy disk and 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, extract the source disk from the drive and insert the target disk. Enter the following command:

$ Dd If =/tmp/tmpfile of =/dev/fd0

After the floppy disk is copied, delete the temporary file:

$ RM/tmp/tmpfile

Example 2: Write the net. I file to a floppy disk and set the number of read/write buffers.

(Note: The content in the floppy disk will be completely overwritten)

$ Dd If = net. I of =/dev/fd0 BS = 16384

Example 3: copy the sfile to the dfile.

$ Dd If = sfile of = dfile _____________________________________ dd is a very useful command in Linux/Unix. It is used to copy an object with a specified size block, and perform the specified conversion while copying.

Main options of DD:
If the following column ends with a specified number, multiply it by the corresponding number:
B = 512, c = 1, K = 1024, W = 2, XM = Number m

If = File
Input File name. The default value is standard input.

Of = File
Output file name. The default value is standard output.

IBS = bytes
Read bytes at a time (that is, the size of a block is bytes ).

Obs = bytes
Write bytes at a time (that is, the size of a block is bytes ).

BS = bytes
Set the size of the read/write block to bytes, which can replace IBS and obs.

CBS = bytes
Bytes are converted at a time, that is, the size of the conversion buffer.

Skip = Blocks
The blocks are skipped from the beginning of the input file and then copied.

Seek = Blocks
The blocks are skipped from the beginning of the output file and then copied. (Usually only valid when the output file is a disk or tape)

Count = Blocks
Copy only blocks. The block size is equal to the number of bytes specified by IBS.

Conv = Conversion [, conversion...]
Use the specified parameter to convert the file.

Conversion parameters:

ASCII conversion ebcdic is ASCII.

Ebcdic converts ASCII to ebcdic.

IBM converts ASCII to alternate ebcdic.

Block converts each row to a record with a length of CBS. The missing part is filled with spaces.

Unblock
Make the length of each line be CBS, and fill the remaining part with spaces.

Lcase converts uppercase to lowercase.

Ucase converts lowercase to uppercase.

Swab exchanges each pair of input bytes. Unlike
Unix dd, this works when an odd number
Bytes are read. If the input file contains
An odd number of bytes, the last byte is
Simply copied (since there is nothing
Swap it ).

Noerror
Do not stop when an error occurs.

Notrunc
The output file is not truncated.

Sync fills each input block into IBS bytes, and the missing part is filled with null (NUL) characters.

Since the DD command allows binary read/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 = 1440 K
Interestingly, this image file can be read by tools such as HD-copy and winimage. Another example is to save the first 512 bytes of the first hard disk as a file:
Dd If =/dev/hda of = disk. mbr bs = 512 COUNT = 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.