Does NIxOs not create /mnt by default?

I just installed NixOS 21.11 on my homeserver, and realized that there is not /mnt directory does not exist.

Does NixOS not create this directory by default? I want to mount some other volumes, and was wondering if I should manually create this directory, or if it’s something that I need to enable via my config file?

1 Like

No, it does not create /mnt by default, yes, you can do this manually, but I would recommenced the configuration.nix way, which might look like this:

fileSystems."/" =
    { device = "/dev/disk/by-uuid/f24b4362-3b79-4f18-ae4f-22bc1ba40a0c";
      fsType = "btrfs";

You can see your /etc/nixos/hardware-configureation.nix for reference, but don’t edit that, because NixOS overwrites that on rebuild.

/mnt is traditionally used for ephemeral mounts, you don’t do them in the configuration.

Today I usually don’t use mount and /mnt for ephemeral mounts anymore but instead I use udisksctl for ephemeral user mounts when dealing with removable drives.


I wasn’t aware that /mnt meant only for ephemeral mounts, I’ve always used it even for volumes that were always expected to be present. Is there a source for it’s purpose being ephemeral, or is that mostly just lore/convention?

Is there a conventional place where semi permanent volumes are mounted? I could create a /data or /volumes, but if there’s a convention, I’d like to stick to that.

Sure, I’m actually trying to mount these volumes in order to regenerate the hardware-configuration.nix.

I ended up manually creating these mounts, but the regenerated hardware-configuration.nix file doesn’t have the correct luks configuration. If I add these mounts in my configuration.nix manually, will a regeneration of the hardware-configuration.nix avoid synthesizing code that duplicates these mount options?

Mostly lore from my Unix prof at university as well as ops people at my current employer, though they had the same prof, so my sample size is basically 1 :wink:

Beyond that I usually mount my volumes to appropriate locations in /var/lib.

For me there is not really a thing as arbitrary unsorted data.

And if it’s music, documents etc, owned by a user id mount them to the respective XDG locations of that user.

If it’s just a random windows data partition, I’d use it solely through udisksctl

1 Like

Note this might become somewhat more difficult in the sparkly systemd-homed future where your home directory isn’t an actual directory but a filesystem-in-file that’s decrypted and mounted on login.

Whenever we make it to that state it’d probably be best to hook your drive into this encryption too, though, so there will probably be a nice way to do that.

Personally, I’m silly and habitually use /mnt because a much younger me thought that seemed appropriate :slight_smile: