Note: This page is for use with the latest Knoppix 6. If you are using an older version such as Knoppix 5 or 4, then you may want to use this How-To instead. |
Using dd without additional options is fine but it can go very slowly because it has to make sure it does not try to collect more than it should, therefore a lot of unnecessary checks and tests are done to read data one byte at a time.
To dramatically speed up dd, you should tell it to use the block size option to read data in blocks of 8192 to 65536 bytes (8K to 64K) at a time but you should use a correct value so that you do not over-shoot or under-shoot the correct amount of data.
If you use the fdisk command, you can find the correct block size.
STEPS TO FOLLOW TO FIND THE CORRECT BLOCK SIZE
When you run fdisk /dev/sda you will want to type p to display the partition table information, and then type q to quit fdisk.
root@Microknoppix:/media# fdisk /dev/sda You will not be able to write the partition table. Note: sector size is 2048 (not 512) Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Command (m for help): p Disk /dev/hda: 730 MB, 730177536 bytes 255 heads, 63 sectors/track, 22 cylinders Units = cylinders of 16065 * 2048 = 32901120 bytes Device Boot Start End Blocks Id System Command (m for help): q root@Microknoppix:/media# |
After running fdisk, from the above you can determine that the harddrive is 730MB in size, that there are cylinders of 16065 made up of blocks of 2048 bytes per block.
You can keep it simple by using a block size of 2048 (which is a dramatic increase of about 2048), but you can increase the speed slightly further by using a larger block size between 8192 to 65536 bytes in size.
Looking at the 16065, it appears you can evenly divide it by 5, so 16065 divide by 5 is "3213" which is good, therefore, you can increase the block size by 5 as well, so 2048 x 5 is equal to "10240".
If you want to increase the speed a little further, it appears you can evenly divide 3213 by 3 to give you "1071" which is also good, therefore, you can increase the block size by 3 as well, so 10240 x 3 is equal to "30720".
Since you are in the range of 8192 to 65536, there is no need to try improve it more because when the blocks begin to get too large, it will begin to work against you and you may begin to see the transfer speed drop.
You will want to add the "block size" parameter with the value you discovered above, so if you are going to make a backup image, then you will want to include the bs option and type it this way instead:
root@Microknoppix:/media# dd bs=30720 if=/dev/sda | gzip -c | split -b 638m - backup/backup.img.gz. root@Microknoppix:/media# |
If you are going to make a restoration, then you will want to include the bs option and type it this way instead:
root@Microknoppix:/media# cat backup/backup.img.gz.* | gzip -dc | dd bs=30720 of=/dev/sda root@Microknoppix:/media# |