From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:49069) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6EeV-0006pC-4P for guix-patches@gnu.org; Mon, 24 Feb 2020 09:24:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6EeQ-0007Pd-Dl for guix-patches@gnu.org; Mon, 24 Feb 2020 09:24:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:47062) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6EeQ-0007PZ-8y for guix-patches@gnu.org; Mon, 24 Feb 2020 09:24:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j6EeQ-0003Mp-4H for guix-patches@gnu.org; Mon, 24 Feb 2020 09:24:02 -0500 Subject: [bug#37305] [PATCH V3] Allow booting from a Btrfs subvolume. Resent-Message-ID: From: Maxim Cournoyer References: <87sgpby4p9.fsf@gmail.com> <87y2yg3t3s.fsf@gnu.org> <87k14sfaz7.fsf@gmail.com> <87lfp6b5cs.fsf_-_@gmail.com> <8736bdf5il.fsf@gnu.org> Date: Mon, 24 Feb 2020 09:23:18 -0500 In-Reply-To: <8736bdf5il.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 14 Feb 2020 18:22:26 +0100") Message-ID: <871rqkf4ix.fsf_-_@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 37305@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain I've added a `normalize-file' procedure to the attached patch, which simplify producing correct store references in the GRUB configuration file generated. This fixed the GRUB video mode issues reported in a another issue. Thanks! Maxim --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-bootloader-grub-Allow-booting-from-a-Btrfs-subvolume.patch Content-Transfer-Encoding: quoted-printable From=201c0aafd5d0e013387a8f9bede3c42622b85957c5 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 14 Jul 2019 20:50:23 +0900 Subject: [PATCH] bootloader: grub: Allow booting from a Btrfs subvolume. * gnu/bootloader/grub.scm (strip-mount-point): Remove procedure. (normalize-file): Add procedure. (grub-configuration-file): New BTRFS-SUBVOLUME-FILE-NAME parameter. When defined, prepend its value to the kernel and initrd file names, using the NORMALIZE-FILE procedure. Adjust the call to EYE-CANDY to pass the BTRFS-SUBVOLUME-FILE-NAME argument. Normalize the KEYMAP file as well. (eye-candy): Add a BTRFS-SUBVOLUME-FILE-NAME parameter, and use it, along w= ith the NORMALIZE-FILE procedure, to normalize the FONT-FILE and IMAGE nested variables. Adjust doc. * gnu/bootloader/depthcharge.scm (depthcharge-configuration-file): Adapt. * gnu/bootloader/extlinux.scm (extlinux-configuration-file): Likewise. * gnu/system/file-systems.scm (btrfs-subvolume?) (btrfs-store-subvolume-file-name): New procedures. * gnu/system.scm (operating-system-bootcfg): Specify the Btrfs subvolume file name the store resides on to the `operating-system-bootcfg' procedure, using the new BTRFS-SUBVOLUME-FILE-NAME argument. * doc/guix.texi (File Systems): Add a Btrfs subsection to document the use = of subvolumes. Document the new `properties' field of the `' record. * gnu/tests/install.scm: Add test "btrfs-root-on-subvolume-os". =2D-- doc/guix.texi | 114 ++++++++++++++++++++++++++++++ gnu/bootloader/depthcharge.scm | 3 +- gnu/bootloader/extlinux.scm | 3 +- gnu/bootloader/grub.scm | 123 +++++++++++++++++++++------------ gnu/system.scm | 9 ++- gnu/system/file-systems.scm | 58 ++++++++++++++++ gnu/tests/install.scm | 96 +++++++++++++++++++++++++ 7 files changed, 356 insertions(+), 50 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index d6bfbd7b55..f0956f965a 100644 =2D-- a/doc/guix.texi +++ b/doc/guix.texi @@ -11442,6 +11442,13 @@ a dependency of @file{/sys/fs/cgroup/cpu} and =20 Another example is a file system that depends on a mapped device, for example for an encrypted partition (@pxref{Mapped Devices}). + +@item @code{properties} (default: @code{'()}) +This is a list of key-value pairs that can be used to specify properties +not captured by other fields. For example, the top level path of a +Btrfs subvolume within its Btrfs pool can be specified using the +@code{btrfs-subvolume-path} property (@pxref{Btrfs file system}). + @end table @end deftp =20 @@ -11491,6 +11498,113 @@ and unmount user-space FUSE file systems. This r= equires the @code{fuse.ko} kernel module to be loaded. @end defvr =20 +@node Btrfs file system +@subsection Btrfs file system + +The Btrfs has special features, such as subvolumes, that merit being +explained in more details. The following section attempts to cover +basic as well as complex uses of a Btrfs file system with the Guix +System. + +In its simplest usage, a Btrfs file system can be described, for +example, by: + +@lisp +(file-system + (mount-point "/home") + (type "btrfs") + (device (file-system-label "my-home"))) +@end lisp + +The example below is more complex, as it makes use of a Btrfs +subvolume, named @code{rootfs}. The parent Btrfs file system is labeled +@code{my-btrfs-pool}, and is located on an encrypted device (hence the +dependency on @code{mapped-devices}): + +@example +(file-system + (device (file-system-label "my-btrfs-pool")) + (mount-point "/") + (type "btrfs") + (options '("defaults" ("subvol" . "rootfs")) + (dependencies mapped-devices)) +@end example + +Some bootloaders, for example GRUB, only mount a Btrfs partition at its +top level during the early boot, and rely on their configuration to +refer to the correct subvolume path within that top level. The +bootloaders operating in this way typically produce their configuration +on a running system where the Btrfs partitions are already mounted and +where the subvolume information is readily available. As an example, +@command{grub-mkconfig}, the configuration generator command shipped +with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level +path of a subvolume. + +The Guix System produces a bootloader configuration using the operating +system configuration as its sole input; it is therefore necessary to +extract the subvolume name on which @file{/gnu/store} lives (if any) +from that operating system configuration. To better illustrate, +consider a subvolume named 'rootfs' which contains the root file system +data. In such situation, the GRUB bootloader would only see the top +level of the root Btrfs partition, e.g.: + +@example +/ (top level) +=E2=94=9C=E2=94=80=E2=94=80 rootfs (subvolume directory) + =E2=94=9C=E2=94=80=E2=94=80 gnu (normal directory) + =E2=94=9C=E2=94=80=E2=94=80 store (normal directory) +[...] +@end example + +Thus, the subvolume name must be prepended to the @file{/gnu/store} path +of the kernel and initrd binaries in the GRUB configuration in order for +those to be found. + +The next example shows a nested hierarchy of subvolumes and +directories: + +@example +/ (top level) +=E2=94=9C=E2=94=80=E2=94=80 rootfs (subvolume) + =E2=94=9C=E2=94=80=E2=94=80 gnu (normal directory) + =E2=94=9C=E2=94=80=E2=94=80 store (subvolume) +[...] +@end example + +This scenario would work without mounting the 'store' subvolume. +Mounting 'rootfs' is sufficient, since the subvolume name matches its +intended mount point in the file system hierarchy. + +Finally, a more contrived example of nested subvolumes: + +@example +/ (top level) +=E2=94=9C=E2=94=80=E2=94=80 root-snapshots (subvolume) + =E2=94=9C=E2=94=80=E2=94=80 root-current (subvolume) + =E2=94=9C=E2=94=80=E2=94=80 guix-store (subvolume) +[...] +@end example + +Here, the 'guix-store' module name doesn't match its intended mount +point, so it is necessary to mount it. The layout cannot simply be +described by the record, so it is required to specify the +exact path at which the subvolume exists within the top level of its +parent file system. This can be achieved by attaching a +@code{btrfs-subvolume-path} property to the corresponding file system +record: + +@lisp +(file-system + ... + (properties '((btrfs-subvolume-path + . "/root-snapshots/root-current/guix-store")))) +@end lisp + +The default behavior of Guix is to assume that a subvolume exists +directly at the root of the top volume hierarchy. When this is not the +case, the above property must be used for the system to boot correctly +when using a GRUB based bootloader. + @node Mapped Devices @section Mapped Devices =20 diff --git a/gnu/bootloader/depthcharge.scm b/gnu/bootloader/depthcharge.scm index 58cc3f3932..0a50374bd9 100644 =2D-- a/gnu/bootloader/depthcharge.scm +++ b/gnu/bootloader/depthcharge.scm @@ -82,7 +82,8 @@ (define* (depthcharge-configuration-file config entries #:key (system (%current-system)) =2D (old-entries '())) + (old-entries '()) + #:allow-other-keys) (match entries ((entry) (let ((kernel (menu-entry-linux entry)) diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm index 5b4dd84965..6b5ff298e7 100644 =2D-- a/gnu/bootloader/extlinux.scm +++ b/gnu/bootloader/extlinux.scm @@ -28,7 +28,8 @@ (define* (extlinux-configuration-file config entries #:key (system (%current-system)) =2D (old-entries '())) + (old-entries '()) + #:allow-other-keys) "Return the U-Boot configuration file corresponding to CONFIG, a object, and where the store is available at STORE-F= S, a object. OLD-ENTRIES is taken to be a list of menu entries diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index b99f5fa4f4..99cb42c4a2 100644 =2D-- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -4,6 +4,7 @@ ;;; Copyright =C2=A9 2017 Leo Famulari ;;; Copyright =C2=A9 2017 Mathieu Othacehe ;;; Copyright =C2=A9 2019 Jan (janneke) Nieuwenhuizen +;;; Copyright =C2=A9 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -61,18 +62,29 @@ ;;; ;;; Code: =20 =2D(define (strip-mount-point mount-point file) =2D "Strip MOUNT-POINT from FILE, which is a gexp or other lowerable object =2Ddenoting a file name." =2D (match mount-point =2D ((? string? mount-point) =2D (if (string=3D? mount-point "/") =2D file =2D #~(let ((file #$file)) =2D (if (string-prefix? #$mount-point file) =2D (substring #$file #$(string-length mount-point)) =2D file)))) =2D (#f file))) +(define* (normalize-file file mount-point btrfs-subvolume-file-name) + "Strip MOUNT-POINT and prepend BTRFS-SUBVOLUME-FILE-NAME to FILE, a +G-expression or other lowerable object denoting a file name." + + (define (strip-mount-point mount-point file) + (if mount-point + (if (string=3D? mount-point "/") + file + #~(let ((file #$file)) + (if (string-prefix? #$mount-point file) + (substring #$file #$(string-length mount-point)) + file))) + file)) + + (define (prepend-btrfs-subvolume-file-name btrfs-subvolume-file-name fil= e) + (if btrfs-subvolume-file-name + #~(string-append #$btrfs-subvolume-file-name #$file) + file)) + + (prepend-btrfs-subvolume-file-name btrfs-subvolume-file-name + (strip-mount-point mount-point file))) + + =20 (define-record-type* grub-image make-grub-image @@ -140,13 +152,15 @@ WIDTH/HEIGHT, or #f if none was found." #:width width #:height height)))) =20 (define* (eye-candy config store-device store-mount-point + btrfs-store-subvolume-file-name #:key system port) =2D "Return a gexp that writes to PORT (a port-valued gexp) the =2D'grub.cfg' part concerned with graphics mode, background images, colors,= and =2Dall that. STORE-DEVICE designates the device holding the store, and =2DSTORE-MOUNT-POINT is its mount point; these are used to determine where = the =2Dbackground image and fonts must be searched for. SYSTEM must be the tar= get =2Dsystem string---e.g., \"x86_64-linux\"." + "Return a gexp that writes to PORT (a port-valued gexp) the 'grub.cfg' p= art +concerned with graphics mode, background images, colors, and all that. +STORE-DEVICE designates the device holding the store, and STORE-MOUNT-POIN= T is +its mount point; these are used to determine where the background image and +fonts must be searched for. SYSTEM must be the target system string---e.g= ., +\"x86_64-linux\". BTRFS-STORE-SUBVOLUME-FILE-NAME is the file name of the +Btrfs subvolume, to be prefixed to any store path, if any." (define setup-gfxterm-body ;; Intel and EFI systems need to be switched into graphics mode, where= as ;; most other modern architectures have no other mode and therefore do= n't @@ -194,11 +208,14 @@ fi~%" #$font-file) (symbol->string (assoc-ref colors 'bg))))) =20 (define font-file =2D (strip-mount-point store-mount-point =2D (file-append grub "/share/grub/unicode.pf2"))) + (normalize-file (file-append grub "/share/grub/unicode.pf2") + store-mount-point + btrfs-store-subvolume-file-name)) =20 (define image =2D (grub-background-image config)) + (normalize-file (grub-background-image config) + store-mount-point + btrfs-store-subvolume-file-name)) =20 (and image #~(format #$port " @@ -223,7 +240,7 @@ fi~%" #$(setup-gfxterm config font-file) #$(grub-setup-io config) =20 =2D #$(strip-mount-point store-mount-point image) + #$image #$(theme-colors grub-theme-color-normal) #$(theme-colors grub-theme-color-highlight)))) =20 @@ -327,52 +344,66 @@ code." (define* (grub-configuration-file config entries #:key (system (%current-system)) =2D (old-entries '())) + (old-entries '()) + btrfs-subvolume-file-name) "Return the GRUB configuration file corresponding to CONFIG, a object, and where the store is available at =2DSTORE-FS, a object. OLD-ENTRIES is taken to be a list of = menu =2Dentries corresponding to old generations of the system." +STORE-FS, a object. OLD-ENTRIES is taken to be a list +of menu entries corresponding to old generations of the system. +BTRFS-SUBVOLUME-FILE-NAME may be used to specify on which subvolume a +Btrfs root file system resides." (define all-entries (append entries (bootloader-configuration-menu-entries config))) (define (menu-entry->gexp entry) =2D (let ((device (menu-entry-device entry)) =2D (device-mount-point (menu-entry-device-mount-point entry)) =2D (label (menu-entry-label entry)) =2D (kernel (menu-entry-linux entry)) =2D (arguments (menu-entry-linux-arguments entry)) =2D (initrd (menu-entry-initrd entry))) + (let* ((device (menu-entry-device entry)) + (device-mount-point (menu-entry-device-mount-point entry)) + (label (menu-entry-label entry)) + (arguments (menu-entry-linux-arguments entry)) + (kernel (normalize-file (menu-entry-linux entry) + device-mount-point + btrfs-subvolume-file-name)) + (initrd (normalize-file (menu-entry-initrd entry) + device-mount-point + btrfs-subvolume-file-name))) ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount poin= t. ;; Use the right file names for KERNEL and INITRD in case ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a ;; separate partition. =2D (let ((kernel (strip-mount-point device-mount-point kernel)) =2D (initrd (strip-mount-point device-mount-point initrd))) =2D #~(format port "menuentry ~s { + + ;; When BTRFS-SUBVOLUME-FILE-NAME is defined, prepend it the kernel = and + ;; initrd paths, to allow booting from a Btrfs subvolume. + #~(format port "menuentry ~s { ~a linux ~a ~a initrd ~a }~%" =2D #$label =2D #$(grub-root-search device kernel) =2D #$kernel (string-join (list #$@arguments)) =2D #$initrd)))) + #$label + #$(grub-root-search device kernel) + #$kernel (string-join (list #$@arguments)) + #$initrd))) (define sugar (eye-candy config (menu-entry-device (first all-entries)) (menu-entry-device-mount-point (first all-entries)) + btrfs-subvolume-file-name #:system system #:port #~port)) =20 (define keyboard-layout-config =2D (let ((layout (bootloader-configuration-keyboard-layout config)) =2D (grub (bootloader-package =2D (bootloader-configuration-bootloader config)))) =2D #~(let ((keymap #$(and layout =2D (keyboard-layout-file layout #:grub grub)))) =2D (when keymap =2D (format port "\ + (let* ((layout (bootloader-configuration-keyboard-layout config)) + (grub (bootloader-package + (bootloader-configuration-bootloader config))) + (keymap* (and layout + (keyboard-layout-file layout #:grub grub))) + (keymap (and keymap* + (if btrfs-subvolume-file-name + #~(string-append #$btrfs-subvolume-file-name + #$keymap*) + keymap*)))) + #~(when #$keymap + (format port "\ insmod keylayouts =2Dkeymap ~a~%" keymap))))) +keymap ~a~%" #$keymap)))) =20 (define builder #~(call-with-output-file #$output diff --git a/gnu/system.scm b/gnu/system.scm index 2e6d03272d..59c3526098 100644 =2D-- a/gnu/system.scm +++ b/gnu/system.scm @@ -5,6 +5,7 @@ ;;; Copyright =C2=A9 2016 Chris Marusich ;;; Copyright =C2=A9 2017 Mathieu Othacehe ;;; Copyright =C2=A9 2019 Meiyo Peng +;;; Copyright =C2=A9 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -992,19 +993,23 @@ entry." (define* (operating-system-bootcfg os #:optional (old-entries '())) "Return the bootloader configuration file for OS. Use OLD-ENTRIES, a list of , to populate the \"old entries\" menu." =2D (let* ((root-fs (operating-system-root-file-system os)) + (let* ((file-systems (operating-system-file-systems os)) + (root-fs (operating-system-root-file-system os)) (root-device (file-system-device root-fs)) (params (operating-system-boot-parameters os root-device #:system-kernel-arguments? #t)) (entry (boot-parameters->menu-entry params)) (bootloader-conf (operating-system-bootloader os))) + (define generate-config-file (bootloader-configuration-file-generator (bootloader-configuration-bootloader bootloader-conf))) =20 (generate-config-file bootloader-conf (list entry) =2D #:old-entries old-entries))) + #:old-entries old-entries + #:btrfs-subvolume-file-name + (btrfs-store-subvolume-file-name file-systems)))) =20 (define* (operating-system-boot-parameters os root-device #:key system-kernel-arguments?) diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index 4f0c5ad99e..7b78731524 100644 =2D-- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -21,7 +21,10 @@ #:use-module (ice-9 match) #:use-module (rnrs bytevectors) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-2) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-26) + #:use-module (srfi srfi-35) #:use-module (srfi srfi-9 gnu) #:use-module (guix records) #:use-module (gnu system uuid) @@ -44,9 +47,12 @@ file-system-create-mount-point? file-system-dependencies file-system-location + file-system-properties =20 file-system-type-predicate file-system-independent-mount-option? + btrfs-subvolume? + btrfs-store-subvolume-file-name =20 file-system-label file-system-label? @@ -112,6 +118,8 @@ (default #f)) (dependencies file-system-dependencies ; list of (default '())) ; or + (properties file-system-properties ; list of name-value pai= rs + (default '())) (location file-system-location (default (current-source-location)) (innate))) @@ -584,4 +592,54 @@ system has the given TYPE." (or (string-prefix-ci? "x-" option-name) (member option-name %file-system-independent-mount-options)))) =20 +(define (btrfs-subvolume? fs) + "Predicate to check if FS, a file-system object, is a Btrfs subvolume." + (and-let* ((btrfs-file-system? (string=3D "btrfs" (file-system-type fs))) + (option-keys (map (match-lambda + ((key . value) key) + (key key)) + (file-system-options fs)))) + (find (cut string-prefix? "subvol" <>) option-keys))) + +(define (btrfs-store-subvolume-file-name file-systems) + "Return the subvolume file name within the Btrfs top level onto +which the store is located. When the BTRFS-SUBVOLUME-FILE-NAME file +system property is not set, it is assumed that the store subvolume +file name is located at the root of the top level of the file system." + + (define (find-mount-point-fs mount-point file-systems) + (find (lambda (fs) + (string=3D mount-point (file-system-mount-point fs))) + file-systems)) + + ;; Find a subvolume mounted at either /gnu/store, /gnu, or /. + (let loop ((mount-point (%store-prefix))) + (let ((mount-point-fs (find-mount-point-fs mount-point file-systems))) + (cond + ((string-null? mount-point) + #f) ;store is not on a Btrfs subvolume + ((and=3D> mount-point-fs btrfs-subvolume?) + (let* ((fs-options (file-system-options mount-point-fs)) + (subvolid (assoc-ref fs-options "subvolid")) + (subvol (assoc-ref fs-options "subvol"))) + (or (assoc-ref (file-system-properties mount-point-fs) + "btrfs-subvolume-file-name") + (and=3D> subvol (cut string-append "/" <>)) + ;; XXX: Importing (guix utils) and using &fix-hint causes the + ;; following error when booting the init RAM disk: "ERROR: In + ;; procedure dynamic-func:\nIn procedure dynamic-pointer: Sy= mbol + ;; not found: strverscmp", so we just embed the hint in the + ;; message. + (raise (condition + (&message + (message "The store is on a Btrfs subvolume, but the \ +subvolume name is unknown.\nHint: Define the \"btrfs-subvolume-file-name\"= \ +file system property or use the \"subvol\" Btrfs file system"))))))) + (else + (loop + (cond ((string-suffix? "/" mount-point) + (string-drop-right mount-point 1)) + ((string-take mount-point + (1+ (string-index-right mount-point #\/))))))= ))))) + ;;; file-systems.scm ends here diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index d475bda2c7..82e2b46e3e 100644 =2D-- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -44,6 +44,7 @@ %test-raid-root-os %test-encrypted-root-os %test-btrfs-root-os + %test-btrfs-root-on-subvolume-os %test-jfs-root-os)) =20 ;;; Commentary: @@ -811,6 +812,101 @@ build (current-guix) and then store a couple of full = system images.") (command (qemu-command/writable-image image))) (run-basic-test %btrfs-root-os command "btrfs-root-os"))))) =20 + +;;; +;;; Btrfs root file system on a subvolume. +;;; + +(define-os-with-source (%btrfs-root-on-subvolume-os + %btrfs-root-on-subvolume-os-source) + ;; The OS we want to install. + (use-modules (gnu) (gnu tests) (srfi srfi-1)) + + (operating-system + (host-name "hurd") + (timezone "America/Montreal") + (locale "en_US.UTF-8") + (bootloader (bootloader-configuration + (bootloader grub-bootloader) + (target "/dev/vdb"))) + (kernel-arguments '("console=3DttyS0")) + (file-systems (cons* (file-system + (device (file-system-label "btrfs-pool")) + (mount-point "/") + (options '(("subvol" . "rootfs") + ("compress" . "zstd"))) + (type "btrfs")) + (file-system + (device (file-system-label "btrfs-pool")) + (mount-point "/home") + (options '(("subvol" . "homefs") + ("compress" . "lzo"))) + (type "btrfs")) + %base-file-systems)) + (users (cons (user-account + (name "charlie") + (group "users") + (supplementary-groups '("wheel" "audio" "video"))) + %base-user-accounts)) + (services (cons (service marionette-service-type + (marionette-configuration + (imported-modules '((gnu services herd) + (guix combinators))))) + %base-services)))) + +(define %btrfs-root-on-subvolume-installation-script + ;; Shell script of a simple installation. + "\ +. /etc/profile +set -e -x +guix --version + +export GUIX_BUILD_OPTIONS=3D--no-grafts +ls -l /run/current-system/gc-roots +parted --script /dev/vdb mklabel gpt \\ + mkpart primary ext2 1M 3M \\ + mkpart primary ext2 3M 2G \\ + set 1 boot on \\ + set 1 bios_grub on + +# Setup the top level Btrfs file system with its subvolume. +mkfs.btrfs -L btrfs-pool /dev/vdb2 +mount /dev/vdb2 /mnt +btrfs subvolume create /mnt/rootfs +btrfs subvolume create /mnt/homefs +umount /dev/vdb2 + +# Mount the subvolumes, ready for installation. +mount LABEL=3Dbtrfs-pool -o 'subvol=3Drootfs,compress=3Dzstd' /mnt +mkdir /mnt/home +mount LABEL=3Dbtrfs-pool -o 'subvol=3Dhomefs,compress=3Dzstd' /mnt/home + +herd start cow-store /mnt +mkdir /mnt/etc +cp /etc/target-config.scm /mnt/etc/config.scm +guix system build /mnt/etc/config.scm +guix system init /mnt/etc/config.scm /mnt --no-substitutes +sync +reboot\n") + +(define %test-btrfs-root-on-subvolume-os + (system-test + (name "btrfs-root-on-subvolume-os") + (description + "Test basic functionality of an OS installed like one would do by hand. +This test is expensive in terms of CPU and storage usage since we need to +build (current-guix) and then store a couple of full system images.") + (value + (mlet* %store-monad + ((image + (run-install %btrfs-root-on-subvolume-os + %btrfs-root-on-subvolume-os-source + #:script + %btrfs-root-on-subvolume-installation-script)) + (command (qemu-command/writable-image image))) + (run-basic-test %btrfs-root-on-subvolume-os command + "btrfs-root-on-subvolume-os"))))) + ;;; ;;; JFS root file system. =2D-=20 2.25.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEJ9WGpPiQCFQyn/CfEmDkZILmNWIFAl5T3FYACgkQEmDkZILm NWIFGw/9HAUn9ZQml2lUXmMGFGPKJJpvPKQIgKSxmOk8w/1SmTmKCCrEF10kCQsV rrhz/rifZXI7M24zmGJX6N0yqdbbj3EdyKvqPoGANUtEfj2Pz3AFph3DLgFGMJ5D Sj8O4xJVlQ1V6TAeSmtRXwZeOQ3n6yGFxypoeDmHRgVyT+MV/uC3bYV64s1kLgWM petBRUAvoipU9q8Jw/uXvySMUTbZXr7+MPYWQcC67JxjhU2SnrJhmJxCb7Wi8kQm NFiWkOv9Ou1x2a552NjLyMW1dqsJJDbHfepdv8MfVo+cYAukB8FzdfzMZT1V4WkL vCKiSNdRZlF8+jp61F1UC2hD1DVaMkDofd1yFlzboIE6q+IVILzDzDm4u0ThoAcg 5n6HAIDKRiQBc/5iXKlzQfABRSGaMlNxYgVUnMqkONGFp6JyAAgOpwiZTjmHjxIz 5nxzgikGSFyT5wNiTZcR6pBSiSGHuCTdYAdtpmoog0QWuhkv6K4TllgdURlp8vfO QJZAQd+MsX58AE8U0UVBYb3MmY6pM7Y722J5Khpr9+OxLCuECF+83h/k0GmVazdf h6aC9P4S+d8+/RbjwygASCC4ngJur4xWVLGJZlZoeIVEazYv1bTVlwjPzaLg2/f7 zZR++xezmszteLZ1M13JZpP4WCC8zkTPxATyhk+an14QTOlyAHQ= =Op9E -----END PGP SIGNATURE----- --==-=-=--