操作系统制作(6)dd命令使用

linux命令行输入:

dd --help
Usage: dd [OPERAND]...
  or:  dd OPTION
Copy a file, converting and formatting according to the operands.

  bs=BYTES        read and write up to BYTES bytes at a time (default: 512);
                  overrides ibs and obs
  cbs=BYTES       convert BYTES bytes at a time
  conv=CONVS      convert the file as per the comma separated symbol list
  count=N         copy only N input blocks
  ibs=BYTES       read up to BYTES bytes at a time (default: 512)
  if=FILE         read from FILE instead of stdin
  iflag=FLAGS     read as per the comma separated symbol list
  obs=BYTES       write BYTES bytes at a time (default: 512)
  of=FILE         write to FILE instead of stdout
  oflag=FLAGS     write as per the comma separated symbol list
  seek=N          skip N obs-sized blocks at start of output
  skip=N          skip N ibs-sized blocks at start of input
  status=LEVEL    The LEVEL of information to print to stderr;
                  'none' suppresses everything but error messages,
                  'noxfer' suppresses the final transfer statistics,
                  'progress' shows periodic transfer statistics

N and BYTES may be followed by the following multiplicative suffixes:
c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M,
GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

Each CONV symbol may be:

  ascii     from EBCDIC to ASCII
  ebcdic    from ASCII to EBCDIC
  ibm       from ASCII to alternate EBCDIC
  block     pad newline-terminated records with spaces to cbs-size
  unblock   replace trailing spaces in cbs-size records with newline
  lcase     change upper case to lower case
  ucase     change lower case to upper case
  sparse    try to seek rather than write the output for NUL input blocks
  swab      swap every pair of input bytes
  sync      pad every input block with NULs to ibs-size; when used
            with block or unblock, pad with spaces rather than NULs
  excl      fail if the output file already exists
  nocreat   do not create the output file
  notrunc   do not truncate the output file
  noerror   continue after read errors
  fdatasync  physically write output file data before finishing
  fsync     likewise, but also write metadata

Each FLAG symbol may be:

  append    append mode (makes sense only for output; conv=notrunc suggested)
  direct    use direct I/O for data
  directory  fail unless a directory
  dsync     use synchronized I/O for data
  sync      likewise, but also for metadata
  fullblock  accumulate full blocks of input (iflag only)
  nonblock  use non-blocking I/O
  noatime   do not update access time
  nocache   Request to drop cache.  See also oflag=sync
  noctty    do not assign controlling terminal from file
  nofollow  do not follow symlinks
  count_bytes  treat 'count=N' as a byte count (iflag only)
  skip_bytes  treat 'skip=N' as a byte count (iflag only)
  seek_bytes  treat 'seek=N' as a byte count (oflag only)

Sending a USR1 signal to a running 'dd' process makes it
print I/O statistics to standard error and then resume copying.

Options are:

      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/dd>
or available locally via: info '(coreutils) dd invocation'

中文翻译如下:

用法:dd [OPERAND] ......
  或者:dd OPTION
根据操作数复制文件,转换和格式化。

  bs = BYTES一次读取和写入BYTES字节(默认值:512);
                  覆盖ibs和obs
  cbs = BYTES一次转换BYTES字节
  conv = CONVS按照逗号分隔的符号列表转换文件
  count = N仅复制N个输入块
  ibs = BYTES一次读取BYTES字节(默认值:512)
  if = FILE从FILE而不是stdin读取
  iflag = FLAGS按逗号分隔的符号列表读取
  obs = BYTES一次写BYTES字节(默认值:512)
  of = FILE写入FILE而不是stdout
  oflag = FLAGS根据逗号分隔的符号列表写入
  seek = N在输出开始时跳过N个阻塞大小的块
  skip = N在输入开始时跳过N ibs大小的块
  status = LEVEL要打印到stderr的信息的级别;
                  'none'除了错误消息外都会抑制所有内容,
                  'noxfer'抑制最终转移统计,
                  'progress'显示定期传输统计信息

N和BYTES之后可以跟随以下乘法后缀:
c = 1,w = 2,b = 512,kB = 1000,K = 1024,MB = 1000 * 1000,M = 1024 * 1024,xM = M,
对于T,P,E,Z,Y,GB = 1000 * 1000 * 1000,G = 1024 * 1024 * 1024等。

每个CONV符号可以是:

  ascii从EBCDIC到ASCII
  从ASCII到EBCDIC的ebcdic
  从ASCII到交替EBCDIC的ibm
  阻止填充换行符终止的记录,其空格为cbs-size
  unblock用换行符替换cbs-size记录中的尾随空格
  lcase将大写更改为小写
  ucase将小写更改为大写
  稀疏尝试寻找而不是写入NUL输入块的输出
  swab交换每对输入字节
  每个输入块同步填充NUL到ibs大小; 使用时
            使用block或unblock,填充空格而不是NUL
  如果输出文件已存在,则excl失败
  nocreat不创建输出文件
  notrunc不截断输出文件
  阅读错误后,noerror继续
  fdatasync在完成之前物理写入输出文件数据
  fsync同样,但也写入元数据

每个FLAG符号可能是:

  追加附加模式(仅对输出有意义;建议使用conv = notrunc)
  直接使用直接I / O数据
  目录失败,除非目录
  dsync使用同步I / O进行数据
  同样地同步,但也用于元数据
  fullblock累积整个输入块(仅限iflag)
  非阻塞使用非阻塞I / O.
  noatime不更新访问时间
  nocache请求删除缓存。另见oflag = sync
  noctty不从文件中分配控制终端
  nofollow不遵循符号链接
  count_bytes将'count = N'视为字节数(仅限iflag)
  skip_bytes将'skip = N'视为字节数(仅限iflag)
  seek_bytes将'seek = N'视为字节数(仅限oflag)

将USR1信号发送到正在运行的'dd'进程就可以了
将I / O统计信息打印到标准错误,然后重新开始复制​​。

选项包括:

      --help显示此帮助并退出
      --version输出版本信息并退出

GNU coreutils在线帮助:<http://www.gnu.org/software/coreutils/>
完整文档:<http://www.gnu.org/software/coreutils/dd>
或通过以下方式在本地获取:info'(coreutils)dd invocation'

范例如下:
1)把A文件(bootsect)内容拷贝到B文件(boot.img)

dd if=bootsect of=boot.img

2)从A文件(bootsect)拷贝指定字节BYTES的数据到B文件(boot.img)

dd  ibs=BYTES if=bootsect of=boot.img

3)把A文件(system)指定字节后的内容拷贝到到B文件(boot.img)指定位置处,字节=ibs*seek参数

dd ibs=160 skip=1 seek=1 if=system of=boot.img
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章