One downside with #NixOS that I'm noticing is that it consumes an absurd amount of hard disk space. This is especially true if you don't know to clear out old generations, but even a system with only a couple generations takes more space than I would expect: I have a VM running right now with 3 generations and a /nix folder that's 18G. That's AFTER optimizing with hard links and garbage collecting. #nix

@scott Try using btrfs and running a tool to do deduplication.

Follow

@scott yes, I confirm. I use something like this

services.beesd.filesystems = {
root = {
spec = "LABEL=nixos";
hashTableSizeMB = 512;
verbosity = "crit";
extraOptions = [ "--loadavg-target" "2.0" ];
};
};

and it saves a lot of space, without affecting CPU and RAM performances because it is a fast, incremental, off-line deduplication.

@yisraeldov

@mzan @scott Cool! I didn't know about this, I was doing dedup manually. Any idea how this works with compressed filesystems?

@yisraeldov
I used it on a zstd compressed filesystem and the results were above my expectations.

After installation, it had to read the entire disk, and it is slow. But the incremental update phase is unnoticeable.

@scott

@yisraeldov
I don't know, but deduplication is based on the recognition of similar blocks of data. So a defrag should not affect the deduplication, because you are defraging blocks, not "files".

I never used defrag on BTRFS, but I used a lot this:

let # BTRFS maintanance.
# Add to ``systemd..services`` settings.
balanceBtrfs = fs: when: {
description = "Fast and incremental balance of btrfs file-system ${fs}";
startAt = when;
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.btrfs-progs}/bin/btrfs balance start -dusage=50 -dlimit=2 -musage=50 -mlimit=4 ${fs}";
};
};

...

in ...

# Btrfs maintanance
# Without this, the free space is not reclaimed after many deletions.
systemd.services.balanceBtrfsRoot = (balanceBtrfs "/" "daily");
systemd.services.balanceBtrfsHDD1 = (balanceBtrfs "/mnt/hdd-int-1/" "daily");

services.fstrim.enable = true;
services.fstrim.interval = "weekly";

@scott

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.