beli0135 wrote:I know I have seen a grub command for direct entry, just forgot where and which. I also know it works like a flag (probably with file which is deleted automaticly)
You are probably thinking of the Grub Legacy command grubonce:
- Code: Select all
grubonce <n>
Its Grub2 equivalent is grub-reboot:
- Code: Select all
grub-reboot <n>
In that case the quick-and-dirty example script would be:
- Code: Select all
#!/bin/bash
select CHOICE in Sabayon Sabayon_Safe_Mode Windows_Recovery Windows Shutdown Cancel
do
case "$CHOICE" in
"Sabayon")
echo "Rebooting to Sabayon"
sudo /sbin/grub-reboot 0
sudo shutdown -r now
;;
"Sabayon_Safe_Mode")
echo "Rebooting to Sabayon Safe Mode"
sudo /sbin/grub-reboot 1
sudo shutdown -r now
;;
"Windows_Recovery")
echo "Rebooting to Windows 7 Factory Restore Partition"
sudo /sbin/grub-reboot 2
sudo shutdown -r now
;;
"Windows")
echo "Rebooting to Windows 7"
sudo /sbin/grub-reboot 3
sudo shutdown -r now
;;
"Shutdown")
echo "Shutting down"
sudo shutdown -h now
;;
"Cancel")
echo "Cancel"
exit
;;
esac
done
Unlike grubonce, grub-reboot does not display the list of OSs if run without a parameter. However the Grub2 developer Colin Watson made grub-reboot accept an OS name to make it easier: grub-reboot needs to display name of operating system that will be booted.

