Hibernate with reboot on Linux

Written Tagged , and

For the occasional reboot to Windows, I found I was wasting a lot of time saving my work, closing my programs, rebooting, and then later reopening everything again. On the advice of Clarke Brunsdon, I started using suspend to disk AKA hibernate, which allowed me to switch to Windows, while saving my running programs and setup under Linux.

I then searched to remove the task of powering on the computer after it has suspended and then picking Windows from the Grub boot menu, which I often forgot to do.

Setting the selected operating system under grub is relatively straightforward using the grub-set-default command.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#/boot/grub/menu.lst

# change the default boot option to saved
default   saved

# (0) Linux
title  Linux
# ...
# add savedefault 0 to the end of each boot option, which sets the default back to Linux
savedefault 0

# (1) Windows
title  Linux
# ...
savedefault 0

The next step was automatically rebooting which was accomplished using the sparsely documented shutdown method = reboot option of s2disk

My final windows reboot script is

1
2
3
4
5
#!/bin/sh
sudo grub-set-default 2 # here '2' is whichever option is Windows
sudo s2disk -P 'shutdown method = reboot'

Which takes me from Linux to Windows, and back to my saved workspace on reboot.