I have 40gb image split into 10 4gb files, then combined with dm-linear to create single 40gb drive. One file got damaged single 4kb sector. However when I'm copying data unsing either dd or ddrescue resulting file is 4kb smaller than original file. It results in VM boot failure due to invalid physical disk size. How can i copy this image and fill this 4kb sector with 0s to preserve file size and offsets?
dd bs=4k conv=sync,noerror if=damaged_source_image of=destination_image
dd will continue after encountering a read error. With
sync, the unread bytes (due to the read error) will be written as zeros.
See this question for an extended discussion on this.