I have seen examples of using the dd
and ddrescue
command, and I see that instead of asking the user for the size of the block on their device, they recommend using bs=1M
and I do not understand why.
What happens if the disk sector size is 512
bytes and 1MB
is assigned to bs
?
Can any value be used independently of the size of the disk sector?
In the case of discs of advanced format and with a capacity of 1TB, what do you recommend to use?
What is bs option and why it's used ?
It has been explained in dd is producing a 32 MB random file instead of 1 GB ( which I recommend reading, btw ) that
bs
option refers to how much singleread()
syscall would read and store in memory ( if size of memory and the device you're reading from allow for such size ). This is also referenced in the manual:Thus, it has nothing to do with number of blocks/sectors on the disk, but with
dd
's performance - storing more things in memory for faster processing. To quote one ServerFault answer:The choice of
bs
value has also been discussed on another stackoverflow post:As for why 1M it's potentially because people found this to be an optimal value. Remember that RAM size used to be 512M. So using 1M would be small enough to keep RAM usage low, but have decent
dd
speed.Concerning your question:
Nothing.
dd
will read data in chunks of 1MB. It doesn't change the data in any way. It may improvedd
speed as compared to smaller block size, but has no effect on the data itself.Different story would happen if you read in chunks smaller than the sector size of the drive: drives have to serve full sector size and the kernel caches that information. See Matthew Ife's answer on the same Serverfault post. But again, no effect on data itself.
Advanced format such as what ? As far as
dd
itself goes, it should not care about any disk format - all it knows is to read and write from and to block devices; it doesn't matter if you write to USB stick or SCSI drive - the syntax is the same, it's the kernel that handles the minute details and has drivers for those devices to properly pass the data.And again, capacity also doesn't matter. 1TB SATA drive is still an SATA drive.