Linux dd command usage

Source: Internet
Author: User

Linux dd command usage 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 at the same time.

The main option of DD: specify a number. If the following column ends with a 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 both sets the size of the read/write block to bytes, which can replace IBS and obs. CBS = bytes are converted to bytes at a time, that is, the size of the conversion buffer. Skip = blocks skipping blocks from the beginning of the input file before copying. Seek = blocks skips blocks from the beginning of the output file and then starts copying. (Usually only valid when the output file is a disk or tape) Count = blocks only copies blocks, and 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: Convert ebcdic to ASCII. Ebcdic converts ASCII to ebcdic. IBM converts each line to a CBS record by converting ASCII to alternate ebcdic. Block. The missing part is filled with spaces. Unblock: the length of each row is CBS, and spaces are used to fill the remaining parts. Lcase converts uppercase to lowercase. Ucase converts lowercase to uppercase. Swab exchanges each pair of input bytes. Unlike the Unix DD, this works when an odd number of bytes are read. if the input file contains an odd number of bytes, the last byte is simply copied (since there is nothing to swap it ). do not stop when noerror occurs. Notrunc does not truncate the output file. 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

Generate image Hard Disk Files used by xen

A: dd If =/dev/Zero of =/disk2/xen/centos5.office. img bs = 1 m COUNT = 3072 Oflag = direct B: dd If =/dev/Zero of = centos5.img BS = 2 k seek = 4096 K 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.