You are not logged in.

#1 2012-09-02 20:35:46

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

[SOLVED] Minimal grub2 config

Hello.

I'm using grub2 to boot in UEFI mode and I think it's kinda slow. It takes it almost three seconds from 'Wellcome to grub' or something similar to 'Loading kernel'. My config file is a real mess, so can anybody help me clean it up? I have no idea if I need all those modules, conditions and search strings.

## /boot/EFI/EFI/grub/grub.cfg
set default="0"
set timeout=1
terminal_input console
terminal_output gfxterm
font="/usr/share/grub/unicode.pf2"

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=
  insmod gettext
fi

menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-e792525c-8505-494e-bf8a-731f6fb5dd48' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	set root='hd0,gpt2'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  e792525c-8505-494e-bf8a-731f6fb5dd48
	else
	  search --no-floppy --fs-uuid --set=root e792525c-8505-494e-bf8a-731f6fb5dd48
	fi
	echo	'Loading kernel'
	linux	/boot/vmlinuz-linux root=UUID=e792525c-8505-494e-bf8a-731f6fb5dd48 ro add_efi_memmap init=/usr/sbin/e4rat-preload-lite
	echo	'Loading ramdisk'
	initrd	/boot/initramfs-linux.img
}
menuentry 'Arch Linux Fallback' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-fallback-e792525c-8505-494e-bf8a-731f6fb5dd48' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	set root='hd0,gpt2'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  e792525c-8505-494e-bf8a-731f6fb5dd48
	else
	  search --no-floppy --fs-uuid --set=root e792525c-8505-494e-bf8a-731f6fb5dd48
	fi
	echo	'Loading kernel'
	linux	/boot/vmlinuz-linux root=UUID=e792525c-8505-494e-bf8a-731f6fb5dd48 ro add_efi_memmap systemd.unit=multi-user.target
	echo	'Loading initial ramdisk'
	initrd	/boot/initramfs-linux-fallback.img
}
menuentry "Microsoft Windows Server R2" {
    insmod part_gpt
    insmod fat
    insmod search_fs_uuid
    insmod chain
    search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 A981-D50F
    chainloader /efi/Microsoft/Boot/bootmgfw.efi
}

Thanks in advance.

Last edited by Šaran (2012-09-09 17:09:11)

Offline

#2 2012-09-02 20:38:25

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Minimal grub2 config

I know this is not a solution to your grub issue, but I have just succeeded in setting up my system to boot from the efi stub loader (in the kernel itself) rather than go through a traditional bootloader.  So it skips the whole "loading grub" crap, and just goes straight to boot.

Offline

#3 2012-09-02 20:43:08

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

Re: [SOLVED] Minimal grub2 config

My laptop's crappy UEFI will only load /EFI_PARTITION/shellx64.efi. It gives me pretty blank screen when trying to load anything else. I need to dualboot, so efi stub is not really an option.

Offline

#4 2012-09-03 00:41:24

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Minimal grub2 config

You know I had an issue as well that made entering my own efibootmgr entries a real PITA.  What I had to do to use the stub loader was put the *.efi in the root of the partition.  Now all works as it should, though doing an 'ls' from the shell in fs0: is ugly... but it works!

Offline

#5 2012-09-05 07:24:45

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

Re: [SOLVED] Minimal grub2 config

You just made my day!  smile
I realised it will load anything as long it is on efi partition root.

In the meantime, can anybody take a look at my grub cfg in case efi stub approach doesn't work out?

Offline

#6 2012-09-09 17:08:40

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

Re: [SOLVED] Minimal grub2 config

Unfortunately, I couldn't get EFI STUB or rEFInd working - thank you Asus.

As far as Grub goes, here is what I have come up with after a lot of trial and error:

set default=0
set timeout=1

insmod efi_gop
insmod efi_uga
insmod font

if loadfont ${prefix}/fonts/unicode.pf2
then
    insmod gfxterm
    set gfxmode=auto
    set gfxpayload=keep
    terminal_output console
fi

menuentry "Arch Linux" {
	set root=(hd0,2)
	linux	/boot/vmlinuz-linux root=UUID=e792525c-8505-494e-bf8a-731f6fb5dd48 ro add_efi_memmap init=/usr/sbin/e4rat-preload-lite
	initrd	/boot/initramfs-linux.img
}
menuentry "Arch Linux E4R Collect" {
	set root=(hd0,2)
	linux	/boot/vmlinuz-linux root=UUID=e792525c-8505-494e-bf8a-731f6fb5dd48 ro add_efi_memmap init=/sbin/e4rat-collect
	initrd	/boot/initramfs-linux.img
}
menuentry "Arch Linux Fallback" {
	set root=(hd0,2)
	linux	/boot/vmlinuz-linux root=UUID=e792525c-8505-494e-bf8a-731f6fb5dd48 ro add_efi_memmap systemd.unit=multi-user.target
	initrd	/boot/initramfs-linux-fallback.img
}
menuentry "Arch Linux ISO" {
	set isofile="/boot/archlinux-2012.09.07-dual.iso"
	loopback loop (hd0,2)$isofile
	linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201209 img_dev=/dev/sda2 img_loop=$isofile earlymodules=loop
	initrd (loop)/arch/boot/x86_64/archiso.img
}
menuentry "Windows Server R2" {
    chainloader /efi/Microsoft/Boot/bootmgfw.efi
}

Offline

#7 2012-09-11 13:45:39

the.ridikulus.rat
Member
From: Indiana, USA
Registered: 2011-10-04
Posts: 765

Re: [SOLVED] Minimal grub2 config

@Šaran: If you want any ideas, here is my grub.cfg :

set _kernel_params="i915.modeset=1 gpt loglevel=6 printk.time=y pcie_aspm=force elevator=noop"
set _rootfstype="ext4"

