What do I have to take care of when hibernating both Ubuntu and Windows (dual-boot environment)

10

3

I've got both Windows 7 and Ubuntu (finally) installed on my laptop.

For the sake of comfort, I usually hibernate Windows instead of shutting it down. And I think when using Ubuntu regularly, there will be times when I do that to quickly switch from Windows to Ubuntu to check or do something quickly and then want to continue my work on Windows.

1) Are there any problems with hibernating both Windows and Ubuntu at the same time?

I should probably also mention that I created an extra partition which I use to access from both Windows and Ubuntu. I would like to put my www directory of my test web servers on that drive, so that I can work on that stuff both from Windows and from Ubuntu.

2) So - is this a good idea and what do I have to be careful with?

EDIT: One important sidenote I forgot: I want to share a Mozilla Thunderbird profile directory on a shared drive. Does that change anything?

Franz

Posted 2010-11-15T16:52:31.863

Reputation: 595

Windows doesn't force you to boot into it when you hibernate it? – Ignacio Vazquez-Abrams – 2010-11-15T16:59:21.377

2@ Ignacio that probably depends on the boot manager being used – Xantec – 2010-11-15T17:49:10.390

Answers

11

I've never tried it with Windows, but I think it should work. There's just one point you have to be very careful of: always unmount the shared partition(s) before hibernating.

More precisely, you need a reader-writer lock on each shared partition. That is, at any given time you must either:

  • have one OS (live or hibernating) with write access to the partition, and no other OS with read access;
  • or have any number of OSes with read access, and none with write access.

Again, a hibernating OS with the partition mounted counts as an access. This is because when an OS hibernates, it saves some assumptions about the partition (i.e. some form of cache)¹. If the assumptions have become wrong when you resume, massive filesystem corruption is likely to occur.

¹ I think current hibernation systems under Linux don't hibernate any data cache, but there is a little metadata that's saved as part of the kernel state. It's possible that you may be lucky enough that this metadata doesn't change short of a filesystem resize or defragmentation, but I wouldn't risk it.

Gilles 'SO- stop being evil'

Posted 2010-11-15T16:52:31.863

Reputation: 58 319

Could you comment on my edit, please? The only thing that keeps me from accepting an answer... – Franz – 2010-11-19T13:52:12.690

@Franz: Seems to me that this answer directly addresses your edit: If the shared partition is mounted in both operating systems at the same time, you run a significant risk of that partition (including your Thunderbird profile directory) being corrupted if one OS alters its contents while the other (even if hibernating) has cached data or metadata from that partition. – Dave Sherohman – 2010-11-19T14:01:44.370

Which would mean I should rather not, right? – Franz – 2010-11-19T14:52:17.123

@Franz: As I indicate in my footnote, I don't think you could leave the partition mounted before hibernating, but I don't know for sure about an NTFS partition. Even if it turns out leaving the partition mounted is safe, I think you can't run two copies of Thunderbird at the same time on the same profile, so you'd have to close Thunderbird before hibernating. – Gilles 'SO- stop being evil' – 2010-11-19T19:52:14.547

9

I use both Windows and Debian GNU/Linux on my netbook. I hibernate them both and choose one on awakening and have had no problems whatsoever. I also have a shared data partition similar to what you describe. I use NTFS (which is fully supported by recent Linux releases) and have had no problems.

Ubuntu (and Linux in general) hibernate to a swap partition. That is, the contents of RAM are saved to this extra partition. Windows saves to a swap area in its own partition (by default). The two images are in totally different places and cannot interfere with each other.

CarlF

Posted 2010-11-15T16:52:31.863

Reputation: 8 576

Mirrors my general observations on my Vista/Ubuntu desktop. – Tarka – 2010-11-15T21:52:25.613

Could you comment on my edit, please? The only thing that keeps me from accepting an answer... – Franz – 2010-11-19T13:51:50.583

I have no experience with sharing Mozilla Thunderbird profiles. May I suggest that this is an entirely separate question which you should ask separately, with the 'mozilla-thunderbird' tag and a subject like "Can I share the same Thunderbird profile between two operating systems?" – CarlF – 2010-11-19T16:55:12.627

It's not clear from your answer that you leave the shared partition mounted when you hibernate. I know from experience this wouldn't work with an ext3 partition (shared between Linux and Linux); I would be surprised if it worked with another filesystem, but I don't actually know. – Gilles 'SO- stop being evil' – 2010-11-19T19:49:31.613

@Gilles, it's an NTFS partition. It's never dismounted, but both Windows and Linux are smart enough to flush disk buffers when hibernating. Note that this does NOT work on the Windows boot partition, even though both are NTFS. – CarlF – 2010-11-30T13:42:23.330

@CarlF Not so. What was in the cache before is still used after resume so if the contents of the disk changed, corruption will result. This has caused plenty of people to loose data when booting livecds and created a bit of a stir a few years ago when it was noticed that even mounting an ext3/4 fs read only will still replay the journal, trashing the fs that is still in use by the hibernated system. – psusi – 2011-08-03T02:15:08.680