Dd: Different Unit for Bs, Skip and Count?

Dd: Different Unit for Bs, Skip and Count?

I am trying to copy a partition from an entire disk image.

This command is working: dd if=image.iso of=test bs=512 skip=1161215 count=32768

In order to increase the speed, I'd like to set a bigger bs.

dd if=image.iso of=test bs=1M skip=1161215 count=32768

skip and count's unit is bs, is it possible to set a separate unit ?

I could then make this command:

dd if=image.iso of=test bs=4M skip=1161215*512 bytes count=32768*512 bytes

4 Answers

Specify Different Units

Yes, it is possible to specifiy different units for bs and skip and count. However, there are only two choices for the skip and count units. skip and count must match the bs value or be specified in bytes. To set the units to bytes you must add an additional operand of iflag=skip_bytes for skip and iflag=count_bytes for count or iflag=skip_bytes,count_bytes for both.

In your case, this command should accomplish your goal:

dd if=image.iso of=test iflag=skip_bytes,count_bytes bs=4M \
  skip=$((1161215*512)) count=$((32768*512))

It appears you want to extract exactly 16M. Set bs=4M count=4 and use only skip_bytes:

dd if=input.file of=output.file iflag=skip_bytes bs=4M \
  skip=$((1161215*512)) count=4
Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.