grub-support/assets/build-image

44 lines
714 B
Plaintext
Raw Normal View History

2019-02-06 03:34:03 +00:00
#! /bin/bash
set -ex
out=/output/grub-intel.raw
if [ -e $out ]; then
rm $out
fi
# create the file
2024-04-25 18:04:11 +00:00
truncate -s144M $out
2019-02-06 03:34:03 +00:00
# partition it
sgdisk \
2024-04-25 18:04:11 +00:00
--new=0:4096:+128M --typecode=0:EF00 -c 0:boot \
--new=0:0:+2M --typecode=0:EF02 -c 0:BIOS-BOOT \
2019-02-06 04:11:58 +00:00
--hybrid=1:2 --print $out
2019-02-06 03:34:03 +00:00
dev=$(losetup --find --show --partscan $out)
trap "losetup -d $dev" EXIT
# format filesystems
mkfs.vfat -n BLKBOOT ${dev}p1
# mount
2024-04-25 18:04:11 +00:00
mkdir -p /boot
mount ${dev}p1 /boot
trap "umount /boot" EXIT
mkdir -p /boot/grub
cp /assets/grub.cfg /boot/grub
devmap=/boot/grub/device.map
cat >$devmap <<EOF
(hd0) $dev
EOF
2019-02-06 03:34:03 +00:00
2024-04-25 18:04:11 +00:00
grub-install --target=i386-pc $dev
grub-install --target=x86_64-efi --removable --efi-directory=/boot
2019-02-06 03:34:03 +00:00
2024-04-25 18:04:11 +00:00
rm $devmap