Hibernating and booting into another OS: will the filesystems be corrupted



If you came here looking for an answer to this question, please read all the answers below. There are some testimonials from people who have lost data doing this. If you plan to do this regularly, I highly recommend that you test for yourself.

Original Question

Suppose I have Windows and Linux installed on the same computer. If I hibernate Windows, can I boot into Linux without corrupting the Windows filesystem when I resume Windows? What about the other way around? What if I hibernate one, boot into the other, and mount the hibernated filesystem read/write? Read-only? If this is unsafe, is there any way to detect the hibernated state of the other OS and prevent mounting its filesystem?

Basically, how far can I push this before it breaks, and how dangerous is it near the edge? I think I know the answers to some of the above questions, but for other ones, I have no idea, and for obvious reasons I have not tested this on my own computer. If someone has tested these, please enlighten the rest of us. I'm not necessarily looking for a specific answer to every question; I'll accept any response that answers a reasonable portion.


Let me clarify that when I say "hibernate," I mean the process of writing the contents of RAM to the hard disk and completely powering down the computer. In this state, powering the computer back on brings you through the BIOS and bootloader again, and you could theoretically select another operating system on a multi-boot system. Anyway, on with the original question:

My Results

Ok, after everyone's assurances that this would work, I tested it for myself. I set up Ubuntu to remount all ntfs filesystems and external drives read-only before hibernating. There was no need for a similar Windows setup because Windows does not read Linux filesystems. Then, I tried alternately hibernating one operating system and resuming the other, back and forth a few times. I even tried mounting the Windows filesystem from Ubuntu read-write, and creating a few files. Windows didn't complain when I resumed. So, in conclusion, you can more or less freely hibernate in a dual-boot Windows/Linux scenario.

Note that I did not test a dual Linux/Linux co-hibernation situation. If you have two or more Linux installs and you hibernate one of them, you might be able to corrupt the filesystem by mounting it from another.

Best Answer

Booting Windows over an hibernated Linux is not a good idea. I just lost 20 GiB of data in a shared NTFS partition...

I hibernated Ubuntu Lucid one day, and the next I fired up my computer. Some update messed up the saved option in Grub, so instead of booting Ubuntu again as it should, it started Windows 7. When I came back with my coffee, I just went on using it without recalling Ubuntu was in bear mode. I probably accessed music, Firefox profile, documents, downloads and games from the shared partition.

The next time I switched to Ubuntu, I saw the "waking up from hibernation" message. Dang. But I expected it to fail at waking, and soft reboot instead, as happened the previous time I "tried" this (in my Karmic times). But no, it woke up alright. Cool. Or not. I quickly realized a directory in the root of the shared partition was now empty. I think the only programs accessing the shared partition on resuming were Quod Libet (music player) and Transmission (bittorrent client).

I went back to Windows, where I couldn't even open the directory. Trying to "dir" it in shell produced "file not found". Corrupted. Still, the partition's free space had not increased, so my 20 GiB where probably still there, safe from being overwritten. Maybe. But how to get to them?

A little research provided little help, and made my hopes even more bleak.

I ran Scandisk ("Check for Errors") without auto repair, since I don't wanted to risk it fixing things by further destroying my data. The result was not very informative: "Errors found. Run with auto repair." Unknown to me, seemingly it also marked the partition to be automatically checked on next boot. I powered off and went away, and came back with EasyRecovery later.

The computer started with me not paying attention, as usual, and when I looked, chkdsk was already spewing errors in full swing, which it did for some ten minutes. Oh well, here goes nothing.

Fortunately I did lit a candle for Santa Tecla recently, and after Windows started, my data was back, all of it as far as I can tell, though some files ended up in found.000.

So yes, this had a happy ending. You'll forgive the dramatic suspense, but that's to drive a point across: backup your data! And (in my case) keep the backup up to date! And of course, be extra careful with hibernation and shared partitions...