gen_image.sh 463 B

123456789101112131415161718
  1. #!/usr/bin/env bash
  2. OUTPUT="$1"
  3. KERNELSIZE="$2"
  4. KERNELIMAGE="$3"
  5. ROOTFSSIZE="$4"
  6. ROOTFSIMAGE="$5"
  7. ALIGN="$6"
  8. rm -f "$OUTPUT"
  9. # create partition table
  10. set `ptgen -o "$OUTPUT" -h 16 -s 32 -l ${ALIGN} -t 0x27 -p ${KERNELSIZE}m -t 0x83 -p ${ROOTFSSIZE}m`
  11. KERNELOFFSET="$(($1 / 512))"
  12. ROOTFSOFFSET="$(($3 / 512))"
  13. dd if="$KERNELIMAGE" of="$OUTPUT" bs=512 conv=notrunc seek="$KERNELOFFSET"
  14. dd if="$ROOTFSIMAGE" of="$OUTPUT" bs=512 conv=notrunc seek="$ROOTFSOFFSET"