-2

I created an image file using dd on my disk /dev/sda which fdisk says it is 500107862016 bytes in size. The resulting image file is 500108886016 bytes which is exactly 1024000 bytes larger.

  1. Why is the image file 1MB larger than my source disk? Is there something related to the fact that I specified bs=1M in my dd command?
  2. When I restore the image file onto another identical disk, I get "dd: error writing ‘/dev/sda’: No space left on device" error. Is this a problem? Will my new disk be corrupted?
waffle
  • 5
  • 3
  • 2
    Interesting question, but not really on topic here. http://unix.stackexchange.com probably the best bet – Pekka May 16 '16 at 17:26
  • 2
    Can you give us the exact command line? Specifying `conv=sync`, for example, will pad short input records, giving an output file whose size is a round multiple of the block size. 500108886016 is a round multiple of 1024*1024; 500107862016 isn't. – Mark Plotnick May 16 '16 at 17:53
  • i did: dd if=/dev/sda of=imagefile.iso bs=1M conv=noerror,sync – waffle May 16 '16 at 19:44
  • Why did you use `bs` parameter with a block device? buffer cache is handling all the buffering of your disk and no need of a buffer greater than the normal one sector (512 bytes) size. Also, why `conv=noerror,sync` You don't need any parameters to copy a disk image to a file, just `dd if=/dev/sda of=imagefile.iso` should work fine. By the way, what was the output of your dd command? this should help, instead of having us to adivinate. – Luis Colorado May 17 '16 at 13:49

1 Answers1

0

conv=noerror makes dd(1) continue after a reading error, and this is not what you want. Also conv=sync fills incomplete blocks (mainly last block) with zeros up to fill a complete block, so probably this appending zeros to your last block is what is making your file greater than the actual disk size.

You don't need to use any of the conv options you used. No conversion is going to be made, and dd(1) will write the incomplete last block in case of the image doesn't have a full block size (which is the case)

Just retry your command with:

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

and then

dd if=yourfile.img of=/dev/sdb

If you plan to use some greater buffer size (not needed, as you are using a block device and the kernel doesn't impose a blocksize for reading block devices) just use a multiple of the sector size that is a divisor of the whole disk size (something like one full track ---absurd, as today's disks' tracks are completely logical and don't have any relationship with actual disk geometry)

Luis Colorado
  • 10,974
  • 1
  • 16
  • 31
  • Can you help me of I've create .img file( in which ubuntu os) and I've restore to disk but not booting ubuntu? have a any idea about it? – Nullpointer Aug 26 '16 at 10:20