I successfully installed a dual-boot (Ubuntu 18.04 and win10) on my notebook.
Unfortunately I'm still new to the Linux world and my terminal skills and Linux knowledge are close to bad. But I'm willing to learn.
My concern: Every time my machine restarts or I want to switch the OS I have to wait for the grub bootloader and then choose the OS. Normally I will not change my running OS for example if I worked in Ubuntu, I would like to boot back into it or the other way.
Now I want to write a little program that automatically changes the default boot entry to the other OS and then reboots the system.
I guess the problem is not writing this little script for Ubuntu. But how should I realize this for windows?
My To do list based on my knowledge.
- Somehow move the
/etc/default/grub
file to a small fat32 partition so windows is able to read it and make changes. ~probably easy - Run the
sudo update-grub
equivalent command in windows? ~this one is way beyond my knowledge and maybe totally stupid - like running an file.exe on Ubuntu.
I already searched for similar question but without finding a reasonable good solution for me.
- Some recommended to teach windows to read/write on the Ubuntu drive. I think that my precious Ubuntu drive should not be violated by windows.
- Or to install another bootloader. I would like to stay with GRUB, because its working and the default?
- Make changes to the
/boot/grub/grub.cfg
or/boot/grub/grubenv
I'm not 100% sure about it, but most users don't recommend messing with the grub.cfg file because its generated from other files?
I know that I can probably just use a function in GRUB to run the last booted OS as default. But when I want to switch from one OS to the other I like the idea of just running a little own program instead of waiting for the reboot then hitting a key before the timer runs out... and if you miss this opportunity - reboot again -
Thanks for your help
This will do almost what you want...
Making this change will allow you to choose which OS to boot, and it'll reboot to that same OS until you make a different selection.
Edit
/etc/default/grub
and change/add this:sudo -H gedit /etc/default/grub
# edit the fileGRUB_DEFAULT=saved
# change this lineGRUB_SAVEDEFAULT=true
# add this lineThen:
sudo update-grub
For those of us on other flavors of Ubuntu, gedit may not be available; no matter, just about any text editor will do, and @heynnema has it right otherwise...
Edit the file /etc/default/grub with your favorite editor under sudo
Now
sudo update-grub