NILFS(8)

✨ NILFS(8) ✨

okay bestie, pull up a chair, because we're talking about NILFS β€” the new implementation of a log-structured file system, straight outta the System Manager's Manual πŸ’–


🌸 SYNOPSIS 🌸

This one's a lil different β€” it's not a command you run, it's the whole vibe tour of the NILFS file system and all the lil tools that hang out with it. πŸ¦‹


πŸ’… DESCRIPTION πŸ’…

NILFS is a log-structured file system that was developed for Linux. And the way it ate?? It gives you versioning capability of an entire file system plus continuous snapshotting β€” which means you can literally go back and restore files you accidentally overwrote or destroyed a while ago. not me crying over a deleted essay, we don't do that anymore 😭

The current major version of NILFS is version 2, and we call it NILFS2. NILFS2 comes equipped with an online garbage collector (also called a cleaner) that reclaims disk space in the background while keeping multiple snapshots alive. multitasking queen behavior πŸ‘‘

So here's the lore. Whenever data gets written, or literally any change is made to a NILFS2 file system, it automatically creates a checkpoint. A checkpoint represents a consistent state of the NILFS2 file system of a certain instant. It becomes mountable after being changed into a snapshot. And a snapshot is the checkpoint marked not to be deleted by the cleaner. NILFS2 creates a number of checkpoints at regular intervals (unless there's no change) or with synchronous writings. And the best part? There is no practical limit on the number of checkpoints and snapshots. infinite. iconic. periodt. ✨

These are the tools you get to manage your checkpoints and snapshots, bestie:

  • lscp β€” lists checkpoints or snapshots
  • mkcp β€” makes a checkpoint or a snapshot
  • chcp β€” changes an existing checkpoint to a snapshot or vice versa
  • rmcp β€” invalidates specified checkpoint(s)

These tools give the versioning capability to NILFS2; a user can select significant versions among continuously created checkpoints and can change them to snapshots to be preserved for long periods. it's giving time traveler energy fr fr 🧚

Heads up! Every checkpoint except for the snapshot will become unprotected from the cleaner after a given period of time. That period is controlled by the protection_period parameter defined in the /etc/nilfs_cleanerd.conf(5) file. so like, protect your faves or they're gone πŸ’€

🌈 MOUNT OPTIONS 🌈

Refer to the mount.nilfs2(8). (yes that's the whole section, go read the other page, iykyk 🫢)


πŸŽ€ EXAMPLES πŸŽ€

okay this is the fun part, let's actually do stuff πŸ“

  • mkfs -t nilfs2 /dev/sdb1 β€” creates a NILFS2 file system on a block device /dev/sdb1.
  • mount -t nilfs2 /dev/sdb1 /nilfs β€” mounts the NILFS2 file system on a mount point /nilfs like an ordinary POSIX file system. This will invoke a cleaner process nilfs_cleanerd(8) through an external mount program (i.e. mount.nilfs2(8)).
  • lscp β€” lists checkpoints created in the file system, like so:
       CNO        DATE     TIME  MODE  FLG      BLKCNT       ICNT
         1  2024-03-16 23:49:26   cp    -            4          1
         2  2024-03-16 23:49:44   cp    -            4          1
         3  2024-03-16 23:50:55   cp    -         3208        625
         4  2024-03-16 23:51:18   cp    -         2207        506
         5  2024-03-16 23:51:23   cp    -         2204        503
       ...
  • chcp ss 2 β€” changes the checkpoint whose checkpoint-number is two to a snapshot. Then the checkpoint list will become as follows:
       CNO        DATE     TIME  MODE  FLG      BLKCNT       ICNT
         1  2024-03-16 23:49:26   cp    -            4          1
         2  2024-03-16 23:49:44   ss    -            4          1
         3  2024-03-16 23:50:55   cp    -         3208        625
         4  2024-03-16 23:51:18   cp    -         2207        506
         5  2024-03-16 23:51:23   cp    -         2204        503
       ...
  • mount -t nilfs2 -r -o cp=2 /dev/sdb1 /snapshot β€” mounts the snapshot on another directory /snapshot as a read-only file system. Here the snapshot mount requires at least two options: a read-only option (-r or -o ro) and the cp option (-o cp=checkpoint-number). Note that a read/write mount and one or more snapshots are mountable independently, so the online backup is possible through the snapshot mounts. no cap, that's the whole trick πŸ’…
       # mount -t nilfs2
       /dev/sdb1 on /nilfs type nilfs2 (rw,relatime)
       /dev/sdb1 on /snapshot type nilfs2 (ro,relatime,cp=2)
  • umount /nilfs β€” unmounts the NILFS2 file system mounted on /nilfs and will shut down the nilfs_cleanerd(8) through an external umount program (umount.nilfs2(8)) for the read/write mount.

πŸ‘‘ AUTHORS πŸ‘‘

NILFS2 was developed by the NILFS development team. absolute legends, we stan 🫢


πŸ’œ SEE ALSO πŸ’œ

https://nilfs.sourceforge.io/


okay that's the whole page bestie, go forth and snapshot responsibly πŸŒΈπŸ’– this was nilfs-utils version 2.3, dated Jan 2026 β€” mwah, love u, bye!! βœ¨πŸ¦‹

πŸ“¦ where this page comes from