Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to the specific usage of dd command in Linux system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

The main content of this article is "introduction to the specific usage of dd command in Linux system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn the "introduction to the specific usage of the dd command in the Linux system".

Dd-convert and copy fil

When making an unforced conversion, copy the file using the specified input and output block size (default is from standard input to standard output. )

It reads one block of the specified size at a time from the input (512 bytes by default). If you use the bs=bytes option and there is no conversion, except for specifying sync, noerror, or notrunc, dd will write all read data (which can be less than the requested read) to a separate output block. The length of this output block is exactly the same as the data read, unless you specify to use sync (synchronous) conversion, in which case NUL characters (or spaces, see below) will be appended to the end of the data.

In other cases, the input is read one block at a time, then processed, and the output is collected and finally written to the data block of the specified size. The final output block may be shorter than the specified size.

If you want to watch manual online, you can 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]

How much Bytes is forced to input or output Size

Bs: dd-ibs= [BYTE]-obs= [SIZE]

Forced to do only how many Bytes at a time

Cbs=BYTES

Skip a paragraph before output

Seek=BLOCKS

Skip a paragraph before entering

Skip=BLOCKS

Of course, you can use this to make a convenient copy of the CD (note that your CD is in standard iso9660 format!)

Dd if=/dev/cdrom of=cdrom.iso

Among them, the content after if and of is adjusted according to your needs.

Then give the system this command and you can burn it:

Cdrecord-v cdrom.iso

This article is not about cdrecord, so the above instructions are the simplest but do not necessarily fit your hardware environment.

Function: copy the specified input file to the specified output file, and the format can be converted during the copying process. You can use this command to achieve the function of the diskcopy command under DOS. First use the dd command to write the data on the floppy disk into a storage file of the hard disk, and then write the storage file to the second floppy disk to complete the function of diskcopy. It is important to note that the hosting files on the hard disk should be deleted with the rm command. The system uses standard input files and standard output files by default.

If=file

Read from file instead of standard input.

Of=file

Write it to file instead of standard output. Unless conv=notrunc is specified, dd will truncate the file to O bytes (or the size specified by the seek= option)

Ibs=bytes

Read bytes bytes at a time. The default is 512.

Obs=bytes

Write bytes bytes at once. The default is 512.

Bs=bytes

Read and write bytes bytes at once. This overrides the values set by ibs and obs (and setting bs does not mean setting ibs and obs to the same value at the same time, at least when using only sync, noerror, or notrunc conversions. Because bs stipulates that each input block should be copied to the output as a separate block of data, rather than grouping the shorter blocks together.

Cbs=bytes

Specifies the size of the conversion block for block and unblock transformations.

Skip=blocks

Before copying, skip the previous blocks blocks of the input file, each with a size of ibs-byte bytes.

Seek=blocks

Before copying, skip the previous blocks blocks of the output file, each with a size of obs-byte bytes.

Count=blocks

Copy only the previous blocks blocks of the input file (each block is ibs-byte bytes in size), not all of the contents, until the end of the file.

Conversion

Conv= conversion [, conversion].

Converts the file as specified by the conversion parameter (there are no spaces on either side of the lq,rq).

The conversion methods include:

Ascii

Convert EBCDIC to ascii.

Ebcdic

Convert ascii to ebcdic.

Ibm

Convert ascii to alternative ebcdic.

Block

The output of each line of input, regardless of length, is cbs bytes, and the lq newline rq (NEWLINE, that is,'in c) is replaced with a space. If necessary, blanks are filled at the end of the line.

Unblock

Replace the space at the end of each input block (cbs byte size) with the lq newline rq.

Lcase

Convert uppercase letters to lowercase.

Ucase

Convert lowercase letters to uppercase.

Swab

Swap each pair of input bytes. If the number of bytes read is odd, the last byte is simply copied to the output (because there are no bytes that can be swapped with it) (POSIX 1003.26 PASC translation 1003.2 3 and 4).

Noerror

When a read error occurs, continue.

Notrunc

The output file is not truncated.

Sync

Populate the end of each input block with 0 so that its size is ibs bytes.

Example:

The code is as follows:

[root@localhost ~] # dd if=/dev/hdx of=/dev/hdy # backup the local / dev/hdx to / dev/hdy

[root@localhost ~] # dd if=/dev/hdx of=/path/to/image # backup the full data of / dev/hdx to the image file in the specified path

[root@localhost ~] # dd if=/dev/hdx | gzip > / path/to/image.gz # backup / dev/hdx full data, and use gzip tool to compress and save to the specified path

[root@localhost ~] # dd if=/path/to/image of=/dev/hdx # restore backup files to the specified disk

[root@localhost ~] # gzip-dc / path/to/image.gz | dd of=/dev/hdx # restore compressed backup files to the specified disk

[root@localhost ~] # dd if=/dev/hdx of=/path/to/image count=1 bs=512 # MBR information of 512Byte size at the beginning of backup disk to the specified file

[root@localhost ~] # dd if=/dev/cdrom of=/root/cd.iso # copy the CD data to the root folder and save it as a cd.iso file

At this point, I believe you have a deeper understanding of the "introduction to the specific usage of the dd command in the Linux system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report