You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

genefidsk 895B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. #
  3. # Generate an EFI bootable disk image
  4. set -e
  5. function help() {
  6. echo "Usage: ${0} [OPTIONS] <ipxe.efi>"
  7. echo
  8. echo "where OPTIONS are:"
  9. echo " -h Show this help"
  10. echo " -b Specify boot file name (e.g. bootx64.efi)"
  11. echo " -o FILE Save disk image to file"
  12. }
  13. BOOT=bootx64.efi
  14. while getopts "hb:o:" opt; do
  15. case ${opt} in
  16. h)
  17. help
  18. exit 0
  19. ;;
  20. b)
  21. BOOT="${OPTARG}"
  22. ;;
  23. o)
  24. OUT="${OPTARG}"
  25. ;;
  26. esac
  27. done
  28. shift $((OPTIND - 1))
  29. IN=$1
  30. if [ -z "${IN}" ]; then
  31. echo "${0}: no input file given" >&2
  32. help
  33. exit 1
  34. fi
  35. if [ -z "${OUT}" ]; then
  36. echo "${0}: no output file given" >&2
  37. help
  38. exit 1
  39. fi
  40. # Create sparse output file
  41. rm -f ${OUT}
  42. truncate -s 1440K ${OUT}
  43. # Format disk
  44. mformat -i ${OUT} -f 1440 ::
  45. # Create directory structure
  46. mmd -i ${OUT} ::efi
  47. mmd -i ${OUT} ::efi/boot
  48. # Copy bootable image
  49. mcopy -i ${OUT} ${IN} ::efi/boot/${BOOT}