59

IMPORTANT

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.


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:


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.

7
  • 1
    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. Sep 11, 2009 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. ;) Sep 13, 2009 at 19:52
  • related: superuser.com/questions/211079/…
    – David Cary
    Dec 31, 2012 at 19:28
  • @RyanThompson, How would you test this reliably? Sure it may look like it's working, until it doesn't.
    – Pacerier
    Apr 26, 2015 at 22:36
  • That's why I marked the "Don't do it you will lose data" answer as accepted. Apr 27, 2015 at 9:36

15 Answers 15

23

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...

12
  • 6
    I'm going to mark this as the accepted answer just to err on the side of caution for new users reading this question. May 2, 2010 at 5:54
  • Updates caused by one OS affecting the other are rather normal and are not actually caused by issues with hibernation. The hibernation state is treated as any other file on the filesystem. Can't quite see why this answer was accepted.
    – hookenz
    Dec 6, 2011 at 8:09
  • 1
    A whole directory dissapearing into FAT limbo is not an "update caused by one OS," not an intentional one at least. I experienced data corruption in a shared NTFS partition after hibernating Linux, booting Windows, then waking up Linux, simple as that.
    – Chema
    Feb 2, 2012 at 22:22
  • 3
    Hibernating one OS and mounting the same partition in another is effectively having two operating systems access the disk at the same time. They don't know about changes the other one has made so corruption will result.
    – psusi
    Sep 29, 2013 at 3:02
  • 3
    It seems to me that the issue is the OS leaving the partition in an "unclean" state. There is an option in Windows not to cache writes, maybe that helps, Maybe there is a similar option in Linux. Or maybe we can find a way of having the system "clean up" the partition before going to sleep.
    – Rolf
    May 7, 2015 at 11:51
25

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.

5
  • 1
    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. Sep 11, 2009 at 20:09
  • 4
    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, 2009 at 2:18
  • 1
    "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. Nov 11, 2009 at 20:19
  • 1
    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, 2009 at 3:31
  • 1
    since Windows 8 and up Windows boot is lightning fast. When I was using windows 7 it loads slowly so until I can get the browser to start the network is already available. Then I upgraded to windows 8 and since then when I came home, turn on the router then turn on the laptop and browsers I have to wait for a long time before I can access the internet. Since windows 10 it's even faster, press power then a few seconds you'll be ready
    – phuclv
    Jan 21, 2017 at 5:13
9

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.

4
  • 1
    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. Sep 14, 2009 at 7:48
  • 1
    IMHO the corruption people talk about is most likely related to the Linux NTFS driver being not fully compatible with all NTFS features. It's best to mount Read Only.
    – hookenz
    Dec 13, 2011 at 1:28
  • Ok, you would also want to read Is NTFS on Ubuntu stable?
    – nik
    Dec 13, 2011 at 14:16
  • nik is right -- do not mount the partition from the other OS, it is still mounted in the hibernated OS. You wouldn't mount the same partition in two virtual machines (using direct partition access) running at the same time, would you?
    – Ben Voigt
    Jun 25, 2012 at 14:59
9

I can confirm the loss of data issue with a shared NTFS partition. I dual-boot between Lucid Lynx Ubuntu and Windows 7. After hibernating Windows 7 and booting into Ubuntu, I proceeded to build three VirtualBox virtual machines (over the course of 7 days) and installed a variety of software packages into those machines. Upon restarting into Windows 7, the files disappeared. Gone. ntfsundelete and foremost were not able to find them.

So, I ran a series of tests to see if this was in fact what caused the loss of data. When shutting Windows 7 down, starting Ubuntu, writing some files, restarting back into Windows 7, the files are always retained. When hibernating Windows 7, restarting in Ubuntu, writing some files, restarting into Windows 7, the new files are gone.

I don't know about CHANGES written to a file, whether they are retained or lost, but new files and folders added to a shared NTFS partition are most likely going to be lost in this situation.

4

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.

5
  • 4
    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, 2009 at 14:27
  • 2
    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. Sep 14, 2009 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, 2009 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. Sep 14, 2009 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. Sep 14, 2009 at 19:13
4

Just ran into an issue on a shared physical drive (FAT32) between Windows XP and Windows 7. I hibernated Windows XP, booted into Windows 7 for a few days, then went back to XP. Now I have a corrupt file system on the shared drive. Disk Checker is running, and it looks pretty bad. Mostly cross linked files though, but thousands of them.

1
  • 4
    In other words... If you do hibernate to disk, DON'T use a shared drive. (or, if you use Linux, umount that drive before hibernating) Feb 5, 2011 at 2:40
4

This is kinda old, but being a critical issue, another testimonial is worth it.

I have an external NTFS USB hard drive that I'm using for data (no OS-related files) with 2 different PCs. I used to get constant data loss on it until I isolated the problem. One of the PCs is rather old and slow (Windows XP) so I was using hibernate for faster restart times, disconnecting the hard drive while in that state and writing data with the other PC (Windows 7). Data loss was not occurring every time but it was definitely caused by this scenario. Since I stopped doing it, it never happened again.

