Detailed description of/dev/null and/dev/zero files, solutions for accidental deletion of/dev/null and/dev/zero, and disk I/O testing using/dev/zero

Source: Internet
Author: User

Detailed description of/dev/null and/dev/zero files, solutions for accidental deletion of/dev/null and/dev/zero, and disk I/O testing using/dev/zero
1. Introduction-explanation from Wikipedia/dev/null:

In Unix-like systems,/dev/null, or an empty device, is a special device file that discards all data written into it (but reports a successful write operation ), read it to get an EOF immediately.

/Dev/zero:

In UNIX-like operating systems,/dev/zero is a special file. When you read it, it provides unlimited NULL characters (NULL, ascii nul, 0x00 ). One typical usage is to overwrite information with the volume stream provided by it. Another common usage is to generate a blank file of a specific size. BSD maps/dev/zero to the virtual address space through mmap to implement shared memory. Mmap can be used to map/dev/zero to a virtual memory space. The effect of this operation is equivalent to using an anonymous memory (not related to any files ). (Source:/dev/zero-Wikipedia)

The following is an example of how to extract personal information from the sky:

The/dev/null nickname is a bottomless pit. You can output any data to it. It doesn't support it!

2. daily use of/dev/null regards/dev/null as a "black hole ". It is equivalent to a write-only file, and all the content written to it will be lost forever, and the attempt to read the content from it will not be able to read anything. However,/dev/null is very useful for both command lines and scripts.

Blocks =1 {1:-$ MINBLOCKS} # If the command line is not specified, set it to 40 by default.
The solution for accidentally deleting the/dev/zero file is as follows: [root @ localhost zhaiqutianshangxing] # mknod/dev/zero c 1 5
The solution for deleting the/dev/null file by mistake is as follows: [root @ localhost zhaiqutianshangxing] # mknod/dev/null c 1 3

Test disk IO using/dev/zero:

[Root @ localhost zhaiqutianshangxing] # dd if =/dev/zero of = test bs = 64 k count = 4 k oflag = dsync

For more details about the/dev/zero disk I/O testing instructions:

During a normal test, the test may not be performed on the other side, but the average value may be obtained many times. After the normal redirection is ineffective, google redirects the test results to a file in the following way:

2. dd if =/dev/zero of = test bs = 64 k count = 16 k conv = fsync

3. dd if =/dev/zero of = test bs = 64 k count = 4 k oflag = dsync

Next let's take a look at the VPS disk Performance
We recommend that you use dd bs = 1 M count = 128 if =/dev/zero of = test conv = fdatasync

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.