3

I have a dual boot system. My Ubuntu partition needs to boot automatically on BIOS scheduled wakeup (and wakeonlan if possible) Otherwise I want to boot into Windows by default. (power button)

How could one configure the system to boot into Ubuntu only after a BIOS wakeup or wakeonlan, while otherwise defaulting to Windows? Is it possible to configure or script grub to do this?

  • Instead of looking only at GRUB, you could also inspect your firmware settings. My ThinkPad notebook has a different boot priority list for when it’s turned on by WoL. – Daniel B Jan 10 '16 at 9:53
1
+50

Two (or three) different ways

Using network boot via PXE server.

I've used a trick like this for backup windows stations (with ntfsclone or partclone) while users are away, by night.

  1. Create a PXE boot server (dhcpd + tftpd) for booting via network ( You could create specific boot menu for each computer on a network or make group. The network boot menu could point to local hard drive. )

  2. Prepare two different boot menu on this server: one defaulting to ubuntu and the other defaulting to window.

  3. Link boot menu defaulting to window to be served by pxe server.

  4. Prepare a wakeup script for

    1. ) Link boot menu defaulting to ubuntu to be served by pxe server.
    2. ) Send wake-on-lan signal to wake the computer up
    3. ) Wait for boot menu request in TFTP logs (care about timeout and limits, for assuming exception).
    4. ) Link boot menu defaulting to window to be served by pxe server.
  5. You could even try to run same via crontab to be synchronized by BIOS wakup, but if in crontab, you could simply run script defined at 4..

This will do the job.

(Nota a pxe boot server is light and could be installed even on a raspberry pi, an hacked NAS or on a DD-WRT router, for sample.).

Using dmidecode info

You could use dmidecode to run grub-reboot windows when boot from power-switch.

Simply create a script containing something like:

/bin/sh
dmidecode  | grep -q 'Wake-up Type: Power Switch' && echo grub-reboot windows
reboot

You can run this script at each boot, by adding them in crontab with @reboot directive.

(Nota: for grub-reboot, you may have to edit /etc/default/grub. see man grub-reboot)

This will work but will increase windows boot time a lot!

For avoiding this, you could create a special initramdisk wich could do this job, but this is not as simple.

Using ipxe (maybe)

I don't know this tool, but I heard good feed-backs.

iPXE is the leading open source network boot firmware. It provides a full PXE implementation enhanced with additional features

  • 1
    Why did you downgrade this, this is a correct answer (used somewhere and working fine) – F. Hauri Jan 10 '16 at 8:45
  • This “solution” only boots Linux when it was previously hibernated. Nowhere does the OP indicate that this would be the case. – Daniel B Jan 10 '16 at 9:12
  • If someone could post comments about iPXE, they will be welcome! – F. Hauri Jan 21 '16 at 8:01
0

This has been asked a number of times over the years without a satisfactory answer:

It is known that an OS can detect the wake-up reason. It's seems reasonable that something like grub should be able to do the same, but this is currently not the case.

The only "solution" I've been able to find involves setting up grub for dual boot with Linux as default. Wake as usual. Login to computer (remotely or otherwise) and manually reboot into Windows with something like sudo grub-reboot Windows. Setup and use is described here.

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.