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

Basic usage of dd command

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

Share

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

This article mainly introduces "the basic use of dd command". In daily operation, I believe many people have doubts about the basic use of dd command. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "basic use of dd command"! Next, please follow the editor to study!

The role of the dd command (function)

The main function is to copy a file, that is, to copy a file with a block of the specified size and to perform the specified conversion at the same time (the default is to copy from standard input to standard output, which means that dd can be used in pipes).

Note: dd can read data from standard input or file, convert data according to the specified format, and then output to file, device or standard output.

1. Test the disk write ability (bs defaults to 512Bytes, 2048kbits, 512Bytes, i.e. 2048k*512B, corresponding to 1G bits)

[root@-centos] # dd if=/dev/zero of=./testfile count=2048k conv=fsync recorded 2097152 read 0 recorded 2097152 0 write out 1073741824 bytes (1.1 GB) replicated, 7.61593 seconds, 141 MB/ seconds

In this process, a large file testfile is generated, which is 1G in size

[root@centos] # ls-alhtr testfile-rw-r--r-- 1 root root 1.0G March 23 19:59 testfile

two。 Test disk read ability

View the corresponding disk of the server through fdisk, such as / dev/vda.

[root@centos] # dd if=/dev/vda of=/dev/null bs=1M 102400 0records in102400+0 records out107374182400 bytes (107GB) copied, 1084.11 s, 99.0 MB/s

3. Test the ability to read and write at the same time

Dd if=/dev/vda of=./path/to/testfile bs=1G

4. Other parameters

Iflag=flag uses iflag to control the behavior characteristics of input (reading data).

Oflag=flag uses oflag to control behavior characteristics when outputting (writing data).

If you want to avoid the file system cache and read and write directly without using buffer cache, you need to set iflag=direct,nonblockoflag=direct,nonblock like this.

Reference:

Https://www.jianshu.com/p/2aaec9208b20

At this point, the study on the "basic use of dd commands" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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