unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Matthew Brooks <matthewfbrooks@mailbox.org>
To: "Gábor Boskovits" <boskovits@gmail.com>
Cc: "help-guix@gnu.org" <help-guix@gnu.org>
Subject: Re: How to declare a bind mount in the "file-systems" definition?
Date: Sun, 29 Mar 2020 15:01:09 -0500	[thread overview]
Message-ID: <20200329150109.505f087e@mailbox.org> (raw)
In-Reply-To: <CAE4v=pgsLZbBy5K8GadQyV-XcUphWMd3_sS40B2X=MU01HOf3A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

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 though, or on what the preferred writing style is for the cookbook.

On Sun, 29 Mar 2020 11:36:57 +0200
Gábor Boskovits <boskovits@gmail.com> wrote:
 
> Could you consider adding an example to the cookbook?
> I believe that would be a great addition.
> 
> Best regards,
> g_bor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Cookbook-Adding-example-of-bind-mounting-in-the-oper.patch --]
[-- Type: text/x-patch, Size: 3262 bytes --]

From b66973344e3387f1a8450d091489a8a9671e8738 Mon Sep 17 00:00:00 2001
From: Matthew Brooks <matthewfbrooks@mailbox.org>
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.
 
 @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
 
 @node Customizing the Kernel
@@ -1562,6 +1563,51 @@ likely that you'll need to modify the initrd on a machine using a custom
 kernel, since certain modules which are expected to be built may not be
 available for inclusion into the initrd.
 
+@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 example 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 your 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") ;; "source-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*
+
+                ...<other drives omitted for clarity>...
+
+                source-drive ;; Must match the name you gave the source drive in the earlier definition.
+
+                (file-system
+                 (device (%source-directory)) ;; Make sure "source-directory" matches your earlier definition.
+                 (mount-point "/tmp")
+                 (type "none") ;; We are mounting a folder, not a partition, so this type needs to be "none"
+                 (flags '(bind-mount))
+                 (dependencies (list source-drive)) ;; Ensure "source-drive" matches what you've named the variable for the drive.
+                 )
+
+                 ...<other drives omitted for clarity>...
+
+                ))
+@end lisp
+
+
 @c *********************************************************************
 @node Advanced package management
 @chapter Advanced package management
-- 
2.25.1


  reply	other threads:[~2020-03-29 20:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20  0:31 How to declare a bind mount in the "file-systems" definition? Matthew Brooks
2020-03-20  1:41 ` Leo Famulari
2020-03-21  4:14   ` Matthew Brooks
2020-03-22 22:12     ` Leo Famulari
2020-03-26 15:10       ` Matthew Brooks
2020-03-29  9:36         ` Gábor Boskovits
2020-03-29 20:01           ` Matthew Brooks [this message]
2020-04-08 16:52             ` Leo Famulari
2020-04-22 17:03               ` Matthew Brooks
2020-04-22 19:52                 ` Leo Famulari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200329150109.505f087e@mailbox.org \
    --to=matthewfbrooks@mailbox.org \
    --cc=boskovits@gmail.com \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).