NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.39k stars 14.34k forks source link

build-fhs-userenv-bubblewrap: handle roaming CIFS filesystems mounted in a root subdir #189160

Open winny- opened 2 years ago

winny- commented 2 years ago

Describe the bug

I have a roaming CIFS filesystem mounted at /multimedia. This means when the server is available, systemd happily ensures access. Otherwise I get an error such as: "no such device". This is intentional.

When using programs that use build-fhs-userenv-bubblewrap, it appears all directories directly under / are bind-mounted, unless blacklisted. This appears to cause a problem because bindmounting a roaming filesystems results in the following error:

$ sudo mount -o bind /multimedia /tmp/m
mount: /tmp/m: unknown filesystem type 'none'.

For example, when launching android-studio when the /multimedia mountpoint is not connected, I get the following error after a timeout:

bwrap: Can't bind mount /oldroot/multimedia on /newroot/multimedia: Unable to mount source on destination: No such device

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install a program that uses build-fhs-userenv-bubblewrap
  2. Set up a roaming filesystem (one that works with "netsplits") that mounts to a directory in /. See https://nixos.wiki/wiki/Samba#cifs_mount
  3. Try to run your program (e.g. android-studio)

Expected behavior

program launches, bwrap is set up with usable parameters.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

My particular filesystem configuration https://gitlab.com/winny/nixos-configs/-/blob/9186c639498073cbb03ad8a82b1bf77d63ea4e28/common/base.nix

Work around, move the filesytem mountpoint to a directory whose parent is not /.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.52, NixOS, 22.05 (Quokka), 22.05.2720.058de381857`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - channels(root): `"nixos-22.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
austinbutler commented 1 year ago

Yeah, this is really annoying. I can't run Steam on my laptop because my NAS is powered off and the laptop has an NFS automount for the NAS. :man_facepalming:

❯ steam
bwrap: Can't bind mount /oldroot/mnt on /newroot/mnt: Unable to apply mount flags: remount "/newroot/mnt/nas": No such device
austinbutler commented 1 year ago

Found that a way to unblock is stop the systemd mount that's causing the problem.

❯ systemctl | rg -i nas
  mnt-nas.automount                                                                                                                           loaded active     running         mnt-nas.automount
  mnt-nas.mount                                                                                                                               loaded activating mounting  start /mnt/nas

❯ sudo systemctl status mnt-nas.automount
● mnt-nas.automount
     Loaded: loaded (/etc/fstab; generated)
     Active: active (running) since Fri 2023-05-26 10:05:29 PDT; 1 day 9h ago
   Triggers: ● mnt-nas.mount
      Where: /mnt/nas
       Docs: man:fstab(5)
             man:systemd-fstab-generator(8)

May 27 19:16:21 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 539849 (.gvfsd-recent-w)
May 27 19:16:31 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 539849 (.gvfsd-recent-w)
May 27 19:16:41 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 479117 (.gvfsd-recent-w)
May 27 19:16:51 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 608084 (.gvfsd-recent-w)
May 27 19:17:01 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 539849 (.gvfsd-recent-w)
May 27 19:17:12 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 479117 (.gvfsd-recent-w)
May 27 19:17:22 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 539849 (.gvfsd-recent-w)
May 27 19:17:32 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 608084 (.gvfsd-recent-w)
May 27 19:17:42 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 608084 (.gvfsd-recent-w)
May 27 19:17:53 austin-work systemd[1]: mnt-nas.automount: Got automount request for /mnt/nas, triggered by 479117 (.gvfsd-recent-w)

❯ sudo systemctl stop mnt-nas.automount
nixos-discourse commented 2 days ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/bwrap-cant-bind-mount-oldroot-efi-on-newroot-efi-unable-to-mount-source-on-destination-no-such-device/47202/2