dns313_gen_hdd_img.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  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. # Create one empty partitions followed by the swap partition, then the
  15. # boot partition with the ./boot/zImage and then the rootfs partition.
  16. # The swap partition with type 82 is 128 MB since the DNS-313 has 64 MB of
  17. # memory so we assign twice of that as swap.
  18. # The boot partition must always be the third partition.
  19. # The user should use the first (blank) partition for user data storage,
  20. # this will typically be named /dev/sda1
  21. set $(ptgen -o $OUTPUT -h $head -s $sect -n -t 83 -p 0 -t 82 -p 128M -t 83 -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M)
  22. # Swapoffset and swapsize will be $1 and $2
  23. BOOTOFFSET="$(($3 / 512))"
  24. BOOTSIZE="$(($4 / 512))"
  25. ROOTFSOFFSET="$(($5 / 512))"
  26. ROOTFSSIZE="$(($6 / 512))"
  27. dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
  28. dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc