I have a laptop partition (truecrypt) backed up with dd since it's impossible to back it up with anything else but do a raw bit by bit copy like:

dd if=/dev/sda of=imagefile.img

I can of course successfully restore this as well but the restore time is long with the default bs (512).

Would it cause any inconsistency if I would increase the BS size to let's say 1MB? The machine have 8Gb memory, reading 1mb or 10mb or 100mb into memory before writing it out to the disk shouldn't matter but I'm curious what will it do when it reaches the end of the image file and the end of the partition. Wouldn't it try to overwrite data on the next disk area??

Let's say at the last read only 512bytes left in the image, wouldn't it try to write out that 512bytes+the remaining 0.00048828125 Mbyte to the disk?

dd if=imagefile.img of=/dev/sda1 bs=1M


migrated from serverfault.com Jan 22 '15 at 12:04

This question came from our site for system and network administrators.

  • 1
    No, it wouldn't. – frostschutz Jan 22 '15 at 12:08
  • 1
    dd won't write out more than it read, unless you're using conv=sync as an option. Note that you're creating the image from /dev/sda but in your example you're restoring to /dev/sda1, so that obviously won't work as expected :-) Apart from that: Linux won't allow you to write past the end of a partition e.g when writing to /dev/sda1, so you don't have to worry other partitions will be touched. That's what they're partitions for. – wurtel Jan 22 '15 at 12:09

Best thing to do would be to run an MD5 hash on all files prior to the backup and then do a restore and check the MD5 hashes against them.

dd if=imagefile.img of=/dev/sda1 bs=4M

You can even try 16M or larger. Just make sure to keep checking the MD5 hashes occasionally.

Data inconsistency can be caused by a number of different things, I doubt the BS option itself would cause them, usually it depends on what the machine is doing during the backup that might cause data inconsistency.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy