Is it possible to hibernate Ubuntu and run secondary OS?

Is it possible to:

  1. hibernate Ubuntu,
  2. run secondary OS (say Windows 7),
  3. shut down secondary OS,
  4. resume hibernated Ubuntu,

or not? Ubuntu should (AFAIK) hibernate to SWAP partition, which is not used by Windows. Would it work? If not, why?


Solution 1:

Absolutely it should work. I was doing that ages for gaming purposes as well, although now with the Steam-Linux revolution I haven't booted Windows up for months.

I had my OS partitions totally separate, as you intend to, and had no problems at all. There were no shared partitions. My swap partition is 36 GB, slightly more than twice my RAM (16 GB).

The only problem is that hibernate is slightly unstable on Linux sometimes. Probably 20% of the time, it would crash when hibernating or resuming. (This was a year ago, so things might have changed, or be different on your system. After I bought an SDD, and startup time were reduced greatly, I just restarted instead of hibernating.)

I even have a script that might be useful. You might need to change the name and location of the Windows partition.

#!/usr/bin/env bash
# hibernate and restart in Windows for only the next time.
# requires /etc/default/grub has "GRUB_DEFAULT=saved"

# get the correct name from /boot/grub/grub.cfg
sudo grub-reboot "Windows 7 (loader) (on /dev/sdb2)"

# or use the number, i.e.
# WINDOWS_ENTRY=`grep menuentry /boot/grub/grub.cfg  | grep --line-number Windows`
# MENU_NUMBER=$(( `echo $WINDOWS_ENTRY | sed -e "s/:.*//"` - 1 ))
# sudo grub-reboot $MENU_NUMBER

sudo dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Hibernate

# if this fails, you can try ---> sudo pm-hibernate