gen_rpi_sdcard_img.sh 580 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env bash
  2. set -x
  3. [ $# -eq 5 ] || {
  4. echo "SYNTAX: $0 <file> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
  5. exit 1
  6. }
  7. OUTPUT="$1"
  8. BOOTFS="$2"
  9. ROOTFS="$3"
  10. BOOTFSSIZE="$4"
  11. ROOTFSSIZE="$5"
  12. head=4
  13. sect=63
  14. set `ptgen -o $OUTPUT -h $head -s $sect -l 4096 -t c -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M`
  15. BOOTOFFSET="$(($1 / 512))"
  16. BOOTSIZE="$(($2 / 512))"
  17. ROOTFSOFFSET="$(($3 / 512))"
  18. ROOTFSSIZE="$(($4 / 512))"
  19. dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
  20. dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc