time dd if=/dev/zero bs=1024 count=1000000 of=./1Gb.file
dd if=./1Gb.file bs=64k |dd of=/dev/null
dd if=./1Gb.file bs=1MB |dd of=/dev/null
time有計時作用,dd用于復制,從if讀出,寫到of。if=/dev/zero不產生輸出,因此可以用來測試純寫速度。同理of=/dev/null不產生輸入,可以用來測試純讀速度。bs是每次讀或寫的大小,即一個塊的大小,count是讀寫塊的數量。
寫問文件測試
~/tmp> time dd if=/dev/zero bs=1024 count=1000000 of=./1Gb.file
1000000+0 records in
1000000+0 records out
1024000000 bytes (1.0 GB) copied, 2.28148 s, 449 MB/s
real 0m2.287s
user 0m0.240s
sys 0m1.933s
~/tmp> dd if=./1Gb.file bs=64k |dd of=/dev/null
15625+0 records in
15625+0 records out
1024000000 bytes (1.0 GB) copied, 2.67729 s, 382 MB/s
2000000+0 records in
2000000+0 records out
1024000000 bytes (1.0 GB) copied, 2.67744 s, 382 MB/s
~/tmp> rm -rf 1Gb.file
~/tmp> dd if=./1Gb.file bs=1MB |dd of=/dev/null
1024+0 records in
1024+0 records out
1024000000 bytes (1.0 GB) copied, 2.40457 s, 426 MB/s
1999872+1023 records in
2000000+0 records out
1024000000 bytes (1.0 GB) copied, 2.40462 s, 426 MB/s
參考:
http://www.tsingpost.com/articles/201401/344.html
語法:dd [選項]
if =輸入文件(或設備名稱)。
of =輸出文件(或設備名稱)。
ibs = bytes 一次讀取bytes字節,即讀入緩沖區的字節數。
skip = blocks 跳過讀入緩沖區開頭的ibs*blocks塊。
obs = bytes 一次寫入bytes字節,即寫入緩沖區的字節數。
bs = bytes 同時設置讀/寫緩沖區的字節數(等于設置ibs和obs)。
cbs = byte 一次轉換bytes字節。
count=blocks 只拷貝輸入的blocks塊。
conv = ASCII 把EBCDIC碼轉換為ASCIl碼。
conv = ebcdic 把ASCIl碼轉換為EBCDIC碼。
conv = ibm 把ASCIl碼轉換為alternate EBCDIC碼。
conv = block 把變動位轉換成固定字符。
conv = ublock 把固定位轉換成變動位。
conv = ucase 把字母由小寫轉換為大寫。
conv = lcase 把字母由大寫轉換為小寫。
conv = notrunc 不截短輸出文件。
conv = swab 交換每一對輸入字節。
conv = noerror 出錯時不停止處理。
conv = sync 把每個輸入記錄的大小都調到ibs的大小(用NUL填充)。