dd bytesize

I read the manual about the dd and the example and I have seen the use of the bs option, the byte size.

However how can you know that you need to use it and how can you know what size to give it?

like in wwikipedia they give the following:

but why 4096 and why mention it at all

"bs" is the block size, not the byte size (a byte is always 8 bits). Reasons you might want to use it:

  • To transfer a certain amount of fixed-size records (using bs and count options)
  • To match the block size of a device, thus reducing I/O blocking (eg. for hard disks and tapes)
  • To make use of a large buffer, thus reducing I/O requests

Simple example: you want to create a backup of the master boot record prior to changing the layout, it's as simple as dd if=/dev/sda of=part_table.backup bs=512 count=1 , since the MBR is exactly the 512 bytes at the beginning of the disk (including boot loader, partition table, ...)

1 Like

thanks you.

regarding the second use "To match the block size of a device", who can I know the block size of a device?
like for example my hard disk

Depends on your system, which you haven't said, but most drives these days have either 512-byte or 4096-byte sectors. But the block size isn't quite so relevant these days; the OS talks to the drive, and the OS knows the block size, so won't mess up. And you can pick a block size in the megabytes to make transfers more efficient, by doing more per read/write cycle..

1 Like