diff mbox series

[bug#45643,3/3] gnu, guix: Support mounting legacy-mounted ZFS in operating-system form.

Message ID JQwrx0zllfKouhNkLC3SdQXURha-g0cP1d37GCcZZc_Kq1WqlDJzKYyJxBlUsMscWI9cNq6I32GJ46E2JZwZOdRJVNlWjtwrIDZQ4YAOuEU=@protonmail.com
State New
Headers show
Series Better Support for ZFS on Guix | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

raid5atemyhomework Jan. 4, 2021, 1:09 a.m. UTC
From 59c9bd5642e33962798c01f4dcf30be38ead4ab8 Mon Sep 17 00:00:00 2001
From: raid5atemyhomework <raid5atemyhomework@protonmail.com>
Date: Mon, 4 Jan 2021 08:22:01 +0800
Subject: [PATCH 3/3] gnu, guix: Support mounting legacy-mounted ZFS in
 operating-system form.

---
 doc/guix.texi              | 18 ++++++++++++++++++
 gnu/build/file-systems.scm |  2 ++
 gnu/machine/ssh.scm        |  3 +++
 gnu/services/base.scm      |  5 ++++-
 guix/scripts/system.scm    |  3 +++
 5 files changed, 30 insertions(+), 1 deletion(-)

--
2.29.2
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 4544b481b0..2909674302 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13982,6 +13982,24 @@  mount ZFS pools that have a non-@code{legacy} mountpoint. If ZFS
 finds mountable ZFS filesystems that are encrypted by passphrase, it
 will prompt for passphrases on the console.

+You should @emph{not} put ZFS datasets with a non-@code{legacy} mountpoint
+into the @code{file-systems} field of your @code{operating-sstem}. However,
+if you want to declare them in your @code{file-systems} field, you can
+set their ZFS mountpoints to @code{legacy} and add a @code{file-system}
+declaration for them, using the ZFS pool dataset name as the @code{device}
+field:
+
+@example
+zfs set mountpoint=legacy pool/filesystem
+@end example
+
+@lisp
+(file-system
+  (device "pool/filesystem")
+  (mount-point "/path/to/mountpoint")
+  (type "zfs"))
+@end lisp
+
 You can put @code{/home} on a ZFS filesystem by setting it as the
 mountpoint of some ZFS filesystem. However, ZFS will refuse to mount
 onto a non-empty directory, so if you already have an existing
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index ddf6117b67..af75aee2b6 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -828,6 +828,8 @@  containing ':/')."
      ((string-prefix? "f2fs" type) check-f2fs-file-system)
      ((string-prefix? "ntfs" type) check-ntfs-file-system)
      ((string-prefix? "nfs" type) (const 'pass))
+     ;; "ZFS doesn't need fsck."
+     ((string-prefix? "zfs" type) (const 'pass))
      (else #f)))

   (if check-procedure
diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm
index 08c653ba17..cdd8913a00 100644
--- a/gnu/machine/ssh.scm
+++ b/gnu/machine/ssh.scm
@@ -175,6 +175,9 @@  exist on the machine."
                                 %pseudo-file-system-types))
                    ;; Don't try to validate network file systems.
                    (not (string-prefix? "nfs" (file-system-type fs)))
+                   ;; Don't try to validate ZFS file systems.
+                   ;; XXX We should validate these by 'zfs status'.
+                   (not (string-prefix? "zfs" (file-system-type fs)))
                    (not (memq 'bind-mount (file-system-flags fs)))))
             (operating-system-file-systems (machine-operating-system machine))))

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index deffd49154..dcacc5b4b8 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -322,7 +322,10 @@  FILE-SYSTEM."
            (shepherd-service
             (provision (list (file-system->shepherd-service-name file-system)))
             (requirement `(root-file-system udev
-                           ,@(map dependency->shepherd-service-name dependencies)))
+                           ,@(map dependency->shepherd-service-name dependencies)
+                           ,@(if (string-prefix? "zfs" (file-system-type file-system))
+                                 '(zfs-loader)
+                                 '())))
             (documentation "Check, mount, and unmount the given file system.")
             (start #~(lambda args
                        #$(if create?
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 0dcf2b3afe..1515062ada 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -564,6 +564,9 @@  any, are available.  Raise an error if they're not."
                                 %pseudo-file-system-types))
                    ;; Don't try to validate network file systems.
                    (not (string-prefix? "nfs" (file-system-type fs)))
+                   ;; Don't try to validate ZFS file systems.
+                   ;; XXX We should validate these by 'zfs status'.
+                   (not (string-prefix? "zfs" (file-system-type fs)))
                    (not (memq 'bind-mount (file-system-flags fs)))))
             file-systems))