# Is hibernating "dual-boot safe"? [no, it isn't]

## peter4

Hi,

I have a dual-boot system with Gentoo and Windows. I also have a few NTFS partition I'd like to use from both systems. Now, should I unmount the NTFS partition before entering suspend-to-disk and rebooting to windows? Or does the kernel take care of flushing caches and stuff like that before going to sleep? I'm using TuxOnIce.Last edited by peter4 on Tue Aug 10, 2010 1:22 pm; edited 1 time in total

----------

## mrsteven

No, it is not safe without further actions. You always have to umount your shared partitons before booting into the other OS, otherwise bad things will happen! The hibernate script can be configured to do that automatically, and I'm sure pm-utils can also do that.

----------

## peter4

 *mrsteven wrote:*   

> The hibernate script can be configured to do that automatically, and I'm sure pm-utils can also do that.

 

What about KDE's hibernate option?

----------

## mrsteven

 *peter4 wrote:*   

>  *mrsteven wrote:*   The hibernate script can be configured to do that automatically, and I'm sure pm-utils can also do that. 
> 
> What about KDE's hibernate option?

 

Uses pm-utils... Check the scripts in /usr/lib/pm-utils/sleep.d, on my system there is no script that umounts FAT and NTFS filesystems before actually suspending. So be careful! You'll find a file /usr/share/doc/pm-utils-1.4.1/HOWTO.hooks.bz2 on your system that describes how to write your own helper scripts.

Note that having a ext2/3 driver for Windows might also be a bad idea if you want to use Windows while Linux is hibernated.

So, in conclusion: Don't hibernate and boot an other OS, unless you are absolutely sure what you are doing:

 */usr/src/linux/Documentation/power/swsusp.txt wrote:*   

> 
> 
> Some warnings, first.
> 
>  * BIG FAT WARNING *********************************************************
> ...

 

----------

## ppurka

I had a good bit of corruption in my ntfs partition once I tried that. It worked all the time, until that final time when some files (nvidia driver files) in ntfs went missing or corrupted and windows couldn't boot any more. Trying repair from a windows install disk didn't work. 

On the gentoo side, I had hibernated with X. 

So, it may work most of the time, until it fails  :Wink: 

----------

## peter4

Thanks.

----------

## peter4

For those who stumble across this topic in the future: I've been able to solve this problem really nicely using net-fs/autofs: it mounts the filesystems whenever something tries to read or write to it's mountpoint and unmounts them automatically after specified period of time.

----------

## Hu

Although using autofs helps, that does not guarantee data integrity.  If you access one of the shared automounted volumes, then hibernate before autofs unmounts it, you will experience exactly the same problems as if you had left a shared volume manually mounted.  To be safe, you must configure your hibernate process to unmount the shared volumes if you expect to boot the other system and you must ensure that the hibernate process treats failure to unmount as a fatal error.

----------

## peter4

Well, I think I'll take my chances and try to remember not to hibernate within 30 seconds from accessing a ntfs volume. Even though it has it's drawbacks, writing 3 lines in simply structured configuration files seem much easier than learning how to write pm-util's helper scripts, even if that doesn't give me a 100% guarantee of safety.

----------

## Paczesiowa

