Disable hibernation if swap is on file

Bug #224697 reported by Agostino Russo
12
Affects Status Importance Assigned to Milestone
pm-utils (Debian)
New
Unknown
pm-utils (Ubuntu)
Fix Released
Undecided
Martin Pitt
Hardy
Fix Released
Undecided
Unassigned
Intrepid
Fix Released
Undecided
Martin Pitt

Bug Description

Binary package hint: pm-utils

If any swap device is on file, hibernation should be disabled. There were reports of Wubi users (swap is on file in such setups) ending up with a frozen system. It should be a matter of going through the swapon -s list.

Agostino Russo (ago)
Changed in pm-utils:
status: New → Confirmed
description: updated
Agostino Russo (ago)
Changed in pm-utils:
assignee: nobody → ago
Revision history for this message
Agostino Russo (ago) wrote :

Untested patch

Revision history for this message
Agostino Russo (ago) wrote :

Tested and works well for me.

Revision history for this message
Agostino Russo (ago) wrote :

Martin, since I have noticed you are in -proposed mode, I thought I'd subscribe you to this as well. I hope you do not mind. :P

This patch would be useful in hardy because hibernating a wubi installation might freeze the system, and users might then be inclined to hard reboot, which in turn might corrupt the filesystem (had someone complaining about it in the forum...).

Thanks

Revision history for this message
Martin Pitt (pitti) wrote :

In general that looks fine. However, you should robustify it for the case that /proc/swaps does not exist for some reason (people might have disabled it in the kernel config, or whatever). Also, can you please open an upstream bug for it and link it here?

I'll sponsor this to intrepid and hardy-proposed after that. Thanks!

Revision history for this message
Agostino Russo (ago) wrote :
Revision history for this message
Agostino Russo (ago) wrote :

The debdiff for debian is a bit different from the above since it is against version 1.1.2.2

Changed in pm-utils:
status: Unknown → New
Revision history for this message
Martin Pitt (pitti) wrote :

Accepted into -proposed, please test and give feedback here

Changed in pm-utils:
status: New → Fix Committed
Revision history for this message
vlowther (victor-lowther) wrote :

Are there any instances of non wubi users having hibernation issues when using just swapfiles, or when using swap partitions and swapfiles?

Revision history for this message
Agostino Russo (ago) wrote :

@Martin, I tested the changes and they work for me.
@Vlowther, I am not sure how common it is for people to use swap files, but it certainly is very easy to replicate...

Revision history for this message
Martin Pitt (pitti) wrote :

Copied to hardy-updates.

Changed in pm-utils:
status: Fix Committed → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

Should be fixed in Intrepid ASAP, too.

Changed in pm-utils:
milestone: none → intrepid-alpha-6
Revision history for this message
Agostino Russo (ago) wrote :

Martin see my patch for debian, that should also apply to intrepid (haven't actually tried though)

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484212

Revision history for this message
Martin Pitt (pitti) wrote :

Taking for sponsoring.

Changed in pm-utils:
assignee: ago → pitti
status: Confirmed → In Progress
Revision history for this message
PetrB (petr-bug) wrote :

Disabling hibernation if swap is on file - is it too aggressive approach? I mean, the crashes are reported to happen on Wubi only (where are the reports anyway?).

Some people use swap file only and there even was a discussion about using swap file as default in some distro since it make installation easier to newbies and has negligible speed impact (http://www.ussg.iu.edu/hypermail/linux/kernel/0507.0/1690.html).

Revision history for this message
Martin Pitt (pitti) wrote :

This was actually uploaded a while ago already:

pm-utils (1.1.0-1ubuntu2) intrepid; urgency=low

  * 30-swap-file.patch: Added to disable hibernation when swap resides on a
    file.

 -- Evan Dandrea <email address hidden> Wed, 28 May 2008 10:59:14 -0400

Changed in pm-utils:
status: In Progress → Fix Released
Revision history for this message
PetrB (petr-bug) wrote :

Is this the current patch?
http://patches.ubuntu.com/p/pm-utils/extracted/30-swap-file.patch

User will have no idea why is hibernation disabled. What about documenting the patch?

 check_hibernate()
 {
- [ -f /sys/power/disk ] && grep -q disk /sys/power/state
+ # There has been rumor that hibernation of WUBI system (using swap file) causes freeze.
+ # See https://bugs.launchpad.net/debian/+source/pm-utils/+bug/224697
+ grep -q "/.*[[:space:]]file[[:space:]]" /proc/swaps && return 1
+ [ -f /sys/power/disk ] && grep -q disk /sys/power/state && return 0
 }

Revision history for this message
Chow Loong Jin (hyperair) wrote : Re: [Bug 224697] Re: Disable hibernation if swap is on file

On Sun, 2008-10-05 at 19:29 +0000, PetrB wrote:
> Is this the current patch?
> http://patches.ubuntu.com/p/pm-utils/extracted/30-swap-file.patch
>
> User will have no idea why is hibernation disabled. What about
> documenting the patch?
>
> check_hibernate()
> {
> - [ -f /sys/power/disk ] && grep -q disk /sys/power/state
> + # There has been rumor that hibernation of WUBI system (using swap file) causes freeze.
> + # See https://bugs.launchpad.net/debian/+source/pm-utils/+bug/224697
> + grep -q "/.*[[:space:]]file[[:space:]]" /proc/swaps && return 1
> + [ -f /sys/power/disk ] && grep -q disk /sys/power/state && return 0
> }
I doubt documenting the patch will do any good in that aspect, although
it's always good to document the patch. The general user doesn't apt-get
source pm-utils to figure out why it doesn't hibernate.
--
Chow Loong Jin

Revision history for this message
Johan Kröckel (jnkl) wrote :

I have used hibernation to a swapfile for some time without problems and thought the disabled hibernate was a bug (Bug 252143). So is there a way to reenable it?
The other really funny aspect here is: On a fresh ubuntu installation without any swapspace hibernate is not disabled, but after creating and activating the swap file, it is.

Revision history for this message
Martin Pitt (pitti) wrote :

Agostino, why does this particularly affect wubi users? The recent comments seem to indicate that this should be reverted again.

Changed in pm-utils:
milestone: intrepid-alpha-6 → none
status: Fix Released → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pm-utils - 1.1.2.4-1ubuntu5

---------------
pm-utils (1.1.2.4-1ubuntu5) intrepid; urgency=low

  * Drop 30-swap-file.patch again. Reportedly, resuming from a swap file works
    just fine. (LP: #224697)

 -- Martin Pitt <email address hidden> Tue, 07 Oct 2008 19:44:20 +0200

Changed in pm-utils:
status: In Progress → Fix Released
Revision history for this message
Agostino Russo (ago) wrote :

Martin,

I didn't test hibernation on the latest intrepid (will do so in the coming days) but I am glad to hear that hibernation using a swap file now works. It is my understanding though that not all suspend (to disk) mechanisms do support swap on file, so it might be appropriate to test whether the current suspend app is indeed happy to use a swap file. Also, from what I gather from Johan's comment, we should test if there is a swap at all.

Revision history for this message
Tom Hughes (tomtheengineer) wrote :
Changed in pm-utils (Debian):
status: New → Fix Released
Changed in pm-utils (Debian):
status: Fix Released → New
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.