How can I get correct subvolume paths for btrfs?

I’m trying to install NixOS from a rescue system running Debian.

I’ve created a btrfs file system, which spans the two hard disks I have via the RAID-1 support of btrfs. I’ve created subvolumes /live/root, /live/nix, and /live/home on this btrfs file system and mounted them on /mnt, /mnt/nix, and /mnt/home respectively.

Unfortunately, the file hardware-configuration.nix created by running sudo `which nixos-generate-config` --root /mnt lists /mnt, /mnt/nix, and /mnt/home as the btrfs subvolume paths. This is wrong in two ways: first, those paths use the /mnt prefix, which will be incorrect for the running system; second, they are the paths of the mount points, not the paths of the subvolumes, which are /live/root, /live/nix, and /live/home.

Is this a bug in action? Any ideas how to fix that? I understand that I shouldn’t edit hardware-configuration.nix.

You can edit hardware-configuration.nix if it contains wrong information. It will be not regenerated unless you call nixos-generate-config again, which you might not need to on re-installation for example. This is the code that tries to figure out btrfs volumes: https://github.com/Mic92/nixpkgs/blob/3fec2c1101caaac5397ae8e00003771b3eb476d9/nixos/modules/installer/tools/nixos-generate-config.pl#L365 If you think this is incorrect you can open an issue or pull request.

1 Like