From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Brooks Subject: Re: How to declare a bind mount in the "file-systems" definition? Date: Sun, 29 Mar 2020 15:01:09 -0500 Message-ID: <20200329150109.505f087e@mailbox.org> References: <20200319193123.40d51798@mailbox.org> <20200320014155.GA30652@jasmine.lan> <20200320231457.520bf473@mailbox.org> <20200322221210.GA20590@jasmine.lan> <20200326101032.50ba3d9c@mailbox.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/pOBTHVacYT6E4_XFBEE99y2" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:43555) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIe7W-0003RK-Gv for help-guix@gnu.org; Sun, 29 Mar 2020 16:01:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIe7V-0002PF-4f for help-guix@gnu.org; Sun, 29 Mar 2020 16:01:22 -0400 Received: from mout-p-202.mailbox.org ([80.241.56.172]:34018) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jIe7U-0002Ef-Gf for help-guix@gnu.org; Sun, 29 Mar 2020 16:01:21 -0400 In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane-mx.org@gnu.org Sender: "Help-Guix" To: =?UTF-8?B?R8OhYm9y?= Boskovits Cc: "help-guix@gnu.org" --MP_/pOBTHVacYT6E4_XFBEE99y2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I can give it a shot. I've whipped up and attached a quick patch that adds = a section about bind-mounting. I wasn't able to find any info on how to preview the resulting html file th= ough, or on what the preferred writing style is for the cookbook. On Sun, 29 Mar 2020 11:36:57 +0200 G=C3=A1bor Boskovits wrote: =20 > Could you consider adding an example to the cookbook? > I believe that would be a great addition. >=20 > Best regards, > g_bor --MP_/pOBTHVacYT6E4_XFBEE99y2 Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=0001-Cookbook-Adding-example-of-bind-mounting-in-the-oper.patch =46rom b66973344e3387f1a8450d091489a8a9671e8738 Mon Sep 17 00:00:00 2001 From: Matthew Brooks Date: Sun, 29 Mar 2020 14:55:34 -0500 Subject: [PATCH] Cookbook: Adding example of bind-mounting in the operating system definition. --- doc/guix-cookbook.texi | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index 477b7e3dff..78b99abda8 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -1320,6 +1320,7 @@ reference. =20 @menu * Customizing the Kernel:: Creating and using a custom Linux kernel on= Guix System. +* Bind-mounting file systems:: Setting up a bind-mount in the file-systems= definition. @end menu =20 @node Customizing the Kernel @@ -1562,6 +1563,51 @@ likely that you'll need to modify the initrd on a ma= chine using a custom kernel, since certain modules which are expected to be built may not be available for inclusion into the initrd. =20 +@c ********************************************************************* +@node Bind-mounting file-systems +@section Bind-mounting file-systems + +To bind-mount a file-system, one must first set up some definitions before= the @code{operating-system} section of the system definition. In this exam= ple we will bind-mount a folder from a spinning disk drive to @code{/tmp}, = to save wear and tear on the primary +SSD, without dedicating an entire partition to be mounted as @code{/tmp}. + +First, the source drive that hosts the folder we wish to bind mount should= be defined, so that the bind-mount can depend on it. + +@lisp +(define source-drive ;; "source-drive" can be named anything you want. + (file-system + (device (uuid "UUID goes here")) + (mount-point "/path-to-spinning-disk-goes-here") + (type "ext4"))) ;; Make sure to set this to the appropriate type for y= our drive. +@end lisp + +The source folder must also be defined, so that guix will know it's not a = regular block device, but a folder. +@lisp +(define (%source-directory) "/path-to-spinning-disk-goes-here/tmp") ;; "so= urce-directory" can be named any valid variable name. +@end lisp + +Finally, inside the @code{file-systems} definition, we must add the mount = itself. + +@lisp +(file-systems (cons* + + ...... + + source-drive ;; Must match the name you gave the source dr= ive in the earlier definition. + + (file-system + (device (%source-directory)) ;; Make sure "source-directo= ry" matches your earlier definition. + (mount-point "/tmp") + (type "none") ;; We are mounting a folder, not a partitio= n, so this type needs to be "none" + (flags '(bind-mount)) + (dependencies (list source-drive)) ;; Ensure "source-driv= e" matches what you've named the variable for the drive. + ) + + ...... + + )) +@end lisp + + @c ********************************************************************* @node Advanced package management @chapter Advanced package management --=20 2.25.1 --MP_/pOBTHVacYT6E4_XFBEE99y2--