Linux NILFS file system: automatic continuous snapshots

I’m using it on NixOS, but you need nixos/filesystems: add automatic nilfs2 detection by rapenne-s · Pull Request #193773 · NixOS/nixpkgs · GitHub for the best experience.

Until it’s merged, you need to:

  • create an empty /etc/nilfs_cleanerd.conf file to fix the failing garbage collector
  • add nilfs2 module in your initrd to load the root filesystem at boot.
1 Like

I thought NILFS was just a log-structured fs like F2FS but it actually does CoW?! Can it do reflinks?

Thanks for sharing, but beware two things:

  • nilfs2 is deprecated, since I do not remember when but few years, and before was essentially unmaintained;

  • the cleaner, no matter how you tweak it, it’s way to slow for a fast-changing file system like /nix/store or a home directory. I’ve used it few years ago looking for a log based USABLE fs like DragonFlyBSD hammer end finally switch to zfs with a frequent auto_snapshot setup because cyclically ending up in fs full due to a way to lazy cleaner…

Essentially IME avoid it using on production systems except for volume that are mostly static. In protection terms it’s snapshot mechanism is very little usable, yes you can mark a snapshot to avoid cleaning and mount it, but there is no nice “diff” view for a specific file/tree so if the fs is not very small you get too many snaps to check manually so even if it’s better than Samsung f2fs (no human usable snaps at all) it’s still almost useless in the present state in most cases…

Thanks for the feedback :slight_smile:

nilfs2 is still receiving patches, but it seems to lack any integrity check tool (fsck, scrub, whatever you call it). In my tests, the garbage collector was able to clean things so I never had to hit a full disk situation, it was on a 32 GB emmc disk

I wonder if BTRFS or ZFS would be able to cope with a snapshot every 10 seconds. I remember in OpenSolaris times, there was a Nautilus plugin to browse snapshots, and there were a lot of them, so ZFS may be able to support that. I don’t know for BTRFS.

There is one way to find out :smiley:

Depends on how quickly you clean them up I think.

Btrfs snapshots don’t scale very well, you should start running into performance degradations after a few dozen.

ZFS scales better but not infinitely either.

Just taking a snapshot should be a pretty cheap operation on both though.

Definitely report back with your findings, I’m interested in this aswell. I’d love to have super-frequent snapshots with logarithmic retention drop-off. (Sadly, no auto-snapshot tools I know of allow for that.)

2 Likes

Btrfs snapshots don’t scale very well, you should start running into performance degradations after a few dozen.

I’m running with the following for /home:

  • every 15 minutes, kept for 4 hours
  • every hour (except midnight), kept for 2 days
  • every day, kept for 2 weeks

So a total of 76 snapshots at any given time.

With quotas enabled it was a shitshow, but without that, I don’t even notice when btrbk runs.

I simply cannot imagine not having snapshots again. The only ones I have needed are the 15min ones for when I fatfingered rm.

Are you using a custom script to manage the snapshots?

No, just the NixOS btrbk module.

1 Like

🤦‍♀🤦‍♀

I didn’t find that module, and wrote how to do it in a config file. I suppose I’ll make a PR to add “btrfs” in a documentation string of btrbk

Hosted by Flying Circus.