Next: , Previous: , Up: Systemkonfiguration   [Contents][Index]


3.10 Setting up a bind mount

To bind mount a file system, one must first set up some definitions before the operating-system section of the system definition. In this example we will bind mount a folder from a spinning disk drive to /tmp, to save wear and tear on the primary SSD, without dedicating an entire partition to be mounted as /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.

(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.

The source folder must also be defined, so that guix will know it’s not a regular block device, but a folder.

;; "source-directory" can be named any valid variable name.
(define (%source-directory) "/path-to-spinning-disk-goes-here/tmp")

Finally, inside the file-systems definition, we must add the mount itself.

(file-systems (cons*

                ...<other drives omitted for clarity>...

                ;; Must match the name you gave the source drive in the earlier definition.
                source-drive

                (file-system
                 ;; Make sure "source-directory" matches your earlier definition.
                 (device (%source-directory))
                 (mount-point "/tmp")
                 ;; We are mounting a folder, not a partition, so this type needs to be "none"
                 (type "none")
                 (flags '(bind-mount))
                 ;; Ensure "source-drive" matches what you've named the variable for the drive.
                 (dependencies (list source-drive))
                 )

                 ...<other drives omitted for clarity>...

                ))