nix-community / impermanence

Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
MIT License
1.01k stars 76 forks source link

Fails with mkdir: cannot create directory: No such file or directory #154

Open tmarkov opened 7 months ago

tmarkov commented 7 months ago

I use impermanence with the following config:

  # Impermanence
  environment.persistence."/persist/system" = {
    directories = [
      "/etc/nixos" # bind mounted from /persist/system/etc/nixos to /etc/nixos
      "/etc/NetworkManager"
      "/etc/secureboot"
      "/var/log"
      "/var/lib"
    ];
    files = [
      "/etc/machine-id"
      "/etc/ssh/ssh_host_ed25519_key"
      "/etc/ssh/ssh_host_ed25519_key.pub"
      "/etc/ssh/ssh_host_rsa_key"
      "/etc/ssh/ssh_host_rsa_key.pub"
    ];
  };

When installing on a new system, I create a partition, mount it on /persist, and run nixos-install. However. this fails because when impermanence tries to create the persistence directories, it fails with No such file or directory errors.

I have fixed it like this - I'm nit sure though if this is a problem with impermanence or if I'm doing something wrong.

Frontear commented 7 months ago

Are you sure your /persist directory exists at the time of root creation? You should ensure "/persist" is loaded and mounted before impermanence gets to it, otherwise bind mounts fail.

WayneHarsman commented 1 month ago

Got the same issue here. Before running nixos-install the /mnt/persist/system directory is basically empty. Install script fails to create directory if the root of target path does not exist. Also this causes further complications during first boot since the system tries to mount binds for the non-existent directories and this halts the whole boot process. Tmarkov's solution looks like the proper fix for that.

visualphoenix commented 2 weeks ago

@talyz i tracked down the MVP of the nixos-anywhere provisioning issue - seems to be related to /etc/ssh keys not existing until the first boot... this issue lists similar keys being persisted... the MVP of the issue is https://github.com/visualphoenix/nixos-anywhere-disko-impermanence-mvp

talyz commented 2 weeks ago

@visualphoenix That sounds like a different issue than this. Could you open a new one for it?

talyz commented 2 weeks ago

193 should have a proper solution for this, hopefully. Please try it out!