2013-03-06 101 views
3

我想使用dd從磁盤上的特定位置(基本上跳過第一個50000字節)開始寫入數據,並在第一個50000字節後開始寫入數據。我試着這樣做使用dd從特定位置開始寫入數據

=的/ dev/disk1的的DD如果=的/ dev /隨機尋求= 50000

我讓了幾分鐘以上線路運行,然後當我取消它,我得到這個

0 + 0記錄在 0 + 0記錄輸出 0字節(0 B)複製,79.2458 s,0.0 kB/s 在我看來,沒有得到複製。我做錯了什麼?

回答

5

dd docs

‘seek=n’ 

Skip n ‘obs’-byte blocks in the output file before copying. 
if ‘oflag=seek_bytes’ is specified, n is interpreted as a byte 
count rather than a block count. 

所以它看起來像你想的:

dd of=/dev/disk1 if=/dev/random obs=50000 seek=1 

或者這樣:

dd of=/dev/disk1 if=/dev/random oflag=seek_bytes seek=50000 

另一件事是,如果內核池/dev/random將阻止空。您可以嘗試/dev/urandom代替,這將使用其他方法來生成一個數字,沒有阻塞時,池爲空:

dd of=/dev/disk1 if=/dev/urandom oflag=seek_bytes seek=50000 
+0

當我使用的第一個命令,並運行它的幾秒鐘,我看到=/dev的這個DD/disk1 if =/dev/random obs = 50000 seek = 1 0 + 8記錄在 0 + 0記錄輸出 0字節(0 B)複製,100.714 s,0.0 kB/s爲什麼說複製0 B? – user238021 2013-03-06 03:11:05

+0

更新了答案 – perreal 2013-03-06 03:12:20

相關問題