Thursday, May 16, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1627  / 3 Years ago, thu, october 14, 2021, 3:15:29

Please see the dd command and the output below.


dd if=/dev/null of=./VirtualDisk.img bs=1M count=1024  
0+0 records in
0+0 records out
0 bytes copied, 0.000281296 s, 0.0 kB/s

I expected 1024 blocks of size 1MB will be written to the output file. But why is the output file size of VirtualDisk.img 0?


Also, see another example.


dd if=/dev/null of=./VirtualDisk.img bs=1M seek=1024
0+0 records in
0+0 records out
0 bytes copied, 0.000254032 s, 0.0 kB/s

According to the manual, is should skip 1024 blocks of size 1MB from the start of output file. But the generated output file size of VirtualDisk.img is 1073741824 (1MB * 1024). I could see the skipped region was filled with zero.


THis is the dd manual : https://man7.org/linux/man-pages/man1/dd.1.html

To me, the behavior for count and seek is different from what the manual says. How should I absorb this behaviour?


More From » boot

 Answers
3

seek= how far you go ahead in the output file


skip= how far you go ahead in the input file


count= how many segments you copy (can be set via bs=)


say you have 2 16 byte files like so:


file1: 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF

file2: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01

heres some commands and sample outputs:


dd if=file1 of=file2 count=12 bs=1 seek=4
file2: 01 01 01 01 [00 11 22 33 44 55 66 77 88 99 AA BB]


dd if=file1 of=file2 count=12 bs=1 skip=4
file2: [44 55 66 77 88 99 AA BB CC DD EE FF] 01 01 01 01

dd if=file1 of=file2 count=12 bs=1 skip=4 seek=4 count=8
file2: 01 01 01 01 [44 55 66 77 88 99 AA BB] 01 01 01 01

[#1694] Friday, October 15, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aradxalte

Total Points: 70
Total Questions: 116
Total Answers: 116

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
aradxalte questions
;