Visit The New, Modern Unix Linux Community


dd bytesize


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users dd bytesize
# 1  
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:
Quote:
Using dd to duplicate one hard disk partition to another hard disk:
dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=noerror
but why 4096 and why mention it at all
# 2  
"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, ...)
This User Gave Thanks to pludi For This Post:
# 3  
Quote:
Originally Posted by pludi
"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, ...)
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
# 4  
Quote:
Originally Posted by programAngel
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..
This User Gave Thanks to Corona688 For This Post:

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #421
Difficulty: Medium
JavaScript is strongly typed.
True or False?

Featured Tech Videos