impermanence icon indicating copy to clipboard operation
impermanence copied to clipboard

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

Open tmarkov opened this issue 1 year ago • 5 comments

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.

tmarkov avatar Dec 02 '23 14:12 tmarkov

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.

Frontear avatar Dec 05 '23 08:12 Frontear

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.

WayneHarsman avatar Jun 08 '24 11:06 WayneHarsman

@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

visualphoenix avatar Jun 22 '24 23:06 visualphoenix

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

talyz avatar Jun 23 '24 11:06 talyz

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

talyz avatar Jun 23 '24 14:06 talyz