vote up 4 vote down star

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.


EDIT: 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:


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.

flag

75% accept rate
I'd like to further clarify that I'm looking for someone who has actually tested these questions and similar one empirically. But, failing that, feel free to speculate. If no one has any real test results, I'll accept the most plausible speculation after a while. – Ryan Thompson Sep 11 at 20:13
Well, I'm going to try to test some of these ideas soon. If I end up with a machine that still boots, I'll come back and accept an answer. ;) – Ryan Thompson Sep 13 at 19:52

5 Answers

vote up 1 vote down check

There is nothing wrong with what you mentioned. Even if you mounted the hibernated filesystem, the contents of the hibernation are saved to a large file on the disc - as long as you don't touch this file, or any important system files (obviously), then nothing will happen.

If you change the contents of a partition from another OS after you turn the system off, the original partition will still boot with no problems. It's the same thing in hibernation.

Just be sure that when mounting/unmounting the partition, you don't damage any system files or drive header information (e.g. MBR, file journals) - although this point has nothing to do with hibernation, and more just a common warning we all need to know.

link|flag
1  
Thought experiment: what if you have a document or file open in an app in Windows (eg you're editing a Word doc) then you hibernate and boot to the other OS. There's no active file lock any more so as far as Linux knows it can safely do anything with the file, so if you decide it's mis-filed and move it to a different directory Linux will let you. When you boot back to Windows what does Word do if its file has suddenly disappeared? Now think what would happen if this file was more vital than a Word doc? Read Only mounting is going to be an awful lot safer. – GAThrawn Sep 11 at 14:27
1  
This turns out to be the most accurate answer. You can, in fact mount and make modifications to the Windows C drive while Windows is hibernated, and it won't complain. I haven't tested this with Linux, but I suspect that it won't work. – Ryan Thompson Sep 14 at 8:21
@Ryan, you can but it is not 100% safe. NTFS might be broken far too easily. Another issue is that Linux and WIndows use NTFS slightly different so what is working with Windows might not work with Linux. These differences might end up in FS corruption, especially in such an edge case state of FS. – vava Sep 14 at 8:51
@GAThrawn - What does Word do? Try forcably editing a Word document under Windows and see what happens. Programs exist to remove file locks. @vava - As long as you are using a program/operating system which complies with the NTFS MFT and the Journal, it should be fine. – Breakthrough Sep 14 at 11:33
I know that it's not 100% safe, but the point is that if I accidentally mount the windows filesystem in linux after hibernating windows, the result is not instant and irrecoverable corruption. In other words, I would actually have to put in some effort if I wanted to shoot myself in the foot. – Ryan Thompson Sep 14 at 19:13
vote up 4 vote down

I regularly hibernate my Windows XP and boot over USB into Ubuntu.
Works flawlessly.

There is a difference between 'Standby' mode and 'Hibernate' mode.
The OS state is completely flushed to the disk and your hardware is powered off.
If you power up the machine and boot into some other OS, it has no impact on the hibernated OS.
You can keep as many OS'es hibernated as you want.

As an example,
You could have multiple Ubuntu installations (say, one per USB flash drive),
And, hibernate each, unplug the drive, and boot into another one.
There is no edge here because there is no stacking/chaining effect.
The hibernated USB sticks in this examples are all independent of each other
(across a power-cycled machine).

One small downside of a hibernated "C:\" drive and booting into another OS is,
you would not be able to mount the hibernated boot partition in the new OS.
The partition is locked with hibernation.
It will be corrupted if edited in that state.

link|flag
Actually you're wrong, in a good way! I tried hibernating Windows and booting into Ubuntu and mounting the windows filesystem, and it works, with no corruption when you resume Windows from hibernation! It surprised me. – Ryan Thompson Sep 14 at 7:48
vote up 4 vote down

I always hibernate Windows before booting in anything else, Windows is just too slow to start from scratch. But it is dangerous to write to the partition of hibernated OS, because some of the FS tables are still in memory (well, in hibernation file but not in the FS), applications still have handles to some files and generally file system state is kind of unstable.

But you can mount that partition read-only, this way it will stay exactly the same as before hibernation and Windows won't notice a thing.

As for a suggestion about mounting it normally and just stay away from system files, it is not a good idea. Relocation of a file content might happen, MFT might be changed, access time attributes will be changed, all those things might seriously corrupt a file system. It is not so dangerous with FAT but it is really really dangerous with NTFS, as it is far more complicated and have far more state in the memory.

link|flag
Are you sure that mounting read only is ok? My understanding is that with journaling filesystems, even a read-only mount will replay the journal and thus cause a change to the filesystem. On the other hand, the only Linux filesystem you can access from windows is ext2, which is non-jornaling, as is FAT, and Linux probably does a true read-only mount of NTFS, for historical reasons. So maybe it is safe. I any case, I'd like it if someone had concrete test results. – Ryan Thompson Sep 11 at 20:09
No, when FS is mounted read-only nothing got changed on it at all. This is why it is called read-only :) There's no need for a journal as it ensures that state of FS alway correct but when state does not change, it is not necessary, so journal is not used. And it works for me for quite a while now, so there's your testing results :) – vava Sep 12 at 2:18
"windows is too slow to start from scratch" Are you serious? I must be doing something wrong then, cause when my laptop hibernates, it adds around 2 minutes or more to my boot up time. – tehp Nov 11 at 20:19
I was talking about XP and yes, it is slow as hell considering how much it time it takes from boot to working applications. Ubuntu 9.04 was running circles around it. Ubuntu 9.10 is much slower for some reason. – vava Nov 12 at 3:31
vote up 1 vote down

I ran into problems with hibernate and multi-booting. Situation: Ubuntu and WinxP Multboot but the data partition visible for both OS. I did some testing... back and forth... So I was editing a Wordfile with Word... Saved the file and closed Word. Hibernated... started Ubuntu... edited the same file with OpenOffice... hibernated.

Rebbooted to the hibernated WinXP. Word did NOT 'see' the changes... It simply loooked like another file...

I also did this testing the other way around... Second time file was corrupted... I could not open the file or delete the file Chkdsk 'solved' the problem but the file was lost... In another test Ubuntu did not even see the edited file.

SO when using hibernation and the same partitions (does NOT need to be the partition where the OS boots from...) ist is very dangerous... Files can and will corrupt in my tests and I can repeat it... BTW: In my tests I ALWAYS saved the file and closed the application (Word and OpenOffice) befre going into hibernate...!! I thought mounting the partition was the culprit but now I think the problem must be something about file-caching or whatever... Anyhow: Be careful with multi-OS-hibernation...!! Regards, ArnoR

link|flag
vote up 0 vote down

I just don't think this is possible.

When you hibernate, the computer is 'locked in' (for lack of a better term) to that OS. You aren't hibernating the OS, you are hibernating the whole computer. When to resume from hibernation, you don't go through the BIOS and the POST time again.

link|flag
I'm not talking about suspend to RAM, I mean hibernation to disk. I'll edit the question to be more specific. – Ryan Thompson Sep 11 at 8:48
3  
Seems wrong to me. When you're hibernating, the computer is shut down. When you start it on again, it goes through the BIOS and POST. It's only when the OS loader sees that it has been hibernating that it will load the file containing the memory state (hiberfil.sys for Windows) and restore the OS. – snark Sep 11 at 8:48

Your Answer

Get an OpenID
or
never shown

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