Files
void-installer/installer/lib/grub.sh

57 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# GRUB UEFI install with dual-boot (Windows on /dev/nvme0n1p3 via os-prober).
# shellcheck source=common.sh
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
install_grub() {
step "Installing GRUB (UEFI, bootloader-id=$BOOTLOADER_ID)"
local TARGET="${TARGET:-/mnt}"
if ! is_uefi; then
die "non-UEFI boot detected; this installer only supports UEFI"
fi
# Configure /etc/default/grub
cat > "$TARGET/etc/default/grub" <<'GRUBEOF'
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Void"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=4 nvidia-drm.modeset=1"
GRUB_CMDLINE_LINUX=""
GRUB_DISABLE_OS_PROBER=false
GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_GFXMODE=auto
GRUBEOF
# Make sure os-prober can see the NTFS partitions to enumerate Windows.
run_chroot "modprobe efivarfs 2>/dev/null || true"
run_chroot "xbps-install -y os-prober ntfs-3g >/dev/null 2>&1 || true"
run_chroot "grub-install \
--target=x86_64-efi \
--efi-directory=/boot/efi \
--bootloader-id='$BOOTLOADER_ID' \
--recheck"
# Ensure os-prober actually runs (some hosts skip it without this).
mkdir -p "$TARGET/etc/grub.d"
# Generate config
run_chroot "grub-mkconfig -o /boot/grub/grub.cfg"
# Verify Windows entry was found (best-effort, non-fatal in test mode)
if grep -q -i 'windows\|microsoft' "$TARGET/boot/grub/grub.cfg"; then
ok "Windows boot entry detected in grub.cfg"
else
if [[ "${TEST_MODE:-0}" == "1" ]]; then
log "no Windows entry (expected in test mode)"
else
warn "no Windows entry in grub.cfg — os-prober may have failed; you can re-run grub-mkconfig later"
fi
fi
ok "GRUB installed"
}