操作系統製作(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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章