Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Is hibernating "dual-boot safe"? [no, it isn't]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
peter4
Guru
Guru


Joined: 19 Jul 2005
Posts: 359
Location: Wroclaw, Poland

PostPosted: Tue Aug 10, 2010 9:52 am    Post subject: Is hibernating "dual-boot safe"? [no, it isn't] Reply with quote

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
Back to top
View user's profile Send private message
mrsteven
Veteran
Veteran


Joined: 04 Jul 2003
Posts: 1938

PostPosted: Tue Aug 10, 2010 12:19 pm    Post subject: Reply with quote

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.
_________________
Unix philosophy: "Do one thing and do it well."
systemd: "Do everything and do it wrong."
Back to top
View user's profile Send private message
peter4
Guru
Guru


Joined: 19 Jul 2005
Posts: 359
Location: Wroclaw, Poland

PostPosted: Tue Aug 10, 2010 12:22 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
mrsteven
Veteran
Veteran


Joined: 04 Jul 2003
Posts: 1938

PostPosted: Tue Aug 10, 2010 12:34 pm    Post subject: Reply with quote

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 *********************************************************
*
* If you touch anything on disk between suspend and resume...
* ...kiss your data goodbye.
*
* If you do resume from initrd after your filesystems are mounted...
* ...bye bye root partition.
* [this is actually same case as above]
[...]

_________________
Unix philosophy: "Do one thing and do it well."
systemd: "Do everything and do it wrong."
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Tue Aug 10, 2010 1:00 pm    Post subject: Reply with quote

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 ;)
_________________
emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/
Back to top
View user's profile Send private message
peter4
Guru
Guru


Joined: 19 Jul 2005
Posts: 359
Location: Wroclaw, Poland

PostPosted: Tue Aug 10, 2010 1:21 pm    Post subject: Reply with quote

Thanks.
Back to top
View user's profile Send private message
peter4
Guru
Guru


Joined: 19 Jul 2005
Posts: 359
Location: Wroclaw, Poland

PostPosted: Tue Aug 10, 2010 3:46 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 16176

PostPosted: Tue Aug 10, 2010 10:42 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
peter4
Guru
Guru


Joined: 19 Jul 2005
Posts: 359
Location: Wroclaw, Poland

PostPosted: Tue Aug 10, 2010 11:09 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Paczesiowa
Guru
Guru


Joined: 06 Mar 2006
Posts: 593
Location: Oborniki Śląskie, Poland

PostPosted: Wed Aug 11, 2010 5:52 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
peter4
Guru
Guru


Joined: 19 Jul 2005
Posts: 359
Location: Wroclaw, Poland

PostPosted: Wed Aug 11, 2010 7:59 am    Post subject: Reply with quote

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 :) My method seems simpler :)
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 16176

PostPosted: Thu Aug 12, 2010 1:52 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
peter4
Guru
Guru


Joined: 19 Jul 2005
Posts: 359
Location: Wroclaw, Poland

PostPosted: Thu Aug 12, 2010 9:37 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
widremann
Veteran
Veteran


Joined: 14 Mar 2005
Posts: 1314

PostPosted: Thu Aug 12, 2010 4:29 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
devsk
Advocate
Advocate


Joined: 24 Oct 2003
Posts: 2899
Location: Bay Area, CA

PostPosted: Fri Aug 13, 2010 6:54 am    Post subject: Reply with quote

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:
Code:
#!/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...;-)

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!... :lol: :P :wink:
Back to top
View user's profile Send private message
peter4
Guru
Guru


Joined: 19 Jul 2005
Posts: 359
Location: Wroclaw, Poland

PostPosted: Sun Aug 15, 2010 9:53 am    Post subject: Reply with quote

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? :D
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Sun Aug 15, 2010 11:07 am    Post subject: Reply with quote

peter4 wrote:
Also, are you suggesting that I should be learning bash while standing up? :D
Yes yes. All while standing on one leg. You don't really learn bash unless you get bashed in the process. :twisted:
_________________
emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7614
Location: almost Mile High in the USA

PostPosted: Sun Aug 15, 2010 7:12 pm    Post subject: Reply with quote

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:
Code:
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 :(

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...
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
devsk
Advocate
Advocate


Joined: 24 Oct 2003
Posts: 2899
Location: Bay Area, CA

PostPosted: Sun Aug 15, 2010 7:33 pm    Post subject: Reply with quote

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? :D
yes... :lol: you need to be on your toes if you want to learn bash... :wink:
Back to top
View user's profile Send private message
devsk
Advocate
Advocate


Joined: 24 Oct 2003
Posts: 2899
Location: Bay Area, CA

PostPosted: Sun Aug 15, 2010 7:42 pm    Post subject: Reply with quote

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:
Code:
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 :(

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...
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...;-) I hardly ever boot into Windows anymore. Most of my needs are fulfilled by Linux and Virtualbox booting the physical Windows partition.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum