Linux/dd

dd recovery
conv=sync,noerror dd if=/dev/sda of=/dev/sdb bs=1M conv=sync,noerror

"conv=sync tells dd to pad each block to the left with nulls, so that if, due to error, the full block cannot be read, the full length of the original data is preserved, even though not all of the data itself can be included in the image. that way you at least know how damaged the data is, which might provide you with forensic clues, and if you can't take an image at all due to bad blocks or whatever, you can't analyze any of the data. some is better than none. conv=sync,noerror is necessary to prevent dd from stopping on error and make a dump with same location for each blocks, than source. conv=sync is largely meaningless without noerror."

References:
 * http://linuxcommand.org/man_pages/dd1.html
 * http://vlinux-freak.blogspot.com/2011/01/how-to-use-dd-command.html
 * https://superuser.com/questions/622541/what-does-dd-conv-sync-noerror-do

direct io
dd if=/dev/zero of=out.img bs=1M count=1000 oflag=direct

Pad File
Error: size of old.img is not a multiple of 512

Pad to multiple of 512 dd if=old.img of=new.img obs=512 conv=sync

Add specific amount of bytes: dd if=/dev/zero bs=1 count=20 >> out.img

pad the output file with zeroes until the file size reaches 100 KB: dd if=inputFile.bin ibs=1k count=100 of=paddedFile.bin conv=sync

Pad with 0xFF: dd if=/dev/zero ibs=1k count=100 | tr "\000" "\377" >paddedFile.bin hexdump -C paddedFile.bin dd if=inputFile.bin of=paddedFile.bin conv=notrunc

References:
 * unix - How to append data in a file by dd? - Super User - https://superuser.com/questions/850267/how-to-append-data-in-a-file-by-dd
 * linux - How to pad a file with "FF" using dd? - Super User - https://superuser.com/questions/274972/how-to-pad-a-file-with-ff-using-dd
 * lofiadm: size of xxx.iso is not a multiple of 512 | Dbhk's Blog - https://dbhk.wordpress.com/2012/08/24/lofiadm-size-of-xxx-iso-is-not-a-multiple-of-512/

Append Data
dd if=/dev/shm/test bs=1G >>/data/sdb/test

dd if=/dev/shm/test of=/data/sdb/test bs=1G oflag=append conv=notrunc

Ref: unix - How to append data in a file by dd? - Super User - https://superuser.com/questions/850267/how-to-append-data-in-a-file-by-dd