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

How to check the progress of dd in dos

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

Share

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

Editor to share with you how to check the progress of dd in dos, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Because the speed of data copy during the dd process will be printed after the execution of the dd command, many people use dd to test the IBO of the disk, hoping to use the results as reference data to compare the read and write ability of the disk under different service providers or different hardware configurations. Although an average speed is displayed after the command is executed, no information is displayed during execution, which causes the operator to wait endlessly when copying large files.

Step 1: create a new window to find the PID corresponding to the current dd command

The code is as follows:

Pgrep-l'^ dd$'.pgrep-l'^ dd$'

The result is:

8269 dd.8269 dd

Step 2: send USR1 instructions to the dd process

The code is as follows:

Kill-USR1 8269.kill-USR1 8269

At this point, you will see the size of the data that has been copied and the speed per second in the window where you are executing the dd command.

Of course, if you have only one dd process executing, you can also use the following command directly:

The code is as follows:

Kill-USR1 `pgrep ^ dd`.kill-USR1 `pgrep ^ dd`

If you can't wait, you can use this command to output every other second:

The code is as follows:

Watch-N1 'sudo kill-USR1 `pgrep ^ dd`' .watch-N1 'sudo kill-USR1 `pgrep ^ dd`'

Of course, you can also do this, when you execute the dd command, let him automatically continue to output:

The code is as follows:

Dd if=/dev/zero of=/home/test & pidymagram; while [[- d / proc/$pid]]; do kill-USR1 $pid & & sleep 1 & & clear; done.dd if=/dev/zero of=/home/test & pidymen; while [[- d / proc/$pid]]; do kill-USR1 $pid & & sleep 1 & & clear; done

Dd parameter interpretation

1. If= file name: enter the file name. Default is standard input. That is, specify the source file.

< if=input file >

2. Of= file name: output file name, default is standard output. That is, specify the destination file.

< of=output file >

3. Ibs=bytes: read bytes bytes at a time, that is, specify a block size of bytes bytes.

Obs=bytes: output bytes bytes at a time, specifying a block size of bytes bytes.

Bs=bytes: set the read / output block size to bytes bytes at the same time.

4. Cbs=bytes: convert bytes bytes at a time, that is, specify the conversion buffer size.

5. Skip=blocks: skip blocks blocks from the beginning of the input file and then start copying.

6. Seek=blocks: skip blocks blocks from the beginning of the output file and then start copying.

Note: it is usually only valid when the output file is a disk or tape, that is, when backing up to a disk or tape.

7. Count=blocks: only blocks blocks are copied, and the block size is equal to the number of bytes specified by ibs.

8. Conv=conversion: converts the file with the specified parameters.

Ascii: converting ebcdic to ascii

Ebcdic: converting ascii to ebcdic

Ibm: converting ascii to alternate ebcdic

Block: convert each line to a length of cbs, and fill in the gaps with blanks

Unblock: make the length of each line cbs, and fill the insufficient parts with blanks

Lcase: convert uppercase characters to lowercase characters

Ucase: convert lowercase characters to uppercase characters

Swab: swap each pair of bytes of input

Noerror: don't stop when something goes wrong

Notrunc: output files are not truncated

Sync: populate each input block into ibs bytes, and fill in the shortfalls with NUL characters.

Some application examples of dd

1. Back up the local / dev/hdb entire disk to / dev/hdd

The code is as follows:

Dd if=/dev/hdb of=/dev/hdd.dd if=/dev/hdb of=/dev/hdd

two。 Back up the whole / dev/hdb data to the image file of the specified path

The code is as follows:

Dd if=/dev/hdb of=/root/image.dd if=/dev/hdb of=/root/image

3. Restore backup files to the specified disk

The code is as follows:

Dd if=/root/image of=/dev/hdb.dd if=/root/image of=/dev/hdb

4. Backup / dev/hdb full data, and use gzip tool to compress and save to the specified path

The code is as follows:

Dd if=/dev/hdb | gzip > / root/image.gz.dd if=/dev/hdb | gzip > / root/image.gz

