File: mkusb.sh

package info (click to toggle)
efitools 1.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 728 kB
  • sloc: ansic: 7,459; makefile: 124; perl: 119; sh: 35
file content (37 lines) | stat: -rwxr-xr-x 985 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
k=$1
e=$2
o=$3
if [ $# -ne 3 ]; then
    echo "Usage $0: key_dir efi_dir output_image_file"
    exit 1;
fi
t=/var/tmp/tmpusb.$$.img
if [ ! -d "$k" ]; then
    echo "Failed to find directory $k"
    exit 1;
fi
if [ ! -d "$e" ]; then
    echo "Failed to find directory $e"
    exit 1;
fi

dd if=/dev/zero of=${o} bs=512 count=102096
parted ${o} "mktable gpt"
parted ${o} "mkpart p fat32 2048s 102049s"
parted ${o} "toggle 1 boot"
parted ${o} "name 1 UEFI"
dd if=/dev/zero of=${t} bs=512 count=100000
mkfs -t vfat -n UEFI-Tools ${t}
mmd -i ${t} ::/EFI
mmd -i ${t} ::/EFI/BOOT
mmd -i ${t} ::/keys
mcopy -i ${t} ${k}/*.esl ::/keys
mcopy -i ${t} ${k}/*.auth ::/keys
mcopy -i ${t} ${e}/HashTool-signed.efi ::/EFI/BOOT/HashTool.efi
mcopy -i ${t} ${e}/KeyTool-signed.efi ::/EFI/BOOT/KeyTool.efi
mcopy -i ${t} ${e}/PreLoader-signed.efi ::/EFI/BOOT/BOOTX64.efi
mcopy -i ${t} ${e}/HelloWorld.efi ::/EFI/BOOT/loader.efi
dd if=${t} of=${o} bs=512 seek=2048 count=100000
rm -f ${t}
exit 0;