4
  • The most scary thing for me: this seems to be about a data disk, right? So it's not even the state of the OS itself that is hibernated onto that USB disk, but just data? In that case I'd kind of expect software to properly write things to disk when they get the signal that the OS is about to hibernate. But apparently not...
    – Arjan
    Jul 31, 2014 at 11:17
  • 1
    Exactly. It's a data disk. No OS-related files on it. Sorry for not emphasizing that. Actually, that's why I felt I needed to add my contribution. When I first diagnosed this I was told that it's common sense not to do, but although I'm an it professional this doesn't look obvious at all and it's a scenario so likely to occur with external drives. I guess the reason it's not commonly discussed is that few people actually go to lengths to analyse and diagnose it. Let alone report. Jul 31, 2014 at 11:35
  • Perhaps a silly question: did you safely remove the drive (i.e file manager, right-click on the device, and eject) before hibernating, or did you just pull the drive?
    – gamen
    Jan 4, 2017 at 9:47
  • Yes, it's a silly comment: how do you safely remove a drive while the computer is in hibernate? Jan 5, 2017 at 11:40
3

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

3

Don't do it (again!)

I hibernated my Vista/NTFS and booted up Lucid, worked 3 days on the shared ntfs partition, and started having files and directories disappearing or locked with nasty error messages (within lucid). When I booted back to windows it was a true mess, desktop gone havoc etc.. Hopefully chkdsk was able to fix most of it and I fished out from found.000 about 98% of what I had before.
So it's definitely not a good thing to do.
I sort of remember that this was not possible before: 'hibernated' ntfs partitions were not mountable in linux for some (apparently good) reason. I'd like to come back to this old behavior

3

I had the following highly destructive experience with dual-booting Windows (Vista) and Ubuntu (9, 10, 11). I am not a technical user, though I have long experience using and configuring Windows and DOS. I installed Ubuntu via a live CD on a Win Vista machine. This proceded flawlessly and I had the dual boot up and running in no time. Seeing as there were no warnings attached to the Ubuntu installation, I (naively) assumed that I could hibernate (saving to disk, not suspending) both systems and switch freely between them. This had the following results:

1) I made the mistake of editing a text-file in Ubuntu that I had forgotten was open in Windows. Afterwards the file was inaccessible to either operating system. It could not even be deleted. Chkdsk finally deleted it, but my data were lost.

2) I also tried two other file operations from Ubuntu directly into the Win partition: Generating a pdf-file from OpenOffice, and creating a directory/folder on the Win desktop. Both were inaccessible from Windows (though they could be seen in Win explorer). Luckily they could be deleted from Ubuntu, though chkdsk had to be run afterward to delte then completely from Windows.

3) A large OpenOffice Writer file (saved as *.doc), which was edited first in one, then in the other operating system several times (it was not open in the other system when I edited it), suddenly ballooned in size from about 2 MB to 7 MB, making it nearly impossible to load and save. When I saved the file as an *.odt document its size was greatly reduced but save/load times were no faster. When I unzipped the file, its "contents" section turned out to be more than 22 MB. When I accessed this with a text editor, it turned out that every single word and space in the document was separately formatted in and out of the same style! I finally resolved the problem by comparing the giant version with an earlier version of the same file, using the old version as the basis for the comparison, and then accepting all changes and saving.

4) At this point I upgraded from Ubuntu 10 to Ubuntu 11 and discovered that the 11 system used the new Unity interface exclusively, which was completely unacceptable for my purposes. When I figured out how to install Gnome on Ubuntu 11, it turned out Gnome 3 was far inferior to Gnome 2. I therefore decided to uninstall Ubuntu completely and make a fresh installation of Karmic Koala, which uses Gnome 2 without any trace of the new Unity system. This turned out to be complicated, but after finding the exact same instructions repeated in several manuals online, I proceded. Everything went fine until I ran EasyBCD 2.1.2 (from windows), which would allow me to reboot directly to Windows after Ubuntu's Grub booter had been removed. On rebooting, I found that my MBR was fatally damaged and the machine did not recognize any bootable hard drives. I needed to pay a technician to restore the MBR.

5) Now I could boot to Vista again and I was getting ready to reinstall Ubuntu, when I discovered that a number of files started disappearing from my system at random. Obviously the file system was still corrupted. Only a complete reinstall of Windows solved the problem, and I am now considering very carefully what I should do to avoid similar problems in the future, before installing Karmic Koala. I hope my problems are related to the hibernation issue, but to be sure, I am considering creating a separate "transfer" NTFS partition, where I can put files from one operating system before accessing them from the other. Impractical, but it ought to be safe. I hope.

2

DANGER! I can also confirm this is a dire issue for both FAT32 and NTFS volumes & only when Windows (I have windows 7) is hibernated. I think this is tied to caching and have considered setting the drive up for quick removal. That may fix it, but I haven't tried it yet because I really only want to set one partition up this way which Windows does not seem to support. Even my OSX ntfs driver supports per partition cache control, but not windows. Also, my OSX ntfs driver seems to recognize that the drive should not be mounted. Seems to be tied to this issue. Hope that helps.

