Emergency mode after updating, failed to mount /sysroot

Hi!

After updating my Nixos I get this error:

This is my hardware-configuration.nix and configuration.nix:

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

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

  fileSystems."/nix" =
    { device = "zroot/root/nix";
      fsType = "zfs";
    };

  fileSystems."/var" =
    { device = "zroot/root/var";
      fsType = "zfs";
    };

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

  fileSystems."/home/helenajurkowska" =
    { device = "zroot/root/home/helenajurkowska";
      fsType = "zfs";
    };

  fileSystems."/home/kazimierzkrauze" =
    { device = "zroot/root/home/kazimierzkrauze";
      fsType = "zfs";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/F899-30FA";
      fsType = "vfat";
      options = [ "fmask=0022" "dmask=0022" ];
    };

  swapDevices =
    [ { device = "/dev/disk/by-uuid/b23cc832-6706-4de0-8657-e2a5d1786a4b"; }
    ];

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
{ config, pkgs-stable, pkgs-unstable, lib, inputs, ... }:

{
  imports =
    [
      ./packages.nix
      ./systemd-services.nix
      ./scripts/scripts.nix
      ./user-interfaces/user-interfaces.nix
      ./backup.nix
      ./filesystems.nix
      ./tlp.nix
    ];

  boot = {
    loader = {
      systemd-boot.enable = true;
      efi.canTouchEfiVariables = true;
    };
    initrd.supportedFilesystems = [ "zfs" "vfat" ];
    kernelPackages = pkgs-unstable.linuxPackages;
    kernel.sysctl."vm.swappiness" = 80;
    zfs.forceImportRoot = false;
  };

  networking.networkmanager.enable = true;

  console.keyMap = "pl";

  time.timeZone = "Europe/Warsaw";

  fonts.packages = [
    pkgs-stable.corefonts
  ];

  i18n = {
    defaultLocale = "en_GB.UTF-8";
    extraLocaleSettings = {
      LC_ADDRESS = "pl_PL.UTF-8";
      LC_IDENTIFICATION = "pl_PL.UTF-8";
      LC_MEASUREMENT = "pl_PL.UTF-8";
      LC_MONETARY = "pl_PL.UTF-8";
      LC_NAME = "pl_PL.UTF-8";
      LC_NUMERIC = "pl_PL.UTF-8";
      LC_PAPER = "pl_PL.UTF-8";
      LC_TELEPHONE = "pl_PL.UTF-8";
      LC_TIME = "pl_PL.UTF-8";
    };
  };

  xdg.portal = {
    enable = true;
    xdgOpenUsePortal = true;
    extraPortals = [
      pkgs-stable.kdePackages.xdg-desktop-portal-kde
    ];
  };

  environment = {
    variables.EDITOR = "vim";
    sessionVariables.NIXOS_OZONE_WL = "1";
  };

  services = {
    pulseaudio.enable = false;
    pipewire = {
      enable = true;
      alsa = {
        enable = true;
        support32Bit = true;
      };
      pulse.enable = true;
    };
    printing = {
      enable = true;
      openFirewall = true;
      drivers = [
        pkgs-stable.samsung-unified-linux-driver
        pkgs-stable.hplip
      ];
    };
    clamav = {
      daemon.enable = true;
      updater.enable = true;
    };
    fwupd.enable = true;
  };

  # Bluetooth
  hardware = {
    bluetooth = {
      enable = true;
      powerOnBoot = true;
      settings.General.Experimental = true;
    };
    i2c = {
      enable = true;
      group = "users";
    };
  };


  # Enable sound with pipewire.
  security = {
    rtkit.enable = true;
    polkit.enable = true;
    audit.enable = true;
    auditd.enable = true;
  };

  virtualisation = {
    libvirtd.enable = true;
    #waydroid.enable = true;
  };

  system.autoUpgrade = {
    enable = true;
    flake = inputs.self.outPath;
    dates = "daily";
  };

  nix = {
    extraOptions = ''
      access-tokens = github.com=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
    '';
    settings = {
      experimental-features = [
        "nix-command"
        "flakes"
      ];
      auto-optimise-store = true;
    };
    nixPath = [ "nixos-config=/home/kazimierzkrauze/Git/nixos-configuration" ];
    gc = {
      automatic = true;
      dates = "daily";
      options = "--delete-older-than 120d";
    };
  };

  programs = {
    virt-manager.enable = true;
    kdeconnect.enable = true;
    steam.enable = true;
  };

  networking = {
    firewall.enable = true;
    nameservers = [
      "208.67.222.123"
      "208.67.220.123"
    ];
  };

  system.stateVersion = "24.11"; # Did you read the comment?

Can you, please, help me out?

Best,
Miro

What is the mountpoint property on those datasets? i.e. What does zfs get mountpoint zroot/root say?

f user@kaktus 0s ~ -> zfs get mountpoint zroot/root
NAME        PROPERTY    VALUE       SOURCE
zroot/root  mountpoint  /           local
f user@kaktus 0s ~ ->

I understood that there is a conflict between zfs-mount and systemd mount, is it right?

That’s right. You probably want to sudo zfs set mountpoint=legacy zroot/root, and the same for the other datasets you mention in your NixOS configuration.

See ZFS - Official NixOS Wiki (which I bet was written by @ElvishJerricco ).

Thank you! That helped.

1 Like