Boot bind mount device path incorrect

OpenSubmitted by rendaw.
Details
3 participants
  • rendaw
  • François-René Rideau
  • Leo Famulari
Owner
unassigned
Severity
normal
R
R
rendaw wrote on 28 Apr 2019 17:27
(address . submit@debbugs.gnu.org)
a31590f5-918c-5d13-4021-20f0117c1f30@s.rendaw.me
Package: guix
Version: 0.16.0

I specified a needed-at-boot bind mount from "/x/y" to "/y" but this
failed with the error:

ERROR: In procedure stat:
In procedure stat: No such file or directory: "/x/y"

At boot "/x" is actually mounted at "/root/x" so the bind mount path
should be "/root/x/y" -- making such a change causes the boot to work.

User defined filesystems with non-dev paths added to the boot mounts
should either automatically get "/root" prepended to the device path or
else the fact that they need to be prepended should be included in the
documentation, since there's no other way to discover this (other than
reading the source and trial/error).

For people hitting the same error, you can double check the mount points
at the repl you're dropped into with:

(use-modules (ice-9 ftw))
(scandir "/root")
F
F
François-René Rideau wrote on 9 Aug 2021 19:54
(address . 35472@debbugs.gnu.org)
CAOhKva1Rku8SZDx3twnH-+2sfApiqTF+9vvh0_YMpV8-3oC=OA@mail.gmail.com
I believe my issue is the same and that I could narrow it down more.

The `mount --bind /nixos/nix /nix` command works, but if I put a line
`"/nixos/nix /nix bind defaults"` in `/etc/fstab`, then mount will instead
fail with: `mount: /nix: unknown filesystem type 'bind'.`

If instead in fstab I use type `none` and put `bind` in the options,
then `mount /nix` works at the command-line but interestlingly
`guix system reconfigure guix-config.scm` still fails with:
```
guix system: warning: exception caught while executing 'start' on
service 'file-system-/nix':
In procedure mount: mount "/nixos/nix" on "///nix": No such device
guix system: warning: some services could not be upgraded
```

Below is the `file-systems` definition of my `guix-config.scm`, in an attempt
to share the `/nix` directory of my NixOS installation with GuixSD, just like
I share the /guix directory of my GuixSD installation with NixOS:

```
(file-systems
(append
(let* ((boot (file-system
;;(uuid "C1D9-0574")
(device "/dev/nvme0n1p1")
(mount-point "/boot")
(type "vfat")))
(root (file-system
;;(device "/dev/mapper/yew-guix")
(device (uuid "43f7ca3e-c107-4f15-9756-5d3cbacad0a0"))
(mount-point "/")
(type "btrfs")
#;(flags '(no-atime))
(options "compress=zstd")
(dependencies mapped-devices)))
(home (file-system
;;(device "/dev/yew/home")
(device (uuid "a3602532-3527-4afc-9b40-5d01c58b5aa8"))
(mount-point "/home")
(type "ext4")
(dependencies mapped-devices)))
(nixos (file-system
(device (uuid "ab3d691b-227a-4a05-a084-6928abbf0959"))
(mount-point "/nixos")
(type "ext4")
(dependencies mapped-devices)))
(nix (file-system
(device "/nixos/nix")
(mount-point "/nix")
;;(type "bind") ;; fails both at CLI and during reconfigure
(type "none") (option "bind") ;; CLI OK, reconfigure FAIL
(dependencies (list nixos)))))
(append (list boot root home nixos nix) %base-file-systems))))
```

