* How to declare a bind mount in the "file-systems" definition? @ 2020-03-20 0:31 Matthew Brooks 2020-03-20 1:41 ` Leo Famulari 0 siblings, 1 reply; 10+ messages in thread From: Matthew Brooks @ 2020-03-20 0:31 UTC (permalink / raw) To: help-guix@gnu.org My boot disk is an SSD, and to save some wear I'd like to bind mount a folder on one of my spinning disk drives to /tmp. The online manual does mention that bind-mount exists, but doesn't actually seem to have any examples of defining a bind mount. For reference, I'm trying to automatically bind mount "/spinning-disk-drive-goes-here/tmp" to "/tmp". The manual also doesn't give any examples of defining a dependency so that the base drive gets mounted and then the bind mount will only be mounted after. Do I define the "spinning-disk-drive-goes-here" file system inside the dependency block and not in the main list of file systems, or do I define it in the usual place and then add some unique ID to the dependency block, or something else? Anyway, thanks for your help, and for all the work put into guixSD! ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to declare a bind mount in the "file-systems" definition? 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 0 siblings, 1 reply; 10+ messages in thread From: Leo Famulari @ 2020-03-20 1:41 UTC (permalink / raw) To: Matthew Brooks; +Cc: help-guix@gnu.org On Thu, Mar 19, 2020 at 07:31:23PM -0500, Matthew Brooks wrote: > The online manual does mention that bind-mount exists, but doesn't actually seem to have any examples of defining a bind mount. You would add (flags '(bind-mount)) to the Scheme definition of file-system. > The manual also doesn't give any examples of defining a dependency so that the base drive gets mounted and then the bind mount will only be mounted after. Do I define the "spinning-disk-drive-goes-here" file system inside the dependency block and not in the main list of file systems, or do I define it in the usual place and then add some unique ID to the dependency block, or something else? There's an example in this discussion: https://lists.gnu.org/archive/html/help-guix/2016-11/msg00062.html Make sure to read the reply from Ludovic which completes the picture. Does that help? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to declare a bind mount in the "file-systems" definition? 2020-03-20 1:41 ` Leo Famulari @ 2020-03-21 4:14 ` Matthew Brooks 2020-03-22 22:12 ` Leo Famulari 0 siblings, 1 reply; 10+ messages in thread From: Matthew Brooks @ 2020-03-21 4:14 UTC (permalink / raw) To: Leo Famulari; +Cc: help-guix@gnu.org On Thu, 19 Mar 2020 21:41:55 -0400 Leo Famulari <leo@famulari.name> wrote: > You would add (flags '(bind-mount)) to the Scheme definition of > file-system. Yes, that much is mentioned, but defining a bind mount also requires other things which are not mentioned in the manual page. Such as how to specify the source directory, what "device" and "type" should be set to, and probably a few other things that I'm forgetting. For example, "device" appears to be a required field, but the manual says it may only be: >a file system label, a file system UUID, or the name of a /dev node and setting it to a folder doesn't appear to be a valid option, according to the manual. I played around a bit with trying to get a bind mount defined, but the only thing I was able to come up with that didn't error when reconfiguring was: > (file-system > (device "/spinning-disk-drive-goes-here/tmp") > (mount-point "/tmp") > (type "bind") > (flags '(bind-mount)) > ) but it failed on boot with: >No file system check procedure for /spinning-disk-drive-goes-here/tmp: skipping and lots of services failed to start, and I had to reboot and revert to the previous config. There is clearly something else required, but it doesn't appear to be in the manual, and I have no idea how to get guix to give me any helpful info about what all options are actually allowed. > There's an example in this discussion: > > https://lists.gnu.org/archive/html/help-guix/2016-11/msg00062.html > > Make sure to read the reply from Ludovic which completes the picture. Thanks. That does seem to explain how to set up dependencies pretty clearly. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to declare a bind mount in the "file-systems" definition? 2020-03-21 4:14 ` Matthew Brooks @ 2020-03-22 22:12 ` Leo Famulari 2020-03-26 15:10 ` Matthew Brooks 0 siblings, 1 reply; 10+ messages in thread From: Leo Famulari @ 2020-03-22 22:12 UTC (permalink / raw) To: Matthew Brooks; +Cc: help-guix@gnu.org On Fri, Mar 20, 2020 at 11:14:57PM -0500, Matthew Brooks wrote: > I played around a bit with trying to get a bind mount defined, but the only thing I was able to come up with that didn't error when reconfiguring was: > > (file-system > > (device "/spinning-disk-drive-goes-here/tmp") > > (mount-point "/tmp") > > (type "bind") > > (flags '(bind-mount)) > > ) > but it failed on boot with: > >No file system check procedure for /spinning-disk-drive-goes-here/tmp: skipping If you make device a string it is assumed to be a device node. Looking in the manual for mentions of bind-mount I found the documentation of %immutable-store, which is a bind-mounted filesystem that exists by default in Guix System. It's implemented in 'gnu/systems/file-systems.scm' and hopefully provides a helpful example: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/system/file-systems.scm?h=v1.0.1#n346 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to declare a bind mount in the "file-systems" definition? 2020-03-22 22:12 ` Leo Famulari @ 2020-03-26 15:10 ` Matthew Brooks 2020-03-29 9:36 ` Gábor Boskovits 0 siblings, 1 reply; 10+ messages in thread From: Matthew Brooks @ 2020-03-26 15:10 UTC (permalink / raw) To: Leo Famulari; +Cc: help-guix@gnu.org On Sun, 22 Mar 2020 18:12:10 -0400 Leo Famulari <leo@famulari.name> wrote: > Looking in the manual for mentions of bind-mount I found the > documentation of %immutable-store, which is a bind-mounted filesystem > that exists by default in Guix System. It's implemented in > 'gnu/systems/file-systems.scm' and hopefully provides a helpful example: > > https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/system/file-systems.scm?h=v1.0.1#n346 Thanks! I was able to get it working from that example! For anyone else in the future who might want the info, here's what I did: first I had to define these two things before the operating system section: >(define data-drive > (file-system > (device (uuid "UUID goes here")) > (mount-point "/path-to-spinning-disk-goes-here") > (type "ext4"))) > >(define (%tmp-directory) "/path-to-spinning-disk-goes-here/tmp") Then, in the file-systems list I added the following: >(file-systems (cons* > > ...<other drives omitted for clarity>... > > data-drive > > (file-system > (device (%tmp-directory)) > (mount-point "/tmp") > (type "none") > (flags '(bind-mount)) > (dependencies (list data-drive)) > ) > > %base-file-systems)) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to declare a bind mount in the "file-systems" definition? 2020-03-26 15:10 ` Matthew Brooks @ 2020-03-29 9:36 ` Gábor Boskovits 2020-03-29 20:01 ` Matthew Brooks 0 siblings, 1 reply; 10+ messages in thread From: Gábor Boskovits @ 2020-03-29 9:36 UTC (permalink / raw) To: Matthew Brooks; +Cc: help-guix@gnu.org Hello, I am glad that this finally worked! Matthew Brooks <matthewfbrooks@mailbox.org> ezt írta (időpont: 2020. márc. 26., Cs, 16:11): > > On Sun, 22 Mar 2020 18:12:10 -0400 > Leo Famulari <leo@famulari.name> wrote: > > > Looking in the manual for mentions of bind-mount I found the > > documentation of %immutable-store, which is a bind-mounted filesystem > > that exists by default in Guix System. It's implemented in > > 'gnu/systems/file-systems.scm' and hopefully provides a helpful example: > > > > https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/system/file-systems.scm?h=v1.0.1#n346 > > Thanks! I was able to get it working from that example! > > For anyone else in the future who might want the info, here's what I did: > > first I had to define these two things before the operating system section: > > >(define data-drive > > (file-system > > (device (uuid "UUID goes here")) > > (mount-point "/path-to-spinning-disk-goes-here") > > (type "ext4"))) > > > >(define (%tmp-directory) "/path-to-spinning-disk-goes-here/tmp") > > Then, in the file-systems list I added the following: > > >(file-systems (cons* > > > > ...<other drives omitted for clarity>... > > > > data-drive > > > > (file-system > > (device (%tmp-directory)) > > (mount-point "/tmp") > > (type "none") > > (flags '(bind-mount)) > > (dependencies (list data-drive)) > > ) > > > > %base-file-systems)) > Could you consider adding an example to the cookbook? I believe that would be a great addition. Best regards, g_bor -- OpenPGP Key Fingerprint: 7988:3B9F:7D6A:4DBF:3719:0367:2506:A96C:CF63:0B21 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to declare a bind mount in the "file-systems" definition? 2020-03-29 9:36 ` Gábor Boskovits @ 2020-03-29 20:01 ` Matthew Brooks 2020-04-08 16:52 ` Leo Famulari 0 siblings, 1 reply; 10+ messages in thread From: Matthew Brooks @ 2020-03-29 20:01 UTC (permalink / raw) To: Gábor Boskovits; +Cc: help-guix@gnu.org [-- 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 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: How to declare a bind mount in the "file-systems" definition? 2020-03-29 20:01 ` Matthew Brooks @ 2020-04-08 16:52 ` Leo Famulari 2020-04-22 17:03 ` Matthew Brooks 0 siblings, 1 reply; 10+ messages in thread From: Leo Famulari @ 2020-04-08 16:52 UTC (permalink / raw) To: Matthew Brooks; +Cc: help-guix@gnu.org On Sun, Mar 29, 2020 at 03:01:09PM -0500, Matthew Brooks wrote: > 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. Thanks! You can build the cookbook as HTML like this: `guix environment --pure guix -- make doc/guix-cookbook.html` When building you will see some errors and warnings that need to be fixed, related to setting up the menu and navigating between sections. Lines should be wrapped at 72 characters, except in examples. > * 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. "Setting up a bind-mount on Guix System" is more general, and thus I think more appropriate for the table of contents. Otherwise LGTM! Can you send a revised patch? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to declare a bind mount in the "file-systems" definition? 2020-04-08 16:52 ` Leo Famulari @ 2020-04-22 17:03 ` Matthew Brooks 2020-04-22 19:52 ` Leo Famulari 0 siblings, 1 reply; 10+ messages in thread From: Matthew Brooks @ 2020-04-22 17:03 UTC (permalink / raw) To: Leo Famulari; +Cc: help-guix@gnu.org [-- Attachment #1: Type: text/plain, Size: 1277 bytes --] Thanks for the help! I've renamed the section and hard wrapped the lines, and updated it to a more recent commit. Let me know if there's anything else I should do. On Wed, 8 Apr 2020 12:52:47 -0400 Leo Famulari <leo@famulari.name> wrote: > On Sun, Mar 29, 2020 at 03:01:09PM -0500, Matthew Brooks wrote: > > 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. > > Thanks! > > You can build the cookbook as HTML like this: > > `guix environment --pure guix -- make doc/guix-cookbook.html` > > When building you will see some errors and warnings that need to be > fixed, related to setting up the menu and navigating between sections. > > Lines should be wrapped at 72 characters, except in examples. > > > * 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. > > "Setting up a bind-mount on Guix System" is more general, and thus I > think more appropriate for the table of contents. > > Otherwise LGTM! Can you send a revised patch? [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: cookbook_example_of_bind-mounting.patch --] [-- Type: text/x-patch, Size: 2918 bytes --] diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index 58a5ba1c80..b4522c0637 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -1322,6 +1322,7 @@ reference. @menu * Customizing the Kernel:: Creating and using a custom Linux kernel on Guix System. * Customizing a Window Manager:: Handle customization of a Window manager on Guix System. +* Setting up a bind-mount on Guix System:: Setting up a bind-mount in the file-systems definition. @end menu @node Customizing the Kernel @@ -1614,6 +1615,55 @@ Then you need to add the following code to a StumpWM configuration file (set-font (make-instance 'xft:font :family "DejaVu Sans Mono" :subfamily "Book" :size 11)) @end lisp +@node Setting up a bind-mount on Guix System +@section Setting up a bind-mount on Guix System + +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 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: How to declare a bind mount in the "file-systems" definition? 2020-04-22 17:03 ` Matthew Brooks @ 2020-04-22 19:52 ` Leo Famulari 0 siblings, 0 replies; 10+ messages in thread From: Leo Famulari @ 2020-04-22 19:52 UTC (permalink / raw) To: Matthew Brooks; +Cc: help-guix@gnu.org On Wed, Apr 22, 2020 at 12:03:25PM -0500, Matthew Brooks wrote: > Thanks for the help! I've renamed the section and hard wrapped the lines, and updated it to a more recent commit. > > Let me know if there's anything else I should do. Great! I pushed as 60651dd9624e4ca648ef0f0d426628377533a637 with the following changes: I added a copyright line for you. I changed the section title to "Setting up a bind mount"... it's even more general! And we already know that it's about Guix. I changed natural language instances of "bind-mount" to "bind mount" after a Google search revealed that it's more idiomatic. And similarly, I changed "file-system" to "file system", which is how we write in Guix. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-04-22 19:52 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2020-04-08 16:52 ` Leo Famulari 2020-04-22 17:03 ` Matthew Brooks 2020-04-22 19:52 ` Leo Famulari
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).