forked from AsahiLinux/asahi-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-grub
More file actions
executable file
·43 lines (33 loc) · 992 Bytes
/
update-grub
File metadata and controls
executable file
·43 lines (33 loc) · 992 Bytes
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
38
39
40
41
42
43
#!/bin/sh
# SPDX-License-Identifier: MIT
set -e
BOOT_PART="/boot"
EFI_PART="/boot/efi"
GRUB_DIR="$BOOT_PART/grub"
CONFIG="/boot/grub/grub.cfg"
TARGET="$EFI_PART/EFI/BOOT/BOOTX86_64.EFI"
MODULES="ext2 part_gpt search"
[ -e /etc/default/update-grub ] && source /etc/default/update-grub
uuid="$(grub-probe "$BOOT_PART" -t fs_uuid)"
part="$(grub-probe "$BOOT_PART" -t drive | sed -e 's/(.*,/hd0,/' | tr -d ')')"
if [ -z "$uuid" ]; then
echo "Error: Unable to determine root filesystem UUID"
exit 1
fi
echo "UUID: $uuid"
echo "Partition: $part"
cat > /tmp/grub-core.cfg <<EOF
search.fs_uuid $uuid root $part
set prefix=(\$root)'/boot/grub'
EOF
echo "Generating GRUB image..."
grub-mkimage \
--directory '/usr/lib/grub/arm64-efi' \
-c /tmp/grub-core.cfg \
--prefix "$part/boot/grub" \
--output "$GRUB_DIR"/X86_64-efi/core.efi \
--format X86_64-efi \
--compression auto \
$MODULES
cp "$GRUB_DIR"/X86_64-efi/core.efi "$TARGET"
grub-mkconfig -o "$CONFIG"