Can I change the grub default choice from Windows?

Solution 1:

The default menu choice is (or can be) stored in the GRUB "environment block", a little 1024 byte file that lives in /boot/grub/grubenv by default. You could easily put that on a drive accessible from both Windows and Linux (e.g. a FAT or NTFS partition) and modify it accordingly. I've done this already one-way (Linux -> Windows) for my mother's laptop using a little script:

#! /bin/bash
sudo /usr/sbin/grub-set-default 0
nohup bash -c "sleep 15s && sudo /sbin/reboot" &
gnome-session-quit --no-prompt --logout

Also added the following to /etc/sudoers to make the necessary commands execute without prompting:

%adm ALL=(root) NOPASSWD: /usr/sbin/grub-set-default, /sbin/reboot

Alternatively, it looks like someone may already have done the heavy lifting:

http://de.mcbf.net/david/grubchoosedefault/

Haven't tried this yet though ..

Solution 2:

About 20 years ago my OS/2 did that. Knowing a bit more about boot processes, I do not know exactly how it did that. It may have had boot loaders in PBR - partition boot sector and just moved boot flag. Or it may have just dd'd the boot sector/MBR with a different version. Those might work now.

But it might be easier just to install grub2 to a separate NTFS grub2 only boot partition. Then you can edit grub.cfg directly from both Windows and Linux. While you could edit the grub.cfg, I might just make 3 grub configs, working, Windows boot & Linux boot. And just have scripts to copy either Windows boot or Linux boot to the working copy. Then no update grub required.

On one of my flash drives that I originally created as a Windows 7 repair flash drive, I over-installed grub2 so from same flash drive I could directly boot other Linux repair ISO via loopmount. The only issue with grub installed in Windows is making sure you do not create /Boot & /boot as then you have major issues. I had /BCD & /grub in one /Boot folder. So you might not even have to have a separate grub only partition, but have to be careful not to damage Windows.