dd 中的 oflag 是什么?

dd 中的 oflag 是什么?

oflag命令中的用途是什么dd

有什么选择oflag=

目前我正在做dd if=/dev/zero of=/dev/sdb bs=4096

擦除磁盘。

答案1

直接取自info dd

(注意:这是从 [Lubuntu] 20.04 盒子中获取的;因此它可能包含您的版本中不存在的标志,因此您最好info dd在自己的盒子上使用以准确查看您的系统可用的内容)

oflag=FLAG[,FLAG]...' 使用 FLAG 参数指定的标志访问输出文件。(逗号周围没有空格。)

 Here are the flags.  Not every flag is supported on every operating
 system.

 ‘append’
      Write in append mode, so that even if some other process is
      writing to this file, every ‘dd’ write will append to the
      current contents of the file.  This flag makes sense only for
      output.  If you combine this flag with the ‘of=FILE’ operand,
      you should also specify ‘conv=notrunc’ unless you want the
      output file to be truncated before being appended to.

 ‘cio’
      Use concurrent I/O mode for data.  This mode performs direct
      I/O and drops the POSIX requirement to serialize all I/O to
      the same file.  A file cannot be opened in CIO mode and with a
      standard open at the same time.

 ‘direct’
      Use direct I/O for data, avoiding the buffer cache.  Note that
      the kernel may impose restrictions on read or write buffer
      sizes.  For example, with an ext4 destination file system and
      a Linux-based kernel, using ‘oflag=direct’ will cause writes
      to fail with ‘EINVAL’ if the output buffer size is not a
      multiple of 512.

 ‘directory’

      Fail unless the file is a directory.  Most operating systems
      do not allow I/O to a directory, so this flag has limited
      utility.

 ‘dsync’
      Use synchronized I/O for data.  For the output file, this
      forces a physical write of output data on each write.  For the
      input file, this flag can matter when reading from a remote
      file that has been written to synchronously by some other
      process.  Metadata (e.g., last-access and last-modified time)
      is not necessarily synchronized.

 ‘sync’
      Use synchronized I/O for both data and metadata.

 ‘nocache’
      Request to discard the system data cache for a file.  When
      count=0 all cached data for the file is specified, otherwise
      the cache is dropped for the processed portion of the file.
      Also when count=0, failure to discard the cache is diagnosed
      and reflected in the exit status.

      Note data that is not already persisted to storage will not be
      discarded from cache, so note the use of the “sync” options in
      the examples below, which are used to maximize the
      effectiveness of the ‘nocache’ flag.

      Here are some usage examples:

           # Advise to drop cache for whole file
           dd if=ifile iflag=nocache count=0

           # Ensure drop cache for the whole file
           dd of=ofile oflag=nocache conv=notrunc,fdatasync count=0

           # Advise to drop cache for part of file
           # Note the kernel will only consider complete and
           # already persisted pages.
           dd if=ifile iflag=nocache skip=10 count=10 of=/dev/null

           # Stream data using just the read-ahead cache.
           # See also the ‘direct’ flag.
           dd if=ifile of=ofile iflag=nocache oflag=nocache,sync

 ‘nonblock’
      Use non-blocking I/O.

 ‘noatime’
      Do not update the file’s access timestamp.  *Note File
      timestamps::.  Some older file systems silently ignore this
      flag, so it is a good idea to test it on your files before
      relying on it.

 ‘noctty’
      Do not assign the file to be a controlling terminal for ‘dd’.
      This has no effect when the file is not a terminal.  On many
      hosts (e.g., GNU/Linux hosts), this option has no effect at
      all.

 ‘nofollow’
      Do not follow symbolic links.

 ‘nolinks’
      Fail if the file has multiple hard links.

 ‘binary’
      Use binary I/O.  This option has an effect only on nonstandard
      platforms that distinguish binary from text I/O.

 ‘text’
      Use text I/O.  Like ‘binary’, this option has no effect on
      standard platforms.

 ‘fullblock’
      Accumulate full blocks from input.  The ‘read’ system call may
      return early if a full block is not available.  When that
      happens, continue calling ‘read’ to fill the remainder of the
      block.  This flag can be used only with ‘iflag’.  This flag is
      useful with pipes for example as they may return short reads.
      In that case, this flag is needed to ensure that a ‘count=’
      argument is interpreted as a block count rather than a count
      of read operations.

 ‘count_bytes’
      Interpret the ‘count=’ operand as a byte count, rather than a
      block count, which allows specifying a length that is not a
      multiple of the I/O block size.  This flag can be used only
      with ‘iflag’.

 ‘skip_bytes’
      Interpret the ‘skip=’ operand as a byte count, rather than a
      block count, which allows specifying an offset that is not a
      multiple of the I/O block size.  This flag can be used only
      with ‘iflag’.

 ‘seek_bytes’
      Interpret the ‘seek=’ operand as a byte count, rather than a
      block count, which allows specifying an offset that is not a
      multiple of the I/O block size.  This flag can be used only
      with ‘oflag’.

 These flags are not supported on all systems, and ‘dd’ rejects
 attempts to use them when they are not supported.  When reading
 from standard input or writing to standard output, the ‘nofollow’
 and ‘noctty’ flags should not be specified, and the other flags
 (e.g., ‘nonblock’) can affect how other processes behave with the
 affected file descriptors, even after ‘dd’ exits.

man ddinfo将为您可以用来查看其他页面的许多复杂命令提供快速的 manual.reference.page 信息。

相关内容