I'm using nfs mounted (read-only) partition with media (e.g. music) I've been using it for months with hibernating while playing music and when it resumes it keeps on playing. it cannot corrupt the data (because it's read only) so the worst thing possible [/b]is probably an amarok crash or something, but that doesn't happen.

----------

## peter4

That's a solution too, but then, when I want to throw some data in there, I try to remount it rw, it tells me only root can do it, I try to do it as root, it tells me ntfs-3g doesn't support remounting, so I unmount it, mount it rw, copy the data, unmount it and mount it ro. Then, after hibernating I'd have to return at least once before booting windows just to check if I remembered to remount it ro   :Smile:  My method seems simpler   :Smile: 

----------

## Hu

 *peter4 wrote:*   

> Even though it has it's drawbacks, writing 3 lines in simply structured configuration files seem much easier than learning how to write pm-util's helper scripts, even if that doesn't give me a 100% guarantee of safety.

 As you wish.  I simply sought to ensure that other readers did not undertake your solution without understanding the risks.  I cannot speak to the complexity of sys-power/pm-utils helper scripts, but the configuration file for sys-power/hibernate-script makes it very easy to flag particular mount points or particular filesystem types as requiring an unmount during hibernation.

----------

## peter4

Sure, I just assumed that a typical Gentoo user will likely understand it  :Smile: 

And as for hibernate-script: if someone uses it, then that would probably be the best solution. But as mrsteven said, KDE uses pm-utils, so there's not much choice here for me.

----------

## widremann

In /etc/hibernate config files (presumably for uswsusp or swsusp), there are option to unmount specific filesystems or filesystems of specific types (e.g., NTFS).  That's what I use.

----------

## devsk

 *peter4 wrote:*   

> Sure, I just assumed that a typical Gentoo user will likely understand it 
> 
> And as for hibernate-script: if someone uses it, then that would probably be the best solution. But as mrsteven said, KDE uses pm-utils, so there's not much choice here for me.

 This is for pm-utils. Create a file called /etc/pm/sleep.d/99myhook with execute perms (chmod +x /etc/pm/sleep.d/99myhook) and put the following in there:

```
#!/bin/bash

case $1 in

        hibernate)

                # reached when hibernate is done

                # umount my FS

                sync;sync;sync

                umount /myFS

                ;;

        suspend)

                # reached when suspend to RAM is done

                sync;sync;sync

                umount /myFS

                ;;

        thaw|resume)

                # reached when resume is done

                mount /myFS

                ;;

esac

```

How hard was that?

Replace /myFS with your FS... :Wink: 

You may wanna add some error handling by using the return code $? and then may be exit the script so that you don't suspend or hibernate if umount fails.

Finally, get off you lazy bum and learn some bash!...  :Laughing:   :Razz:   :Wink: 

----------

## peter4

Thanks, devsk  :Smile: 

I won't try it, since I'm starting to like my autofs setup  :Smile:  But it probably will be of use for somebody else.

Also, are you suggesting that I should be learning bash while standing up?  :Very Happy: 

----------

## ppurka

 *peter4 wrote:*   

> Also, are you suggesting that I should be learning bash while standing up? 

 Yes yes. All while standing on one leg. You don't really learn bash unless you get bashed in the process.   :Twisted Evil: 

----------

## eccerr0r

 *devsk wrote:*   

> This is for pm-utils. Create a file called /etc/pm/sleep.d/99myhook with execute perms (chmod +x /etc/pm/sleep.d/99myhook) and put the following in there:
> 
> ```
> auto-unmount script deleted
> ```
> ...

 

I wonder how often someone has a window chdir'ed into that directory or have a program just so happen to be left open for the hibernate...

I suppose you could lsof/etc and kill but then... not really hibernating anymore when you have to restart apps  :Sad: 

Guess really have to simply be careful... no easy ways out.  Someone/some program will have cached some data somewhere making it get confused if the disk changes while hibernating...

----------

## devsk

 *peter4 wrote:*   

> Thanks, devsk 
> 
> I won't try it, since I'm starting to like my autofs setup  But it probably will be of use for somebody else.
> 
> Also, are you suggesting that I should be learning bash while standing up? 

 yes...  :Laughing:  you need to be on your toes if you want to learn bash...  :Wink: 

----------

## devsk

 *eccerr0r wrote:*   

>  *devsk wrote:*   This is for pm-utils. Create a file called /etc/pm/sleep.d/99myhook with execute perms (chmod +x /etc/pm/sleep.d/99myhook) and put the following in there:
> 
> ```
> auto-unmount script deleted
> ```
> ...

 depends on how often use those NTFS/FAT volumes that Windows might open. One way to force Windows from seeing those volumes is to hide them in grub. But then, you have to reboot Windows if you want to open any file in those volumes. So, this can get really tedious!

Yes, if most of your apps are accessing that data, there is no point in killing all of them, unmounting and then hibernating. You might as well restart.

Best is to not to dual boot... :Wink:  I hardly ever boot into Windows anymore. Most of my needs are fulfilled by Linux and Virtualbox booting the physical Windows partition.

----------

