Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

This has been asked but nobody answered (Change Grub Default From Windows)

share|improve this question
up vote 2 down vote accepted

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 ..

share|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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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