NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.82k stars 13.92k forks source link

Booting with zfs root filesystem may spuriously fail #25383

Open nagisa opened 7 years ago

nagisa commented 7 years ago

Issue description

Booting during stage 1 results in

running udev...
starting device mapper and LVM...
importing root ZFS pool "rpool"...
mounting rpool/root/nixos on /...
mount: mounting rpool/root/nixos on /mnt-root/ failed: Device or resource busy

This failure is spurious in that it only happens once every a few boots and does not seem to depend on whether the system was shut down cleanly beforehand or stuff like this.

I strongly suspect the problem is caused by device mapper/LVM but I can’t find how to disable them.

Steps to reproduce

Here’re my ZFS datasets and ZVOLs:

$ zfs list
NAME                     USED  AVAIL  REFER  MOUNTPOINT
rpool                   28.5G   219G    96K  /rpool
rpool/home              8.45G   219G  8.45G  legacy
rpool/root              13.8G   219G    96K  none
rpool/root/nixos        13.8G   219G  13.8G  legacy
rpool/vm                6.24G   219G    96K  /rpool/vm
rpool/vm/mips-debian    1.36G   219G  1.36G  - <- zvol
rpool/vm/mipsel-fedora  2.17G   219G  2.17G  - <- zvol
rpool/vm/ppc64-fedora   2.71G   219G  2.71G  - <- zvol

And the relevant nix configuration:

  boot.kernelModules = [ ... "zfs" ];

  services.udev.extraRules = ''
    ENV{ID_FS_TYPE}=="zfs", ATTR{queue/scheduler}="noop"
    ENV{ID_FS_TYPE}=="zfs_member", ATTR{queue/scheduler}="noop"
    SYMLINK=="zvol/rpool/vm/*", GROUP="vm", MODE="0660"
  '';

  fileSystems."/" =
    { device = "rpool/root/nixos";
      fsType = "zfs";
    };

  fileSystems."/home" =
    { device = "rpool/home";
      fsType = "zfs";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/E3E2-E34C";
      fsType = "vfat";
    };

  fileSystems."/tmp" =
    { device = "tmpfs";
      fsType = "tmpfs";
    };

Technical details

mmahut commented 5 years ago

Any news on this issue?

stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
wizeman commented 4 years ago

I think it wouldn't hurt to retry mounting ZFS filesystems on stage 1 like we do for CIFS mounts. I will submit a PR.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info