GNU bug report logs - #37290
Guix System: Hibernation

Previous Next

Package: guix;

Reported by: Nolan Wright <nolan.wright.other <at> gmail.com>

Date: Mon, 2 Sep 2019 22:54:02 UTC

Severity: normal

Done: Tobias Geerinckx-Rice <me <at> tobias.gr>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37290 in the body.
You can then email your comments to 37290 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#37290; Package guix. (Mon, 02 Sep 2019 22:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nolan Wright <nolan.wright.other <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Mon, 02 Sep 2019 22:54:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nolan Wright <nolan.wright.other <at> gmail.com>
To: bug-guix <at> gnu.org
Subject: Guix System: Hibernation
Date: Mon, 2 Sep 2019 17:06:31 -0400
[Message part 1 (text/plain, inline)]
Hello,

I have a desktop computer that sits in the same room where I sleep. The
fans produce a noise that I would prefer not to hear when going to bed. For
that reason, I wish to make use of the hibernation feature, in which the
system state is suspended to disk as described here:

https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate

The IRC user *nxck*, who was very helpful, after some brief experimentation
concluded that Guix System probably does not support the hibernation
feature. Indeed the following comment in the source code suggests as much:

http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/desktop.scm#n598

Additionally I found the following message in this mailing list from three
years ago which stated that the feature is not supported:

https://lists.gnu.org/archive/html/bug-guix/2016-11/msg00067.html

The three requirements for the hibernation feature to my knowledge are: 1)
sufficient swap space; 2) the resume kernel parameter; and 3) the resume
hook in the initramfs.

So, in the case that this feature is currently supported, I ask for
guidance in implementing it, and in the case that it is not currently
supported, I put forth my advocacy for its support and ask for guidance in
adding support for it.

