I want to be able to choose what kernel or OS to boot in GRUB 2 boot menu. I have Windows on another HDD & I want hibernate
openSUSE, turn on PC & boot Windows. What I have found is file grub2.sleep in /usr/lib/systemd/system-sleep.
There is function called prepare-grub which sets what menu entry to boot after sleep, I have deleted code that calls prepare-grub,
but nothing changed.
#############################################################################
# if we did not find a kernel (or BOOT_LOADER is not GRUB) check,
# if the running kernel is still the one that will (probably) be booted for
# resume (default entry in menu.lst or, if there is none, the kernel file
# /boot/vmlinuz points to.)
# This will only work, if you use "original" SUSE kernels.
# you can always override with the config variable set to "yes"
prepare-grub()
{
echo "INFO: Running prepare-grub .."
check-system
get-kernels
RUNNING=`uname -r`
find-kernel-entry
if -z "$NEXT_BOOT" ]; then
# which kernel is booted with the default entry?
BOOTING="${KERNELS$DEFAULT_BOOT]}"
# if there is no default entry (no menu.lst?) we fall back to
# the default of /boot/vmlinuz.
-z "$BOOTING" ] && BOOTING="vmlinuz"
if IMAGE=`readlink /boot/$BOOTING` && -e "/boot/${IMAGE##*/}" ]; then
BOOTING=$IMAGE
fi
BOOTING="${BOOTING#*vmlinuz-}"
echo "running kernel: '$RUNNING', probably booting kernel: '$BOOTING'"
if "$BOOTING" != "$RUNNING" ]; then
error_quit "ERROR: kernel version mismatch, cannot suspend to disk"
fi
else
# set the bootloader to the running kernel
echo " preparing boot-loader: selecting entry $NEXT_BOOT, kernel /boot/$BOOTING"
T1=`date +"%s%N"`
sync; sync; sync # this is needed to speed up grub-once on reiserfs
T2=`date +"%s%N"`
echo " running $GRUB_ONCE \"${NEXT_BOOT}\""
${GRUB_ONCE} "$NEXT_BOOT"
T3=`date +"%s%N"`
S=$(((T2-T1)/100000000)); S="$((S/10)).${S:0-1}"
G=$(((T3-T2)/100000000)); G="$((G/10)).${G:0-1}"
echo " time needed for sync: $S seconds, time needed for grub: $G seconds."
fi
echo "INFO: Done."
}
###### main()
if "$1" = pre ] ; then
prepare-grub
fi
if "$1" = post ] ; then
grub-once-restore
fi