NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.84k stars 13.92k forks source link

about iso \EFI\boot\grub.cfg #185543

Closed jcleng closed 1 year ago

jcleng commented 2 years ago

Describe the bug

\EFI\boot\grub.cfg There are syntax errors in the contents of the file, and it cannot be started. It needs to be manually modified every time. It has been a long long time, and no one has found it?

To Reproduce Steps to reproduce the behavior:

Expected behavior

Screenshots

vKgFiR.png Hydra Server:

milahu commented 2 years ago

the indent is wrong, but the curly braces are ok

grub.cfg is produced by nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix

with the ISO from https://nixos.org/download.html ...

wget https://channels.nixos.org/nixos-22.05/latest-nixos-minimal-x86_64-linux.iso

mkdir mnt

sudo mount -o loop nixos-*.iso mnt

grub-script-check mnt/EFI/boot/grub.cfg && echo ok
ok

nixos-minimal-22.05.2818.b82ccafb541-x86_64-linux_EFI_boot_grub.cfg.txt

jcleng commented 2 years ago

the indent is wrong, but the curly braces are ok

grub.cfg is produced by nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix

with the ISO from https://nixos.org/download.html ...

wget https://channels.nixos.org/nixos-22.05/latest-nixos-minimal-x86_64-linux.iso

mkdir mnt

sudo mount -o loop nixos-*.iso mnt

grub-script-check mnt/EFI/boot/grub.cfg && echo ok
ok

nixos-minimal-22.05.2818.b82ccafb541-x86_64-linux_EFI_boot_grub.cfg.txt

If I boot in legy mode, I have no problem. If I boot in uEFI mode, then can't boot. Could this be a compatibility problem

milahu commented 2 years ago

cannot reproduce in qemu + uefi bios

wget https://channels.nixos.org/nixos-22.05/latest-nixos-minimal-x86_64-linux.iso

nix-shell -p qemu OVMF.fd
this path will be fetched (0.91 MiB download, 8.00 MiB unpacked):
  /nix/store/ksch3xpsb8cs5x143zml99gafd8fnl26-OVMF-202202-fd
copying path '/nix/store/ksch3xpsb8cs5x143zml99gafd8fnl26-OVMF-202202-fd' from 'https://cache.nixos.org'...

qemu-system-x86_64 -bios /nix/store/ksch3xpsb8cs5x143zml99gafd8fnl26-OVMF-202202-fd/FV/OVMF.fd -cdrom nixos-*.iso -m 512

If I boot in uEFI mode, then can't boot.

whats your error?

It needs to be manually modified every time.

how do you fix grub.cfg?

jcleng commented 2 years ago

cannot reproduce in qemu + uefi bios

wget https://channels.nixos.org/nixos-22.05/latest-nixos-minimal-x86_64-linux.iso

nix-shell -p qemu OVMF.fd
this path will be fetched (0.91 MiB download, 8.00 MiB unpacked):
  /nix/store/ksch3xpsb8cs5x143zml99gafd8fnl26-OVMF-202202-fd
copying path '/nix/store/ksch3xpsb8cs5x143zml99gafd8fnl26-OVMF-202202-fd' from 'https://cache.nixos.org'...

qemu-system-x86_64 -bios /nix/store/ksch3xpsb8cs5x143zml99gafd8fnl26-OVMF-202202-fd/FV/OVMF.fd -cdrom nixos-*.iso -m 512

If I boot in uEFI mode, then can't boot.

whats your error?

It needs to be manually modified every time.

how do you fix grub.cfg?

delete more code

set with_fonts=false
set textmode=false
# If you want to use serial for "terminal_*" commands, you need to set one up:
#   Example manual configuration:
#    → serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
# This uses the defaults, and makes the serial terminal available.
set with_serial=no
if serial; then set with_serial=yes ;fi
export with_serial
clear
set timeout=10

# This message will only be viewable when "gfxterm" is not used.
echo ""
echo "Loading graphical boot menu..."
echo ""
echo "Press 't' to use the text boot menu on this console..."
echo ""

#
# Menu configuration
#

# Search using a "marker file"
search --set=root --file /EFI/nixos-installer-image

insmod gfxterm
insmod png
set gfxpayload=keep
set gfxmode=1920x1080,1366x768,1280x720,1024x768,800x600,auto

# Fonts can be loaded?
# (This font is assumed to always be provided as a fallback by NixOS)
if loadfont ($root)/EFI/boot/unicode.pf2; then
  set with_fonts=true
fi
if [ "$textmode" != "true" -a "$with_fonts" == "true" ]; then
  # Use graphical term, it can be either with background image or a theme.
  # input is "console", while output is "gfxterm".
  # This enables "serial" input and output only when possible.
  # Otherwise the failure mode is to not even enable gfxterm.
  if test "$with_serial" == "yes"; then
    terminal_output gfxterm serial
    terminal_input  console serial
  else
    terminal_output gfxterm
    terminal_input  console
  fi
