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

5,471

Solution 1

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.

Solution 2

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.

Share:
5,471

Related videos on Youtube

Franz
Author by

Franz

Full-stack developer from Germany, with a M.Sc. in IT-Systems Engineering.

Updated on September 17, 2022

Comments

  • Franz
    Franz almost 2 years

    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?

    • Ignacio Vazquez-Abrams
      Ignacio Vazquez-Abrams over 13 years
      Windows doesn't force you to boot into it when you hibernate it?
    • Xantec
      Xantec over 13 years
      @ Ignacio that probably depends on the boot manager being used
    • David Cary
      David Cary over 11 years
  • Tarka
    Tarka over 13 years
    Mirrors my general observations on my Vista/Ubuntu desktop.
  • Franz
    Franz over 13 years
    Could you comment on my edit, please? The only thing that keeps me from accepting an answer...
  • Franz
    Franz over 13 years
    Could you comment on my edit, please? The only thing that keeps me from accepting an answer...
  • Dave Sherohman
    Dave Sherohman over 13 years
    @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.
  • Franz
    Franz over 13 years
    Which would mean I should rather not, right?
  • CarlF
    CarlF over 13 years
    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?"
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 13 years
    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'
    Gilles 'SO- stop being evil' over 13 years
    @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.
  • CarlF
    CarlF over 13 years
    @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.