summaryrefslogtreecommitdiff
path: root/mkefipart-fat
blob: 25e282836d7231ee0124ea8421b7bad690fbead9 (plain)
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
#! /bin/sh
# mkefipart-fat - written by Andreas Loibl <andreas@andreas-loibl.de>
# 
# Generate an image for a FAT-EFI-partition

if [ ! -x /usr/bin/mmd ]; then
	echo "Error: mtools are needed! Run: apt-get install mtools"
	exit 1
fi

img=efi-fat.img
[ "$1" ] && img="$1"
rm -f "$img"

# Stuff boot*.efi into a FAT filesystem, making it as small as possible.  24KiB
# headroom seems to be enough; (x+31)/32*32 rounds up to multiple of 32.
mkfs.msdos -n KANOTIX_EFI -C "$img" \
	$(( ($(stat -c %s binary/efi/boot/boot*.efi | awk '{s+=$1} END {print s}') / 1024 + 1023) \
	    / 1024 * 1024 ))
mmd -i "$img" ::efi
mmd -i "$img" ::efi/boot
for file in binary/efi/boot/boot*.efi
do
	mcopy -i "$img" $file "::efi/boot/$(basename "$file")"
done

exit 0