else
  # Sets colors for the non-graphical term.
  set menu_color_normal=cyan/blue
  set menu_color_highlight=white/blue
fi

# Sets theme.
set theme=($root)/EFI/boot/grub-theme/theme.txt
# Load theme fonts
loadfont ($root)/EFI/boot/grub-theme/dejavu.pf2

hiddenentry 'Text mode' --hotkey 't' {
  loadfont ($root)/EFI/boot/unicode.pf2
  set textmode=true
  terminal_output gfxterm console
}
hiddenentry 'GUI mode' --hotkey 'g' {
  loadfont ($root)/EFI/boot/grub-theme/dejavu.pf2
  set textmode=false
  terminal_output gfxterm
}

# If the parameter iso_path is set, append the findiso parameter to the kernel
# line. We need this to allow the nixos iso to be booted from grub directly.
if [ ${iso_path} ] ; then
  set isoboot="findiso=${iso_path}"
fi

#
# Menu entries
#

menuentry 'NixOS 21.11.336001.a03ae0e6d07 Installer '  --class installer {
  linux /boot/bzImage ${isoboot} init=/nix/store/ahdhqjkwwvzmc8cn620d91sdcd6qb6q9-nixos-system-nixos-21.11.336001.a03ae0e6d07/init  root=LABEL=nixos-minimal-21.11-x86_64 boot.shell_on_fail loglevel=4
  initrd /boot/initrd
}
menuentry 'NixOS 21.11.336001.a03ae0e6d07 Installer (nomodeset)'  --class nomodeset {
  linux /boot/bzImage ${isoboot} init=/nix/store/ahdhqjkwwvzmc8cn620d91sdcd6qb6q9-nixos-system-nixos-21.11.336001.a03ae0e6d07/init  root=LABEL=nixos-minimal-21.11-x86_64 boot.shell_on_fail loglevel=4 nomodeset
  initrd /boot/initrd
}
menuentry 'NixOS 21.11.336001.a03ae0e6d07 Installer (copytoram)'  --class copytoram {
  linux /boot/bzImage ${isoboot} init=/nix/store/ahdhqjkwwvzmc8cn620d91sdcd6qb6q9-nixos-system-nixos-21.11.336001.a03ae0e6d07/init  root=LABEL=nixos-minimal-21.11-x86_64 boot.shell_on_fail loglevel=4 copytoram
  initrd /boot/initrd
}
menuentry 'NixOS 21.11.336001.a03ae0e6d07 Installer (debug)'  --class debug {
  linux /boot/bzImage ${isoboot} init=/nix/store/ahdhqjkwwvzmc8cn620d91sdcd6qb6q9-nixos-system-nixos-21.11.336001.a03ae0e6d07/init  root=LABEL=nixos-minimal-21.11-x86_64 boot.shell_on_fail loglevel=4 debug
  initrd /boot/initrd
}

# Search using a "marker file"
search --set=root --file /EFI/nixos-installer-image

insmod gfxterm
insmod png
set gfxpayload=keep
set gfxmode=1920x1080,1366x768,1280x720,1024x768,800x600,auto

# Fonts can be loaded?
# (This font is assumed to always be provided as a fallback by NixOS)
if loadfont ($root)/EFI/boot/unicode.pf2; then
  set with_fonts=true
fi
if [ "$textmode" != "true" -a "$with_fonts" == "true" ]; then
  # Use graphical term, it can be either with background image or a theme.
  # input is "console", while output is "gfxterm".
  # This enables "serial" input and output only when possible.
  # Otherwise the failure mode is to not even enable gfxterm.
  if test "$with_serial" == "yes"; then
    terminal_output gfxterm serial
    terminal_input  console serial
  else
    terminal_output gfxterm
    terminal_input  console
  fi
else
  # Sets colors for the non-graphical term.
  set menu_color_normal=cyan/blue
  set menu_color_highlight=white/blue
fi

menuentry 'Shutdown' --class shutdown {
  halt
}
jcleng commented 2 years ago

cannot reproduce in qemu + uefi bios

wget https://channels.nixos.org/nixos-22.05/latest-nixos-minimal-x86_64-linux.iso

nix-shell -p qemu OVMF.fd
this path will be fetched (0.91 MiB download, 8.00 MiB unpacked):
  /nix/store/ksch3xpsb8cs5x143zml99gafd8fnl26-OVMF-202202-fd
copying path '/nix/store/ksch3xpsb8cs5x143zml99gafd8fnl26-OVMF-202202-fd' from 'https://cache.nixos.org'...

qemu-system-x86_64 -bios /nix/store/ksch3xpsb8cs5x143zml99gafd8fnl26-OVMF-202202-fd/FV/OVMF.fd -cdrom nixos-*.iso -m 512

If I boot in uEFI mode, then can't boot.

whats your error?

It needs to be manually modified every time.

how do you fix grub.cfg?

but the latest version seems to fail, and only Legey mode works on the Livecd

ghost commented 1 year ago

LiveCD GRUB EFI boot works for me, as of NixOS 22.11.20230318.08ef7dc (Raccoon) .