Nixos-install mount: command not found

Hi there, new to nixos.

I’m using my fedora to install nixos on a second btrfs subvolume, by following NixOS Manual
However, I had issue at the end of the installation.

sudo PATH="$PATH:/usr/sbin:/sbin" `which nixos-install` --root /mnt
installing the boot loader...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
...
/nix/var/nix/profiles/system/sw/bin/bash: line 8: mount: command not found

Not sure why that error occurred, I have the binary in /usr/bin.

/usr/bin/mount

I found this issue that looks similar, but not sure what the solution is nixos-install script 'mount: command not found' · Issue #220211 · NixOS/nixpkgs · GitHub

Any guidance is really appreciated. Thanks.

nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.12.9-200.fc41.x86_64, Fedora Linux, 41 (KDE Plasma), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.25.4`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/home/eric/.nix-defexpr/channels/nixpkgs`

nix-channel --list
nixpkgs https://nixos.org/channels/nixos-24.11
2 Likes

Try using the nixOS live ISO to install nixos on the second btrfs subvolume

It is probably more reliable than: sudo PATH="$PATH:/usr/sbin:/sbin" which nixos-install --root /mnt

I thought it’d be cool to see the self contained reproducibility in action, but it seems to be more headache than I expected.
I’ll restart with a live ISO. Thanks for the help.

1 Like

I’m running into a similar problem as OP.

Unfortunately I don’t really have the option of booting a live ISO:
I booted in Debian on an Aarch64 machine, then installed Nix, and now need to install NixOS with nixos-install.

Because of that, a solution to the mount command not being found in nixos-install (despite which mount returning /nix/store/fdv1ary508pbwkzfh3rzgamqyzqsbmwk-util-linux-2.39.4-bin/bin/mount) would be greatly appreciated.

1 Like

I’m running into this problem also. It’s suspicious to run into this and see that all of the references to it are in the last few weeks. I wonder if something has broken recently.

1 Like

There’s nothing “reproducible” or “self-contained” about relying on an external binary in /usr/bin that wasn’t built by nix.

I did automatic iPXE install, got hit by it. Seems like initial 24.11 release was fine, it was broken along the way later in commits of release branch.

I do not have option to manually workaround.

UPDATE:

Trying to use disko-install and fail

indeed, if I do sudo chroot /mnt/disko-install-root/ sh (created by disko-install), mount does not exist. seems nixos-install uses /bin of mounted root directory.

UPDATE2:

helped

  env PATH="$PATH:/home/ubuntu/.nix-profile/bin/:/bin/" nixos-install --no-channel-copy --no-root-password --system "$nixos_system" --root "$mountPoint"

So guess better use mount from nix

UPDATE3:
install into profile util-linux and use

1 Like

I believe the error comes from this line: nixpkgs/pkgs/by-name/ni/nixos-install/nixos-install.sh at 36864ed72f234b9540da4cf7a0c49e351d30d3f1 · NixOS/nixpkgs · GitHub

Notice how it’s line 8 of the snippet, which aligns with the error messages reported here.

(it’s line 10 in nixos-unstable, line 8 in 24.11)

I think the fix is to have the target’s util-linux on PATH (which may differ from the util-linux installed on your host). The easy way to do this would be to just have the target’s system-path on PATH. So add /nix/var/nix/profiles/system/sw/bin to PATH, and I think that will fix it.

2 Likes

I just got hit with this as well, but none of the solutions (as I understood them) works.

This is me following the manual from here: NixOS Manual

The mount command is missing from the newly generated system. I’ve added util-linux to the systemPackages in my configuration.nix, but to no avail

I just ran into this, too, and @ElvishJerricco 's workaround fixed things for me. (Thanks!)

So add /nix/var/nix/profiles/system/sw/bin to PATH, and I think that will fix it.

I was confused about this at first, so maybe the following will help other people like me: The nixos-install.sh script @ElvishJerricco linked to will execute mount after chrooting into the --root directory (e.g. /mnt), so binaries from the host system, like mount, will no longer be available. (In my case I was running nixos-install -p nixos-install-tools util-linux inside a nix-shell on Ubuntu and was surprised as to why mount couldn’t be found.) However, it seems environment variables from the shell on the host will propagate down to the chroot environment, so the solution is to set something like export PATH="$PATH:/nix/var/nix/profiles/system/sw/bin" in the host shell (in which nixos-install is started later). Here, /nix/var/… refers to a path inside the root folder that nixos-install will chroot into (e.g… /mnt).

Now, I have no idea why nixos-install.sh isn’t setting up PATH correctly in the first place but at least we’ve got a workaround!

1 Like

Thanks everybody for the workaround suggestions, especially @codethief for the deep dive. I ran into this problem when running disko-install on an Ubuntu 22 machine. The workarounds posted here, while crucial, weren’t enough individually, so I documented the necessary steps to get my particular setup working. I hope these may help someone else as well.