5. Restore the compressed backup file to the specified disk

The code is as follows:

Gzip-dc / root/image.gz | dd of=/dev/hdb.gzip-dc / root/image.gz | dd of=/dev/hdb

6. Back up 512 bytes of MBR information from the beginning of the disk to the specified file

The code is as follows:

Dd if=/dev/hda of=/root/image count=1 bs=512

# count=1 refers to copying only one block; bs=512 refers to a block size of 512 bytes.

# restore:

Dd if=/root/image of=/dev/hda.

7. Backup floppy disk

The code is as follows:

Dd if=/dev/fd0 of=disk.img count=1 bs=1440k # (i.e. block size is 1.44m). Dd if=/dev/fd0 of=disk.img count=1 bs=1440k # (i.e. block size is 1.44m)

8. Copy the memory contents to the hard disk

The code is as follows:

Dd if=/dev/mem of=/root/mem.bin bs=1024 # (specify a block size of 1k) .dd if=/dev/mem of=/root/mem.bin bs=1024 # (specify a block size of 1k)

9. Copy the contents of the CD to the specified folder and save it as a cd.iso file

The code is as follows:

Dd if=/dev/cdrom (hdc) of=/root/cd.iso.dd if=/dev/cdrom (hdc) of=/root/cd.iso

10. Increase swap partition file size

The code is as follows:

# step 1: create a file with a size of 256m:

Dd if=/dev/zero of=/swapfile bs=1024 count=262144

# step 2: change this file into a swap file:

Mkswap / swapfile

# step 3: enable this swap file:

Swapon / swapfile

# step 4: edit the / etc/fstab file so that the swap file is loaded automatically every time you boot:

/ swapfile swap swap default 0 0.# step 1: create a file with a size of 256m:

Dd if=/dev/zero of=/swapfile bs=1024 count=262144

# step 2: change this file into a swap file:

Mkswap / swapfile

# step 3: enable this swap file:

Swapon / swapfile

# step 4: edit the / etc/fstab file so that the swap file is loaded automatically every time you boot:

/ swapfile swap swap default 0 0

11. Destroy disk data

The code is as follows:

Dd if=/dev/urandom of=/dev/hda1

# Note: filling the hard disk with random data can be used to destroy data in some necessary situations. .dd if=/dev/urandom of=/dev/hda1

# Note: filling the hard disk with random data can be used to destroy data in some necessary situations.

twelve。 Test the read and write speed of the hard disk

The code is as follows:

Dd if=/dev/zero bs=1024 count=1000000 of=/root/1Gb.file

Dd if=/root/1Gb.file bs=64k | dd of=/dev/null

# through the command execution time output from the above two commands, the read and write speed of the hard disk can be calculated. .dd if=/dev/zero bs=1024 count=1000000 of=/root/1Gb.file

Dd if=/root/1Gb.file bs=64k | dd of=/dev/null

# through the command execution time output from the above two commands, the read and write speed of the hard disk can be calculated.

13. Determine the optimal block size for the hard drive:

The code is as follows:

Dd if=/dev/zero bs=1024 count=1000000 of=/root/1Gb.file

Dd if=/dev/zero bs=2048 count=500000 of=/root/1Gb.file

Dd if=/dev/zero bs=4096 count=250000 of=/root/1Gb.file

Dd if=/dev/zero bs=8192 count=125000 of=/root/1Gb.file

# by comparing the command execution time shown in the above command output, you can determine the best block size for the system. .

14. Repair hard disk

The code is as follows:

Dd if=/dev/sda of=/dev/sda.dd if=/dev/sda of=/dev/sda

When the hard disk is not in use for a long time (for example, 1 or 2 years), magnetic fluxpoint will be generated on the disk. It is difficult for the head to read these areas and may result in an Icano error. When this situation affects the first sector of the hard disk, it may cause the hard disk to be scrapped. The above command has the potential to bring the data back to life. And the process is safe and efficient.

The above is all the contents of the article "how to check dd Progress in dos". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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