NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.96k stars 13.33k forks source link

Create necessary Overlayfs directories in Stage 2 mount #186408

Open Sepero opened 2 years ago

Sepero commented 2 years ago

Describe the bug

When mounting an overlayfs in Stage 1, any directories depended on are automatically created. In Stage 2, they are not.

Steps To Reproduce

The following code mounts correctly in Stage 1. If the line "neededForBoot" is removed, then it tries to mount in Stage 2 and fails. The depends directories are not created in Stage 2.

fileSystems."/home" = {
    neededForBoot = true;
    device = "overlay";
    fsType = "overlay";
    options = [
      "lowerdir=/nix/persist/home"
      "upperdir=/.hrw/u"
      "workdir=/.hrw/w"
    ];
    depends = [
      "/nix/persist/home"
      "/.hrw/u"
      "/.hrw/w"
    ];
  };

Expected behavior

If a directory is listed in filesystem."name".depends, and it doesn't exist, then please create it.

Sepero commented 2 years ago

Stage 2 mount dmesg output overlayfs: failed to resolve '/.hrw/u': -2

Sepero commented 10 months ago

Requesting that if a Stage 2 directory is listed in filesystem."name".depends.* , and it doesn't exist, then have it created, pretty please. ❤️

lheckemann commented 6 months ago

Fixed by https://github.com/systemd/systemd/pull/30377 which should hopefully be landing in a nixpkgs version near you soon!