diff options
author | Michael Brown <mcb30@ipxe.org> | 2015-12-05 23:54:10 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2015-12-07 13:08:22 +0000 |
commit | 7f65a08f3e2606a5102fb68acf6ccf5fc283ecb6 (patch) | |
tree | 714de0295e7977592c187e1c94b2172f8d8b3396 /src/util | |
parent | 1fcd4223cc5bce800bf253ab34cbf2e996c9958e (diff) | |
download | ipxe-7f65a08f3e2606a5102fb68acf6ccf5fc283ecb6.tar.gz |
[efi] Add %.usb target for building EFI-bootable USB (or other) disk images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/util')
-rwxr-xr-x | src/util/genefidsk | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/util/genefidsk b/src/util/genefidsk new file mode 100755 index 000000000..7064f99b6 --- /dev/null +++ b/src/util/genefidsk @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Generate an EFI bootable disk image + +set -e + +function help() { + echo "Usage: ${0} [OPTIONS] <ipxe.efi>" + echo + echo "where OPTIONS are:" + echo " -h Show this help" + echo " -b Specify boot file name (e.g. bootx64.efi)" + echo " -o FILE Save disk image to file" +} + +BOOT=bootx64.efi + +while getopts "hb:o:" opt; do + case ${opt} in + h) + help + exit 0 + ;; + b) + BOOT="${OPTARG}" + ;; + o) + OUT="${OPTARG}" + ;; + esac +done + +shift $((OPTIND - 1)) +IN=$1 + +if [ -z "${IN}" ]; then + echo "${0}: no input file given" >&2 + help + exit 1 +fi + +if [ -z "${OUT}" ]; then + echo "${0}: no output file given" >&2 + help + exit 1 +fi + +# Create sparse output file +rm -f ${OUT} +truncate -s 1440K ${OUT} + +# Format disk +mformat -i ${OUT} -f 1440 :: + +# Create directory structure +mmd -i ${OUT} ::efi +mmd -i ${OUT} ::efi/boot + +# Copy bootable image +mcopy -i ${OUT} ${IN} ::efi/boot/${BOOT} |