Thank you.
[Message part 2 (text/html, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#37290; Package guix. (Tue, 03 Sep 2019 03:26:02 GMT) Full text and rfc822 format available.

Message #8 received at 37290 <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Nolan Wright <nolan.wright.other <at> gmail.com>
Cc: 37290 <at> debbugs.gnu.org
Subject: Re: bug#37290: Guix System: Hibernation
Date: Mon, 02 Sep 2019 23:24:50 -0400
[Message part 1 (text/plain, inline)]
Hi Nolan,

Nolan Wright <nolan.wright.other <at> gmail.com> writes:

> I have a desktop computer that sits in the same room where I
> sleep. The fans produce a noise that I would prefer not to hear when
> going to bed. For that reason, I wish to make use of the hibernation
> feature, in which the system state is suspended to disk as described
> here:
>
> https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate
>
> The IRC user nxck, who was very helpful, after some brief
> experimentation concluded that Guix System probably does not support
> the hibernation feature. Indeed the following comment in the source
> code suggests as much:
>
> http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/desktop.scm#n598
>
> Additionally I found the following message in this mailing list from
> three years ago which stated that the feature is not supported:
>
> https://lists.gnu.org/archive/html/bug-guix/2016-11/msg00067.html

The message above links to an earlier message with my preliminary patch
to support hibernation:

  https://lists.gnu.org/archive/html/guix-devel/2016-08/msg00962.html

I've been carrying that patch in my local branch of Guix for 3 years.
It needs a bit more work before it's ready to include in Guix, and I'm
sorry to say that I lost motivation to work on it because it seems that
almost no one cares about hibernation today.

Anyway, I've attached below a slightly updated version of the patch that
applies cleanly to current Guix.  Quoting from the message above:

you'll also need to add a line like this to your 'operating-system'
definition.

  (kernel-arguments '("resume=/dev/sda2"))

Where the device named is a swap partition.

WARNING: Since this is preliminary work, I recommend that the first time
you test this, be prepared for the possibility that resume will fail.
So far I've only tested it with simple partitions, without encryption or
RAID.

It may be that we should add a dedicated 'resume-device' field to the
'operating-system'.  Thoughts?

      Mark


[0001-PRELIMINARY-Add-support-for-hibernation.patch (text/x-patch, inline)]
From c0e9d9913b66649783a4fac05a0da4db1b79faec Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw <at> netris.org>
Date: Sun, 14 Aug 2016 04:45:06 -0400
Subject: [PATCH] PRELIMINARY: Add support for hibernation.

* gnu/build/linux-boot.scm (boot-system): Look for a resume=<device-name>
argument on the linux command line, and if present, attempt to resume from
hibernation.
* gnu/services/desktop.scm (<elogind-configuration>): Change the default
value of the 'handle-hibernate-key' key to 'hibernate'.
---
 gnu/build/linux-boot.scm | 50 +++++++++++++++++++++++++++++++++++++---
 gnu/services/desktop.scm |  6 +----
 2 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index f273957d78..767a424e72 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -477,9 +477,10 @@ upon error."
   (call-with-error-handling
    (lambda ()
      (mount-essential-file-systems)
-     (let* ((args    (linux-command-line))
-            (to-load (find-long-option "--load" args))
-            (root    (find-long-option "--root" args)))
+     (let* ((args          (linux-command-line))
+            (to-load       (find-long-option "--load" args))
+            (root          (find-long-option "--root" args))
+            (resume-device (find-long-option "resume" args)))
 
        (when (member "--repl" args)
          (start-repl))
@@ -512,6 +513,49 @@ upon error."
          (unless (pre-mount)
            (error "pre-mount actions failed")))
 
+       ;;
+       ;; Attempt to resume from hibernation.
+       ;;
+       ;; IMPORTANT: This *must* happen before we mount any filesystems on
+       ;; disk.  Quoting linux-libre/Documentation/swsusp.txt:
+       ;; 
+       ;; * 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]
+       ;; *
+       (when (and resume-device
+                  (file-exists? resume-device)
+                  (file-exists? "/sys/power/resume"))
+         (false-if-exception
+          (let* ((device-base-name
+                  ;; The base name of the device file, after resolving
+                  ;; symlinks.
+                  (let loop ((file resume-device))
+                    (match (stat:type (lstat file))
+                      ('symlink
+                       (let ((target (readlink file)))
+                         (if (string-prefix? "/" target)
+                             (loop target)
+                             (loop (string-append (dirname file) "/" target)))))
+                      (_ (basename file)))))
+                 (major+minor
+                  ;; The major:minor string (e.g. "8:2") corresponding
+                  ;; to the resume device.
+                  (call-with-input-file (string-append "/sys/class/block/"
+                                                       device-base-name
+                                                       "/dev")
+                    read-line)))
+            ;; Write the major:minor string to /sys/power/resume
+            ;; to attempt resume from hibernation.
+            (when major+minor
+              (call-with-output-file "/sys/power/resume"
+                (cut display major+minor <>))))))
+
        (setenv "EXT2FS_NO_MTAB_OK" "1")
 
        (if root
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index a32756e040..93ad9cbc82 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -595,11 +595,7 @@ include the @command{udisksctl} command, part of UDisks, and GNOME Disks."
   (handle-suspend-key              elogind-handle-suspend-key
                                    (default 'suspend))
   (handle-hibernate-key            elogind-handle-hibernate-key
-                                   ;; (default 'hibernate)
-                                   ;; XXX Ignore it for now, since we don't
-                                   ;; yet handle resume-from-hibernation in
-                                   ;; our initrd.
-                                   (default 'ignore))
+                                   (default 'hibernate))
   (handle-lid-switch               elogind-handle-lid-switch
                                    (default 'suspend))
   (handle-lid-switch-docked        elogind-handle-lid-switch-docked
-- 
2.23.0


Information forwarded to bug-guix <at> gnu.org:
bug#37290; Package guix. (Tue, 03 Sep 2019 14:40:04 GMT) Full text and rfc822 format available.

Message #11 received at 37290 <at> debbugs.gnu.org (full text, mbox):

From: Nolan Wright <nolan.wright.other <at> gmail.com>
To: Mark H Weaver <mhw <at> netris.org>
Cc: 37290 <at> debbugs.gnu.org
Subject: Re: bug#37290: Guix System: Hibernation
Date: Tue, 3 Sep 2019 08:36:46 -0400
[Message part 1 (text/plain, inline)]
Hello Mark,

Thank you for that patch. I will test it out when I get a chance. I fully
support your efforts in this area and would like to see this added to the
operating-system configuration as you have described.

Best,
Nolan

On Mon, Sep 2, 2019 at 11:25 PM Mark H Weaver <mhw <at> netris.org> wrote:

> Hi Nolan,
>
> Nolan Wright <nolan.wright.other <at> gmail.com> writes:
>
> > I have a desktop computer that sits in the same room where I
> > sleep. The fans produce a noise that I would prefer not to hear when
> > going to bed. For that reason, I wish to make use of the hibernation
> > feature, in which the system state is suspended to disk as described
> > here:
> >
> >
> https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate
> >
> > The IRC user nxck, who was very helpful, after some brief
> > experimentation concluded that Guix System probably does not support
> > the hibernation feature. Indeed the following comment in the source
> > code suggests as much:
> >
> >
> http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/desktop.scm#n598
> >
> > Additionally I found the following message in this mailing list from
> > three years ago which stated that the feature is not supported:
> >
> > https://lists.gnu.org/archive/html/bug-guix/2016-11/msg00067.html
>
> The message above links to an earlier message with my preliminary patch
> to support hibernation:
>
>   https://lists.gnu.org/archive/html/guix-devel/2016-08/msg00962.html
>
> I've been carrying that patch in my local branch of Guix for 3 years.
> It needs a bit more work before it's ready to include in Guix, and I'm
> sorry to say that I lost motivation to work on it because it seems that
> almost no one cares about hibernation today.
>
> Anyway, I've attached below a slightly updated version of the patch that
> applies cleanly to current Guix.  Quoting from the message above:
>
> you'll also need to add a line like this to your 'operating-system'
> definition.
>
>   (kernel-arguments '("resume=/dev/sda2"))
>
> Where the device named is a swap partition.
>
> WARNING: Since this is preliminary work, I recommend that the first time
> you test this, be prepared for the possibility that resume will fail.
> So far I've only tested it with simple partitions, without encryption or
> RAID.
>
> It may be that we should add a dedicated 'resume-device' field to the
> 'operating-system'.  Thoughts?
>
>       Mark
>
>
>
[Message part 2 (text/html, inline)]

Reply sent to Tobias Geerinckx-Rice <me <at> tobias.gr>:
You have taken responsibility. (Sun, 09 May 2021 19:35:02 GMT) Full text and rfc822 format available.

Notification sent to Nolan Wright <nolan.wright.other <at> gmail.com>:
bug acknowledged by developer. (Sun, 09 May 2021 19:35:02 GMT) Full text and rfc822 format available.

Message #16 received at 37290-done <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: 37290-done <at> debbugs.gnu.org, 40927-done <at> debbugs.gnu.org
Subject: Close hibernation bugs
Date: Sun, 09 May 2021 21:34:51 +0200
[Message part 1 (text/plain, inline)]
Hibernation has been supported on Guix Systems for a very long 
time now.

I'm not aware of any, but any failures to hibernate are probably 
configuration or hardware-specific and should be reported as new 
bugs.

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 07 Jun 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 295 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.