1

I knew use dd if=a.bin of=a.img bs=512 count=1 commond can write a bin file to *.img file in ubuntu 15.10 , i got a file size equals the bin file , it's to small , i can't copy any other files to this img file

how do i write bin file to a exist img file

thanks a lot

HeFang
  • 11
  • 1
  • Make some C program (or script in Python, Ocaml, ...) to build the entire `.img` file from different constituents. Or consider some `ld` script – Basile Starynkevitch Nov 12 '15 at 08:21
  • thank a lot. I made a c program to deal with it,than it works – HeFang Nov 12 '15 at 08:36
  • Possible duplicate of [How do I write a bin file (512 bytes) to the first sector (sector 0) of a floppy disk?](http://stackoverflow.com/questions/32893607/how-do-i-write-a-bin-file-512-bytes-to-the-first-sector-sector-0-of-a-floppy) – Cody Gray - on strike Mar 22 '17 at 09:43

1 Answers1

1

This can be done in two pass:

dd if=a.bin of=a_m.img bs=512 count=1
dd if=a.img of=a_m.img conv=notrunc oflag=append bs=512 skip=1
SergA
  • 1,097
  • 13
  • 21