Note that neither bind nor none appear in `/proc/filesystem` nor in
`/run/booted-system/kernel/lib/modules/5.13.8/kernel/fs` — but then
neither do they on NixOS and yet it all works there.
L
L
Leo Famulari wrote on 9 Aug 2021 20:56
(name . François-René Rideau)(address . fare@mukn.io)(address . 35472@debbugs.gnu.org)
YRF6UQNgm1vziApF@jasmine.lan
On Mon, Aug 09, 2021 at 01:54:15PM -0400, Fran�ois-Ren� Rideau wrote:
Toggle quote (7 lines)
> (nix (file-system
> (device "/nixos/nix")
> (mount-point "/nix")
> ;;(type "bind") ;; fails both at CLI and during reconfigure
> (type "none") (option "bind") ;; CLI OK, reconfigure FAIL
> (dependencies (list nixos)))))

Try replacing the option field with (flags '(bind-mount))

F
F
François-René Rideau wrote on 9 Aug 2021 23:06
(name . Leo Famulari)(address . leo@famulari.name)(address . 35472@debbugs.gnu.org)
CAOhKva2sDC3gK2qcQFGTSG5gG+RKAoCnkK5-wObFSgRpTP_b-w@mail.gmail.com
Wow, this works:
(type "bind") (flags '(bind-mount))

and it works by *not* putting any entry in /etc/fstab, yet doing the
thing somehow. So the bug in mount is still there, but is worked
around.

Toggle quote (1 lines)
Indeed bind-mount is mentioned there, but vastly under-documented,
especially since the guix paragraph refers to some glibc documentation
for mount(2) for details, and those details saying nothing whatsoever
about bind.
L
L
Leo Famulari wrote on 10 Aug 2021 00:09
(name . François-René Rideau)(address . fare@mukn.io)(address . 35472@debbugs.gnu.org)
YRGno31NPiDKp9Ux@jasmine.lan
On Mon, Aug 09, 2021 at 05:06:26PM -0400, Fran�ois-Ren� Rideau wrote:
Toggle quote (4 lines)
> and it works by *not* putting any entry in /etc/fstab, yet doing the
> thing somehow. So the bug in mount is still there, but is worked
> around.

Can you clarify what is the "bug in mount"?
L
L
Leo Famulari wrote on 10 Aug 2021 00:58
Re: bug#35472: Boot bind mount device path incorrect
(name . rendaw)(address . 7e9wc56emjakcm@s.rendaw.me)(address . 35472@debbugs.gnu.org)
YRGzDkLmdxoCGFrl@jasmine.lan
On Mon, Apr 29, 2019 at 12:27:58AM +0900, rendaw wrote:
Toggle quote (3 lines)
> Package: guix
> Version: 0.16.0

Reproduced with 1.3.0ish.

Toggle quote (9 lines)
> I specified a needed-at-boot bind mount from "/x/y" to "/y" but this
> failed with the error:
>
> ERROR: In procedure stat:
> In procedure stat: No such file or directory: "/x/y"
>
> At boot "/x" is actually mounted at "/root/x" so the bind mount path
> should be "/root/x/y" -- making such a change causes the boot to work.

To reproduce this bug:

# mkdir -p /foo/bar
# mkdir -p /bar

Add this to the file-systems field of your config.scm:

(file-system
(device "/foo/bar")
(mount-point "/bar")
(type "none")
(check? #f)
(needed-for-boot? #t)
(flags '(bind-mount)))

Your system should fail to boot.
F
F
François-René Rideau wrote on 10 Aug 2021 03:22
Re: bug#35472:
(name . Leo Famulari)(address . leo@famulari.name)(address . 35472@debbugs.gnu.org)
CAOhKva3+29d2h9hch08wzQECPjmTFNmpyCRGSs5omPireWeoqQ@mail.gmail.com
My apologies: I was just confused about the syntax of bind entries in
/etc/fstab.

"bind" goes in the options field (no ",defaults" needed), whereas
"none" goes in the type field. I tried it this way and mount works
just fine on Guix as well as on NixOS and Debian and other Linux
variants; and with my incorrect syntax (with "bind" in the type field)
it fails on all of them.

Now, whereas the guix manual does need clarification about
"bind-mount", I see that there is a recipe in the cookbook that
specifically explains how to declare bind entries in Guix.
?