From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kH67MGCeIGAeJwAA0tVLHw (envelope-from ) for ; Mon, 08 Feb 2021 02:13:52 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QMK8LGCeIGBHLAAAbx9fmQ (envelope-from ) for ; Mon, 08 Feb 2021 02:13:52 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 38CBA940481 for ; Mon, 8 Feb 2021 02:13:52 +0000 (UTC) Received: from localhost ([::1]:46260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8w3j-0003g3-32 for larch@yhetil.org; Sun, 07 Feb 2021 21:13:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8w3K-0003fp-EU for guix-devel@gnu.org; Sun, 07 Feb 2021 21:13:26 -0500 Received: from mail-40138.protonmail.ch ([185.70.40.138]:13239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8w3G-0005ww-Kw for guix-devel@gnu.org; Sun, 07 Feb 2021 21:13:26 -0500 Date: Mon, 08 Feb 2021 02:13:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1612750399; bh=5ITqegREE/tc7E7bkcKjJyuIyP1i0QOQPh9NZQHU3Tk=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=SXS47iOGv2xBAhslIuwLAvY6xWMqykp5ecyagypTb39ZU5pDQTXP6AQchKYeqRSvC qTuvIk4Yezjtnf00SocdSVmZPOxzo1dCy1LCb3J31qsg6UY9lfuSHriqI73qQpjNWj MskpdTrIfE8nNjLUgJM/vuAIxINpkTC5UDje3zbg= To: "guix-devel@gnu.org" From: raid5atemyhomework Subject: Re: ZFS on Guix Message-ID: In-Reply-To: References: <_1CLe9QSGsoMlu5WxBMXm4CbFLM_M9iRG1XQF9GDsK0GP208jpngdymfix4tAfoLP94mhMTt-Tx6OP2xN_n78Jhx5KQzkiqPpIci_44C9OI=@protonmail.com> <87lfd698xq.fsf@zancanaro.id.au> <5DEAAAD8-1D08-4489-9AEC-675618F8E388@zancanaro.id.au> <07kwAFNpjhGFe7ArkjjAtRhr564wvMPGhHFyjGb_XdmmPNddKTmT9Swky1NbbUxHBC4xw3p-m_3JyW16Ql9J7PLyk6UdhCsA2cdkHehdti8=@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.40.138; envelope-from=raid5atemyhomework@protonmail.com; helo=mail-40138.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: raid5atemyhomework Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.06 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=protonmail.com header.s=protonmail header.b=SXS47iOG; dmarc=pass (policy=quarantine) header.from=protonmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 38CBA940481 X-Spam-Score: -3.06 X-Migadu-Scanner: scn1.migadu.com X-TUID: 9WF0hXLDvEZ+ Greetings guix-developers and other people trying to use Guix, The patchset currently dying on issues.guix.gnu.org would provide a nice si= mple single-step way to enable *very basic* ZFS support on your Guix system= . Until it gets merged, however, you can still enable *very very basic* ZF= S support on your Guix system by following the below minimal guide. First, select a Linux kernel that the latest ZFS package on Guix supports. = Current on Guix is ZFS 2.0.1. That supports up to Linux 5.10. So I sugge= st using a `linux-libre-5.10` kernel. Don't go with the default `linux-lib= re` or `linux-libre-lts` since those could be updated to past what the ZFS = on Guix supports, be explicit with what kernel version you have. Just reme= mber to update to a later LTS version if ZFS on Guix ever gets updated to a= later version. Then, you need to create a ZFS package, by adding some declarations before = the `operating-system` form: ```scheme (use-modules #;... (guix packages)) (use-package-modules #;... linux file-systems) (define my-kernel linux-libre-5.10) (define my-zfs (package (inherit zfs) (arguments (cons* #:linux my-kernel (package-arguments zfs))))) ``` Then in the `operating-system` form, you need to add the following bits: * Add ZFS to the kernel-loadable modules so that the installed kernel knows= how to read and write ZFS disks. * Add ZFS to the system profile packages so that you can easily manage ZFS = disks. So you have to modify a number of places: ```scheme (operating-system (kernel my-kernel) (kernel-loadable-modules (list (list my-zfs "module"))) #;... (packages (append (map specification->package (list "nss-certs")) (list my-zfs) %base-packages)) #;...) ``` With the above you get a ***ridiculously minimal*** ZFS support. * You have to `sudo modprobe zfs` explicitly at startup. * You have to `sudo zpool import -a` explicitly at startup. To do the above automatically at startup you need to add a Shepherd service= to do the `zpool import`, and add a `kernel-module-loader` extension. Thi= s requires a bit more code to be added to your `configuration.scm`. Here's what I got in my `configuration.scm`: ```scheme (define zfs-shepherd-services (let ((zpool (file-append my-zfs "/sbin/zpool")) (zfs (file-append my-zfs "/sbin/zfs")) (scheme-modules `((srfi srfi-1) (srfi srfi-34) (srfi srfi-35) (rnrs io ports) ,@%default-modules))) (define zfs-scan (shepherd-service (provision '(zfs-scan)) (documentation "Scans for ZFS pools.") (requirement '(kernel-module-loader udev)) (modules scheme-modules) (start #~(lambda _ (invoke/quiet #$zpool "import" "-a" "-N"))) (stop #~(const #f)))) (define zfs-automount (shepherd-service (provision '(zfs-automount)) (documentation "Automounts ZFS data sets.") (requirement '(zfs-scan)) (modules scheme-modules) (start #~(lambda _ (with-output-to-port (current-error-port) (lambda () (invoke #$zfs "mount" "-a" "-l"))))) (stop #~(lambda _ (chdir "/") (invoke/quiet #$zfs "unmount" "-a" "-f") #f)))) (list zfs-scan zfs-automount))) ``` Then, add some `simple-service`s to your `operating-system`: ```scheme (use-modules #;... (gnu services)) (use-service-modules linux shepherd #;...) #;... (operating-system #;... (services (append (list #;... (simple-service 'zfs-loader kernel-module-loader-service-type '("zfs")) (simple-service 'zfs-shepherd-services shepherd-root-service-type zfs-shepherd-services) (simple-service 'zfs-shepherd-services-user-processes user-processes-service-type '(zfs-automount)) #;...) #;... %desktop-services)) #;...) ``` The above lets you mount ZFS pools automatically at startup. Encrypted poo= ls with `keylocation=3Dprompt` will prompt at the console on bootup. Caveats: * You can't have a `/home` on ZFS mount. ZFS has to be mounted before `fil= e-systems` target starts, otherwise Guix will fill up the root-mounr's `/ho= me` directory and ZFS will refuse to mount over that. No `/` or `/boot` on= ZFS either. Probably no good way to put `/gnu/store` on ZFS either, becau= se Guix inherently assumes it's on the `/` mount. * The above setup does not maintain a `/etc/zfs/zpool.cache` file, because = I'm not really certain whether it's kosher in Guix to have a file maintaine= d by ZFS in the `/etc` dir hierarchy. This has a number of consequences: * `zdb` doesn't work because it looks for `/etc/zfs/zpool.cache`. Good l= uck trying to figure out why your pool is slow. * You can't practically have more than a few dozen disks in your system, = because the above uses `zpool import -a` which will cause ZFS to scan all t= he disks at bootup which would probably be slow if you have lots of disks. * You can't practically use `zvol`s to back other filesystems in such a way= that you can put them in a `file-system` declaration. Though why use any = file-system other than ZFS amirite. You can still use `zvol`s to e.g. back= a virtual machine that you launch manually when the system boot is finishe= d, or from a Shepherd service that explicitly lists `user-processes` as a r= equirement. Though hmmm the above doesn't use `zvol_wait` anywhere... sigh= . * There's no ZED. No automatic replacement of failing drives with a hot sp= are. No monitoring. You can probably try launching it in its own Shepherd= service, but you need to figure out how to populate `/etc/zfs/zed/` yourse= lf. If you do, you probably will not be doing it from the `configuration.s= cm` file meaning it'll be hard to replicate the setup elsewhere. Thanks raid5atemyhomework