7

I try to run simple test case on linux operating system with dd command .

I create a simple disk image with this command :

dd if=/dev/urandom of=disk.img bs=1M count=100 

This is First Test :
Now I run this commands :

dd if=disk.img of=output_1 bs=1k count=4
dd if=disk.img of=output_2 bs=4k count=1
md5sum output_1 output_2 
bc0245c10ff529042fd2a5335ed1573f  output_1
bc0245c10ff529042fd2a5335ed1573f  output_2   

You can see output_1 and output_2 exactly has same md5 hash .

This is Second Test :
Now I add skip parameter to dd command :

dd if=disk.img of=output_1 skip=1500 bs=1k count=4 
dd if=disk.img of=output_2 skip=1500 bs=4k count=1
c5b0e8dde317c25011b31a5c48580477  output_1
4585d39fcf93cec4abc6c55094aac724  output_2    

Why result is difference for this blocks ?
What part of my test is wrong ?

  • you should also add iflag=fullblock – hanshenrik Jan 23 at 8:50
12

The skip parameter is in (input) blocks, not in bytes, as written in the man page:

skip=N    skip N ibs-sized blocks at start of input

In the first case the skipped part is:

1500 * 1KiB = 1536000 bytes

The second case:

1500 * 4KiB = 6144000 bytes

As long as the involved values divide exactly you can adjust. For the second case using 1500*1k/4k=375 (skip=375) will give back the same result as the first case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.