1
  • 1
    Yes, it's related to caching, and no, "optimize for quick removal" won't help. That makes Windows write changes out immediately, but Windows will still assume (dangerously) that its read cache is 100% valid, and won't see changes other OSes have made to the disk.
    – Ben Voigt
    Jun 25, 2012 at 15:02
1

Here is my experience. I am using a dual boot system with Windows and Kubuntu (11.04). Most of my files are on a Windows NTFS partition and I use primarily it from Linux. It's mounted using FUSE.

This is what happened:

  1. Hibernated Windows
  2. On the next boot, booted to Linux and used it for couple of weeks - without booting to Windows
  3. Booted back to Windows (because an online test only worked in Internet Explorer and nothing else, somehow ie4linux wasn't sufficient)

When Windows resumed, I noticed that all the files created in those two weeks were missing. I rebooted back to Linux to verify only to find files missing there too. I am guessing Windows restored the NTFS filesystem to the state when it was hibernated and restored it back to that point in time.

I tried tools like ntfsundelete and testdisk. Those missing files are not listed. Also, Linux mounts that drive in RW mode even when Windows had hibernated and not shutdown. I guess Linux warns or just mounts the drive in read-only mode, but that didn't happen here.

1
  • 2
    There is a marking on the filesystem metadata whether it's unmounted properly or not... I also would think the correct behavior is for the Linux NTFS driver to check that flag.
    – Ben Voigt
    Jun 25, 2012 at 15:04
1

I can also confirm that share some non-system partition between two different O/S in hibernate state makes file system corruption and loose of data.

Scenario: I have 3 partitions NTFS: 1. Windows XP 2. Windows 7 3. Data ( I have to still use XP for old apps which don't work well in compatbility mode).

Example: Boot from partition 1 (XP) and run Thunderbird which store files on 3. Then hibernate (OS dump RAM to hibernate file and shutdown PC). Boot from partition 2 (7) and run Thunderbird which store files on 3. Here the problem begins with access files etc. sometimes with or without chkdsk. Back to boot from partition 1 and files fixed by OS_2_7 are again corrupted, even worst some open files before hibernation (ex. Firefox) are corrupted now.

So yes. Hibernate two O/S no matter they use system/non-system partition will make data corruption. Why ? I suppose the root cause is file LOCK and MFT. After wake up from hibernation O/S doesn't refresh MFT so still suppose to find files in old sectors, so any file which changed his size/place will be corrupted.

1
  • Well, what files became corrupted? Just those belonging to Thunderbird or several unrelated files? It can make (some) sense that if Thunderbird is run from the same location in partition 3 then there are two different data sets in two different systems. One will try to force the other. Sep 29, 2013 at 0:25
0

I used to do exactly this. I never mounted the system drive of the hibernating machine to avoid accidents, and each OS have their own separate swap partition. However I had a dedicated data partition, which I would use to transfer data between the two hibernating OS. I even put my Firefox and Thunderbird profile there, so I don't need to keep two separate profiles. Just make sure to close the Firefox on one machine before hibernating it.

I don't recall ever having any issues with the setup, and I used it for quite a long time as well.

4
  • What FS do you use on the shared partition? I am starting to think that maybe NTFS has something to do with it, everybody complains that their shared NTFS paritition is getting corrupted.
    – Rolf
    May 7, 2015 at 11:59
  • @Rolf: NTFS with ntfs-3g driver on Linux. Also, this was purely data partition, except for applications like Firefox/Thunderbird, which I know has warnings for unclean shutdown, and which I would always close before switching OS.
    – Lie Ryan
    May 9, 2015 at 1:06
  • Maybe FAT would do? NTFS is better but in this case it does not seem to work well, to say the least. Also, if we can get the system to flush all buffer to disk before hibernating, maybe it'll help. But I guess it would be best to experiment with different filesystems (EXT or others might also be options) for the shared partition. If anyone is willing to do that :) Maybe in a virtual machine? BTW I encountered the same problem by using a VM, saving the state, then using the same VM (same file) but under another OS. The VM host was not aware of the saved state.
    – Rolf
    May 16, 2015 at 18:24
  • 2
    So what your'e saying is that if we remember to close all file handles to the shared partition before hibernating, then it should be OK.
    – Rolf
    May 16, 2015 at 18:26
-3

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.

5
  • I'm not talking about suspend to RAM, I mean hibernation to disk. I'll edit the question to be more specific. Sep 11, 2009 at 8:48
  • 7
    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, 2009 at 8:48
  • No, it will cause problems with filesystem consistency. See my post above. May 2, 2010 at 3:52
  • @George: There will be problems with filesystem consistency, if you share any filesystems between both OSes. But you certainly can run a different OS that has its own set of partitions, contrary to this answer.
    – Ben Voigt
    Jun 25, 2012 at 15:05
  • If it didn't go through the BIOS and POST then it would not be possible to choose the OS at startup and do messups such as the ones described here. Hibernate is not suspend to ram.
    – Rolf
    May 7, 2015 at 12:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .