mbl_gen_hdd_img.sh 630 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env bash
  2. set -x
  3. [ $# -eq 3 ] || {
  4. echo "SYNTAX: $0 <file> <bootfs image> <rootfs image>"
  5. exit 1
  6. }
  7. OUTPUT="$1"
  8. BOOTFS="$2"
  9. ROOTFS="$3"
  10. let "BOOTFSSIZE=(`stat -c%s "$2"` + 1048575) / 1048576"
  11. let "ROOTFSSIZE=(`stat -c%s "$3"` + 1048575) / 1048576"
  12. head=4
  13. sect=63
  14. set `ptgen -o $OUTPUT -h $head -s $sect -l 4096 -t 83 -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