This is a weird question. I read how to set the default OS choice for GRUB (How do I set the grub timeout and the grub default boot entry?) and I did that, but since I often work from home, I'd like to switch from Windows 7 to Ubuntu 13 and from Ubuntu 13 to Windows 7 automatically by VNC.

I can edit manually the file /etc/default/grub, but I can't do the sudo update-grub from inside the Windows environment.

My question is: is there any way to do this from inside a Windows environment or to use a workaround to be able to change the default bootloader choice and boot into another operating system remotely ?

| improve this question | | | | |

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:


Haven't tried this yet though ..

| improve this answer | | | | |

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.

| improve this answer | | | | |
  • If I recall correctly, the OS/2 boot manager had its own partition. That way it wasn't limited to the code size restrictions imposed by the MBR. Basically, the MBR launched the OS/2 boot manager (on a partition), which then chainloaded the desired OS. It also set the hidden flag on the other OSes, that you didn't boot into. The OS/2 boot manager was awesome... – jawtheshark Sep 14 '16 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.