grub.cfg for ich7 targets - librecore-org/librecore GitHub Wiki

# grub.cfg location
set prefix=(memdisk)/boot/grub

# Enable drivers
insmod nativedisk
insmod ehci
insmod ohci
insmod uhci
insmod usb

# Disable AT keyboard to avoid input lag
rmmod at_keyboard

# Serial configuration
serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
terminal_input --append serial
terminal_output --append cbmemc
terminal_output --append serial

# Use native graphics
gfxpayload=keep
terminal_output --append gfxterm

# Default to first option, automatically boot after 1 second
set default="0"
set timeout=1

# Enable pager, so long lines will be wrapped
set pager=1

# Set font and background
loadfont (memdisk)/dejavusansmono.pf2
insmod jpeg
insmod png
background_image (cbfsdisk)/background.jpg

menuentry 'Load Operating System [o]' --hotkey='o' {
	insmod regexp
	insmod ata
	insmod part_msdos
	insmod part_gpt
	for x in (ata*); do
		if [ -f "$x/grub/grub.cfg" ] ; then
			set root=$x
			configfile /grub/grub.cfg
		fi
		if [ -f "$x/boot/grub/grub.cfg" ] ; then
			set root=$x
			configfile /boot/grub/grub.cfg
		fi
	done

# Fallback mode when SATA0 is ata0
	set root='ata0,1'
	linux  /vmlinuz root=/dev/sda1 rw
	if [ -f "/initrd.img" ] ; then
		initrd /initrd.img
	fi

# Fallback mode when SATA0 is ata4
	set root='ata4,1'
	linux  /vmlinuz root=/dev/sda1 rw
	if [ -f "/initrd.img" ] ; then
		initrd /initrd.img
	fi
}

menuentry 'Parse ISOLINUX menu (USB) [u]' --hotkey='u' {
	insmod regexp
	insmod usbms
	insmod part_msdos
	insmod part_gpt
	for x in (usb*); do
		set root=$x
		if [ -f "/isolinux/isolinux.cfg" ] ; then
			syslinux_configfile -i /isolinux/isolinux.cfg
		elif [ -f "/menu.cfg" ] ; then
			syslinux_configfile -i /menu.cfg
		elif [ -f "/txt.cfg" ] ; then
			syslinux_configfile -i /txt.cfg
		fi
	done
}

menuentry 'Parse ISOLINUX menu (ATA) [a]' --hotkey='a' {
	insmod regexp
	insmod ata
	insmod iso9660
	for x in (ata*); do
		set root=$x
		if [ -f "/isolinux/isolinux.cfg" ] ; then
			syslinux_configfile -i /isolinux/isolinux.cfg
		elif [ -f "/menu.cfg" ] ; then
			syslinux_configfile -i /menu.cfg
		elif [ -f "/txt.cfg" ] ; then
			syslinux_configfile -i /txt.cfg
		fi
	done
}

menuentry 'Search for GRUB configuration files [s]' --hotkey='s' {
	insmod regexp
	insmod usbms
	insmod ata
	insmod part_msdos
	insmod part_gpt
	insmod iso9660
	for x in (usb*) (ata*); do
		if [ -f "$x/grub/grub.cfg" ] ; then
			submenu "Load Config from $x" $x { 
				root=$2
				source /grub/grub.cfg
				unset superusers
			}
		fi
		if [ -f "$x/boot/grub/grub.cfg" ] ; then
			submenu "Load Config from $x" $x {
				root=$2
				source /boot/grub/grub.cfg
				unset superusers
			}
		fi
	done
}

menuentry 'Poweroff  [p]' --hotkey='p' {
	halt
}

menuentry 'Reboot  [r]' --hotkey='r' {
	reboot
}