Hibernating and booting into another OS: will my filesystems be corrupted?

Solution 1:

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

Solution 2:

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.