I found a few examples that claimed this but I could not manage to get dd to convert a file with a given block size to double that block size.
dd if=disk256bytesectors.img of=disk512bytesectors.img cbs=256 ibs=512 obs=512 conv=sync
My disk img is 10 megabytes in size I was expecting a new image of 20 megabytes, but no.
So what I need to happen is each 256 byte block get converted to a 512 byte block with the second half of each 512 byte block being null, zero, space or anything.
The dd manual state conv=sync
pads any input block shorter than ibs to that size with null bytes before conversion and output.
But the input block will never be shorter than itself?!?! So what does that mean?
Anyway how can I do this?
-b256
andbs=512
, the output was identical to whatbbe
had given me. The manual says-b
sends at most such-and-such number of bytes per step. Whendd
requests 512 bytes, will it always get exactly 256? If for any reason it gets less then the output will go out of sync. Doestype=2
guarantee this exactness maybe? – Kamil Maciorowski May 06 '20 at 20:35type=2
is a sort of "packet" mode, where each write made towards dd keeps its structure, so a dd read larger than the packet will only get one packet, thus preserving the "structure". If you provide your file as stdin to socat (as in<myfile socat -u ...
), then socat will always be able to read the 256 bytes it is asked to. If you use a pipe, as in my example, and the command you are using to fill the pipe is only sending a few bytes at a time, socat might not get the full 256 bytes, and so will send a short packet to dd. So just ensure you provide your file as stdin directly. – meuh May 06 '20 at 21:14socat
is a powerful tool but I didn't know this trick. Thanks. +1. – Kamil Maciorowski May 06 '20 at 21:21