## Linux Kernel Video Mode 1024x768x32, vga=824
set _video_mode="824"

insmod part_gpt
insmod part_msdos
insmod fat
insmod ext2

set _hdd_disk_gpt_guid="949f0136-382a-4f68-9dc6-8326e1d3d593"

set _root_part_fs_uuid="ad4103fa-d940-47ca-8506-301d8071d467"

set _boot_part_fs_uuid="ad4103fa-d940-47ca-8506-301d8071d467"

set _uefisys_part_fs_uuid="1BF5-7E28"

search --fs-uuid --no-floppy --set=_arch64_boot --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5 "${_boot_part_fs_uuid}"
search --fs-uuid --no-floppy --set=_arch64_root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5 "${_root_part_fs_uuid}"
search --fs-uuid --no-floppy --set=_uefisys_part --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 "${_uefisys_part_fs_uuid}"

if [ "${grub_platform}" == "efi" ]; then
	set _UEFI_ARCH="${grub_cpu}"
	
	if [ "${grub_cpu}" == "x86_64" ]; then
		set _SPEC_UEFI_ARCH="x64"
	fi
	
	if [ "${grub_cpu}" == "i386" ]; then
		set _SPEC_UEFI_ARCH="ia32"
	fi
fi

if [ "${grub_platform}" == "efi" ]; then
	set _kernel_params="${_kernel_params} add_efi_memmap"
fi

if [ "${grub_platform}" == "efi" ]; then
	insmod efi_gop
	insmod efi_uga
	# insmod video_bochs
	# insmod video_cirrus
fi

if [ "${grub_platform}" == "pc" ]; then
	insmod vbe
	insmod vga
	# insmod video_bochs
	# insmod video_cirrus
fi

if [ -e "(${_arch64_root})/usr/share/grub/unicode.pf2" ]; then
	_fontfile="(${_arch64_root})/usr/share/grub/unicode.pf2"
else
     if [ -e "(${_arch64_boot})/boot/grub/fonts/unicode.pf2" ]; then
	_fontfile="(${_arch64_boot})/boot/grub/fonts/unicode.pf2"
    fi
fi

insmod font

if loadfont "${_fontfile}" ; then
	insmod gfxterm
	
	set gfxmode="1024x768x32;auto"
	
	terminal_input console
	terminal_output gfxterm
	
	# set color_normal=light-blue/black
	# set color_highlight=light-cyan/blue
	
	# insmod png
	# insmod jpeg
	# insmod gfxmenu
	
	# background_image "(${_arch64_boot})/boot/images/archlinux.png"
	
	set locale_dir="${prefix}/locale"
	set lang="en_US"
	
	# insmod gettext
fi

if [ "${grub_platform}" == "efi" ]; then
	set default="Arch Linux Testing Kernel"
	
	set _hidden_timeout="5"
fi

if [ "${grub_platform}" == "pc" ]; then
	set default="Arch Linux Testing Kernel"
	
	set _hidden_timeout="5"
fi

if sleep --verbose --interruptible "${_hidden_timeout}" ; then
	set timeout="0"
fi

set pager="1"
# set debug="all"

menuentry "Arch Linux Testing Kernel" {
	set gfxpayload="keep"
	set root="${_arch64_boot}"
	linux /boot/vmlinuz-linux root=UUID=${_root_part_fs_uuid} ro rootfstype=${_rootfstype} ${_kernel_params} systemd.unit=graphical.target
	initrd /boot/initramfs-linux.img
}

menuentry "Arch Linux Testing Kernel Fallback" {
	set gfxpayload="keep"
	set root="${_arch64_boot}"
	linux /boot/vmlinuz-linux root=UUID=${_root_part_fs_uuid} ro rootfstype=${_rootfstype} ${_kernel_params} systemd.unit=graphical.target
	initrd /boot/initramfs-linux-fallback.img
}

menuentry "Arch Linux Mainline Kernel" {
	set gfxpayload="keep"
	set root="${_arch64_boot}"
	linux /boot/vmlinuz-linux-mainline root=UUID=${_root_part_fs_uuid} ro rootfstype=${_rootfstype} ${_kernel_params} systemd.unit=graphical.target
	initrd /boot/initramfs-linux-mainline.img
}

menuentry "Arch Linux Mainline Kernel Fallback" {
	set gfxpayload="keep"
	set root="${_arch64_boot}"
	linux /boot/vmlinuz-linux-mainline root=UUID=${_root_part_fs_uuid} ro rootfstype=${_rootfstype} ${_kernel_params} systemd.unit=graphical.target
	initrd /boot/initramfs-linux-mainline-fallback.img
}

if [ "${grub_platform}" == "pc" ]; then
	
	menuentry "Microsoft Windows x86_64 BIOS-MBR" {
		search --fs-uuid --no-floppy --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 FA668086668044FB
		ntldr /bootmgr
	}
	
fi

if [ "${grub_platform}" == "efi" ]; then
	
	menuentry "UEFI ${_UEFI_ARCH} Shell 2.0" {
		set root="${_uefisys_part}"
		chainloader /EFI/tools/shell${_SPEC_UEFI_ARCH}.efi
	}
	
	menuentry "UEFI ${_UEFI_ARCH} Shell 1.0" {
		set root="${_uefisys_part}"
		chainloader /EFI/tools/shell${_SPEC_UEFI_ARCH}_old.efi
	}
	
	menuentry "Microsoft Windows x86_64 UEFI-GPT" {
		set root="${_uefisys_part}"
		chainloader /EFI/Microsoft/Boot/bootmgfw.efi
	}
	
fi

Offline

#8 2012-09-11 15:01:00

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

Re: [SOLVED] Minimal grub2 config

Thanks!

Offline

Board footer

Powered by FluxBB