I’m using this sd-card image generator for a RiscV board, similar to others like RaspberryPi etc. NixOS on RISCV/VisionFive 2 - Official NixOS Wiki
I changed the root filesystem from ext4 to Btrfs using this:
sdImage = {
compressImage = false;
rootFilesystemCreator = "${pkgs.path}/nixos/lib/make-btrfs-fs.nix";
# do this manually as replacing the resize2fs string in postBootCommands
# might be too complex. btrfs uses its own resize command.
expandOnBoot = false;
};
nixpkgs.overlays = [
(final: prev: {
ubootVisionFive2 = prev.ubootVisionFive2.overrideAttrs (oldAttrs: {
extraConfig = (oldAttrs.extraConfig or "") + ''
CONFIG_FS_BTRFS=y
CONFIG_CMD_BTRFS=y
'';
});
})
];
fileSystems."/" = {
fsType = lib.mkForce "btrfs";
options = [
"compress=zstd"
"noatime"
"rw"
];
};
Booting works quite far but with a lot of errors. Couldn’t figure out the root cause yet:
Scanning for Btrfs filesystems
registered: /dev/vda3
mounting /dev/disk/by-label/NIXOS_SD on /...
[ 15.589159] BTRFS: device label NIXOS_SD devid 1 transid 13 /dev/vda3 (254:3) scanned by mount (193)
[ 15.597953] BTRFS info (device vda3): first mount of filesystem 44444444-4444-4444-8888-888888888888
[ 15.637722] BTRFS info (device vda3): using crc32c (crc32c-lib) checksum algorithm
[ 15.881840] BTRFS info (device vda3): turning on async discard
[ 15.882129] BTRFS info (device vda3): enabling free space tree
[ 15.882451] BTRFS info (device vda3): use zstd compression, level 3
mount: /mnt-root/run: filesystem was mounted, but failed to update userspace mount table.
[...]
<<< NixOS Stage 2 >>>
[ 18.254168] booting system configuration /nix/store/pmpybzgmfz558gzs3swhqbkqrd8n955f-nixos-system-nixos-sd-card-25.11pre-git
running activation script...
setting up /etc...
+ /nix/store/w30hh4fig5a8hsv3zhnfrw3ki8zj7p57-nix-riscv64-unknown-linux-gnu-2.31.2/bin/nix-store --load-db
+ touch /etc/NIXOS
+ /nix/store/w30hh4fig5a8hsv3zhnfrw3ki8zj7p57-nix-riscv64-unknown-linux-gnu-2.31.2/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
+ rm -f /nix-path-registration
+ mkdir -p /mnt
+ '[' -e /var/lib/nixos/did-channel-init ']'
+ echo 'unpacking the NixOS/Nixpkgs sources...'
unpacking the NixOS/Nixpkgs sources...
+ mkdir -p /nix/var/nix/profiles/per-user/root
+ /nix/store/w30hh4fig5a8hsv3zhnfrw3ki8zj7p57-nix-riscv64-unknown-linux-gnu-2.31.2/bin/nix-env -p /nix/var/nix/profiles/per-user/root/channels -i /nix/store/rf4v5lgvvrm9mg5pv2bn9i5bk79qrh14-nixos-25.11pre-git --quiet --option build-use-substitutes false
error: opening file '/nix/store/bzq916b8li8sxwz3ml1kr2q9bx932xw3-user-environment.drv': No such file or directory
starting systemd...
[...]
[FAILED] Failed to start Logrotate configuration check.
See 'systemctl status logrotate-checkconf.service' for details.
[FAILED] Failed to start Name Service Cache Daemon (nsncd).
See 'systemctl status nscd.service' for details.
[DEPEND] Dependency failed for Host and Network Name Lookups.
[DEPEND] Dependency failed for User and Group Name Lookups.
Starting Name Service Cache Daemon (nsncd)...
[ OK ] Started D-Bus System Message Bus.
[FAILED] Failed to start Name Service Cache Daemon (nsncd).
full log: https://gist.github.com/onny/f4c474ce3f2c19a828eaf46c8d178ab4