GNU bug report logs - #59746
[DOCUMENTATION] [PATCH] doc: Introduce using Swap Space for hibernation, with an example.

Previous Next

Package: guix-patches;

Reported by: Ivan Vilata i Balaguer <ivan <at> selidor.net>

Date: Thu, 1 Dec 2022 17:18:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

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 59746 in the body.
You can then email your comments to 59746 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 guix-patches <at> gnu.org:
bug#59746; Package guix-patches. (Thu, 01 Dec 2022 17:18:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ivan Vilata i Balaguer <ivan <at> selidor.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 01 Dec 2022 17:18:01 GMT) Full text and rfc822 format available.

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

From: Ivan Vilata i Balaguer <ivan <at> selidor.net>
To: guix-patches <at> gnu.org
Subject: [DOCUMENTATION] [PATCH] doc: Introduce using Swap Space for
 hibernation, with an example.
Date: Thu, 1 Dec 2022 18:17:08 +0100
[Message part 1 (text/plain, inline)]
* doc/guix.texi (Swap Space): Add a concise introduction to hibernation and
specifying a swap space to the kernel to make resume work.  Mention space
requirements and the need of an offset for swap files (missing info on how to
obtain it, but at least hint on the needed kernel argument).  Include a
trivial example on how to set up swap space for hibernation.
---
 doc/guix.texi | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 47b805dc7f..76441fd4db 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -109,6 +109,7 @@
 Copyright @copyright{} 2022 Simon Streit@*
 Copyright @copyright{} 2022 (@*
 Copyright @copyright{} 2022 John Kehayias@*
+Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -17072,6 +17073,14 @@ Swap Space
 allocated at disk formatting time (logical volumes notwithstanding),
 whereas files can be allocated and deallocated at any time.
 
+Also, a swap space is required in order to hibernate (suspend to disk) a
+system using the Linux kernel.  The kernel needs to know about the swap
+space to be used to resume from hibernation on boot (via a kernel
+argument).  When using a swap file, its offset in the device holding it
+also needs to be given to the kernel, but that value has to be updated
+if the file is recreated.  Hibernation uses at most half the size of the
+RAM in the configured swap space.
+
 Note that swap space is not zeroed on shutdown, so sensitive data (such
 as passwords) may linger on it if it was paged out.  As such, you should
 consider having your swap reside on an encrypted device (@pxref{Mapped
@@ -17157,6 +17166,23 @@ Swap Space
 file system mounted at @file{/btrfs}.  Note how we use Guile's filter to
 select the file system in an elegant fashion!
 
+@lisp
+(swap-devices
+  (list (swap-space
+          (target "/dev/mapper/my-swap")
+          (dependencies mapped-devices))))
+
+(kernel-arguments
+  (cons* "resume=/dev/mapper/my-swap"
+         %default-kernel-arguments))
+@end lisp
+
+Use the mapped device @file{/dev/mapper/my-swap} as swap space, and tell
+the kernel to use it for hibernation via the @code{resume} kernel
+argument (@pxref{operating-system Reference}, @code{kernel-arguments}).
+If a swap file was used, the @code{resume_offset} argument would also be
+needed.
+
 @node User Accounts
 @section User Accounts
 

base-commit: 5e03354ef535ab1e548f444ac0af0b645a4081de
-- 
2.38.1


-- 
Ivan Vilata i Balaguer -- https://elvil.net/
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#59746; Package guix-patches. (Wed, 21 Dec 2022 12:18:01 GMT) Full text and rfc822 format available.

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

From: Ivan Vilata i Balaguer <ivan <at> selidor.net>
To: 59746 <at> debbugs.gnu.org
Subject: Re: [DOCUMENTATION] [PATCH] doc: Introduce using Swap Space for
 hibernation, with an example.
Date: Wed, 21 Dec 2022 13:16:59 +0100
[Message part 1 (text/plain, inline)]
This patch replaces the previous one and enhances it with several minor fixes
and the missing information related to computing the swap file offset, as
discussed [in the guix-devel thread][1].

[1]: https://lists.gnu.org/archive/html/guix-devel/2022-12/msg00028.html

Thanks and cheers!

-- 
Ivan Vilata i Balaguer -- https://elvil.net/
[0001-doc-Introduce-using-swap-space-for-hibernation-with-.patch (text/plain, attachment)]
[signature.asc (application/pgp-signature, inline)]

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Thu, 05 Jan 2023 22:02:02 GMT) Full text and rfc822 format available.

Notification sent to Ivan Vilata i Balaguer <ivan <at> selidor.net>:
bug acknowledged by developer. (Thu, 05 Jan 2023 22:02:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Ivan Vilata i Balaguer <ivan <at> selidor.net>
Cc: 59746-done <at> debbugs.gnu.org
Subject: Re: bug#59746: [DOCUMENTATION] [PATCH] doc: Introduce using Swap
 Space for hibernation, with an example.
Date: Thu, 05 Jan 2023 23:01:07 +0100
[Message part 1 (text/plain, inline)]
Hi,

Ivan Vilata i Balaguer <ivan <at> selidor.net> skribis:

> This patch replaces the previous one and enhances it with several minor fixes
> and the missing information related to computing the swap file offset, as
> discussed [in the guix-devel thread][1].
>
> [1]: https://lists.gnu.org/archive/html/guix-devel/2022-12/msg00028.html
>
> Thanks and cheers!
>
> -- 
> Ivan Vilata i Balaguer -- https://elvil.net/
>
> From e95d79ef8c466e495c730f722b7aefc4d2d5969f Mon Sep 17 00:00:00 2001
> From: Ivan Vilata-i-Balaguer <ivan <at> selidor.net>
> Date: Wed, 21 Dec 2022 13:08:48 +0100
> Subject: [PATCH] doc: Introduce using swap space for hibernation, with
>  examples.
>
> * doc/guix.texi (Swap Space): Add a concise introduction to hibernation and
> specifying a swap space to the kernel to make resume work.  Mention space
> requirements and the need of an offset for swap files.  Include a trivial
> example on how to set up a mapped swap volume for hibernation and another one
> for a swap file, including how to compute the file offset.

Very nice!  Applied with the tweaks below.

Thanks,
Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/doc/guix.texi b/doc/guix.texi
index 9a74ae64d6..293c3016aa 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17109,14 +17109,18 @@ should consider ease of use when deciding between them.  Partitions are
 allocated at disk formatting time (logical volumes notwithstanding),
 whereas files can be allocated and deallocated at any time.
 
-A swap space is also required in order to hibernate a system using the
-Linux kernel.  Hibernation (also called suspend to disk) uses at most
-half the size of the RAM in the configured swap space.  The kernel needs
-to know about the swap space to be used to resume from hibernation on
-boot (via a kernel argument).  When using a swap file, its offset in the
-device holding it also needs to be given to the kernel, but that value
-has to be updated if the file is initialized again as swap (e.g. because
-its size was changed).
+@cindex hibernation
+@cindex suspend to disk
+Swap space is also required to put the system into @dfn{hibernation}
+(also called @dfn{suspend to disk}), whereby memory is dumped to swap
+before shutdown so it can be restored when the machine is eventually
+restarted.  Hibernation uses at most half the size of the RAM in the
+configured swap space.  The Linux kernel needs to know about the swap
+space to be used to resume from hibernation on boot (@i{via} a kernel
+argument).  When using a swap file, its offset in the device holding it
+also needs to be given to the kernel; that value has to be updated if
+the file is initialized again as swap---e.g., because its size was
+changed.
 
 Note that swap space is not zeroed on shutdown, so sensitive data (such
 as passwords) may linger on it if it was paged out.  As such, you should
@@ -17215,7 +17219,7 @@ select the file system in an elegant fashion!
          %default-kernel-arguments))
 @end lisp
 
-The previous snippet of an @code{operating-system} declaration enables
+The above snippet of an @code{operating-system} declaration enables
 the mapped device @file{/dev/mapper/my-swap} (which may be part of an
 encrypted device) as swap space, and tells the kernel to use it for
 hibernation via the @code{resume} kernel argument

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 03 Feb 2023 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 83 days ago.

Previous Next


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