Linux dd 命令的用法

來源:互聯網
上載者:User

Linux dd 命令的用法 dd 是 Linux/UNIX 下的一個非常有用的命令,作用是用指定大小的塊拷貝一個檔案,並在拷貝的同時進行指定的轉換。

dd 的主要選項: 指定數位地方若以下列字元結尾乘以相應的數字: b=512, c=1, k=1024, w=2, xm=number m if=file 輸入檔案名稱,預設為標準輸入。 of=file 輸出檔案名,預設為標準輸出。 ibs=bytes 一次讀入 bytes 個位元組(即一個塊大小為 bytes 個位元組)。 obs=bytes 一次寫 bytes 個位元組(即一個塊大小為 bytes 個位元組)。 bs=bytes 同時設定讀寫塊的大小為 bytes ,可代替 ibs 和 obs 。 cbs=bytes 一次轉換 bytes 個位元組,即轉換緩衝區大小。 skip=blocks 從輸入檔案開頭跳過 blocks 個塊後再開始複製。 seek=blocks 從輸出檔案開頭跳過 blocks 個塊後再開始複製。(通常只有當輸出檔案是磁碟或磁帶時才有效) count=blocks 僅拷貝 blocks 個塊,塊大小等於 ibs 指定的位元組數。 conv=conversion[,conversion...] 用指定的參數轉換檔。 轉換參數: ascii 轉換 EBCDIC 為 ASCII。 ebcdic 轉換 ASCII 為 EBCDIC。 ibm 轉換 ASCII 為 alternate EBCDIC. block 把每一行轉換為長度為 cbs 的記錄,不足部分用空格填充。 unblock 使每一行的長度都為 cbs ,不足部分用空格填充。 lcase 把大寫字元轉換為小寫字元。 ucase 把小寫字元轉換為大寫字元。 swab 交換輸入的每對位元組。 Unlike the Unix dd, this works when an odd number of bytes are read. If the input file contains an odd number of bytes, the last byte is simply copied (since there is nothing to swap it with). noerror 出錯時不停止。 notrunc 不截短輸出檔案。 sync 把每個輸入塊填充到ibs個位元組,不足部分用空(NUL)字元補齊。

 由於 dd 命令允許二進位方式讀寫,所以特別適合在原始物理裝置上進行輸入/輸出。

例如可以用下面的命令為磁碟片建立鏡像檔案:

 dd if=/dev/fd0 of=disk.img bs=1440k

有趣的是,這個鏡像檔案能被 HD-Copy ,Winimage 等工具軟體讀出。

再如把第一個硬碟的前 512 個位元組存為一個檔案:

 dd if=/dev/hda of=disk.mbr bs=512 count=1

產生Xen使用的鏡像硬碟檔案

A: dd if=/dev/zero of=/disk2/xen/centos5.office.img bs=1M count=3072 oflag=direct B: dd if=/dev/zero of=centos5.img bs=2k seek=4096k count=1

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.