NILFS
NILFS is a New Implementation of Log-structured File System (LFS) that supports continuous snapshot taking. In addition to full file system versioning, this feature of NILFS allows users to restore accidentally deleted or overwritten files to their previous state. Like traditional LFS, NILFS can guarantee file system consistency after a system crash or unclean shutdown, and like journaling file systems, can quickly recover.
Installation
Kernel
File Systems --->
<M/*> NILFS2 file system support Search for <code>CONFIG_NILFS2_FS</code> to find this item.
USE flags
USE flags for sys-fs/nilfs-utils A New Implementation of a Log-structured File System for Linux
split-usr
|
Enable behavior to support maintaining /bin, /lib*, /sbin and /usr/sbin separately from /usr/bin and /usr/lib* |
static-libs
|
Build static versions of dynamic libraries as well |
Emerge
root #emerge --ask sys-fs/nilfs-utilsUsage
Formatting a device
To format a device, use mkfs.nilfs2:
root #mkfs.nilfs2 -f /dev/sda1mkfs.nilfs2 (nilfs-utils 2.2.9)
Start writing file system initial data to the device
Blocksize:4096 Device:/dev/sda1 Device Size:268435456000
File system initialization succeeded !!
Checkpoints and snapshots
NILFS makes checkpoints at regular intervals. Checkpoints will be cleaned up by the garbage collector.
Listing checkpoints
To list checkpoints available, use lscp:
root #lscp CNO DATE TIME MODE FLG BLKCNT ICNT
1 2026-01-12 21:25:44 cp - 4 2
2 2026-01-12 21:28:22 cp - 4 3
Creating a checkpoint
To create a checkpoint, use mkcp:
root #mkcp /dev/sda1root #lscp CNO DATE TIME MODE FLG BLKCNT ICNT
1 2026-01-12 21:25:44 cp - 4 2
2 2026-01-12 21:28:22 cp - 4 3
3 2026-01-12 21:28:46 cp - 5 3
Creating a snapshot
To create a snapshot, use the -s flag in mkcp:
root #mkcp -sroot #lscp CNO DATE TIME MODE FLG BLKCNT ICNT
1 2026-01-12 21:25:44 cp - 4 2
2 2026-01-12 21:28:22 cp - 4 3
3 2026-01-12 21:28:46 cp - 5 3
4 2026-01-12 21:29:19 ss - 5 3
Note how the Mode changed from cp to ss.
Converting a checkpoint to a snapshot (and vice versa)
To convert a checkpoint to a snapshot (or vice versa), use chcp:
root #chcp ss 2root #lscp CNO DATE TIME MODE FLG BLKCNT ICNT
1 2026-01-12 21:25:44 cp - 4 2
2 2026-01-12 21:28:22 ss - 4 3
3 2026-01-12 21:28:46 cp - 5 3
4 2026-01-12 21:29:19 ss - 5 3
To turn a snapshot into a checkpoint:
root #chcp cp 4root #lscp CNO DATE TIME MODE FLG BLKCNT ICNT
1 2026-01-12 21:25:44 cp - 4 2
2 2026-01-12 21:28:22 ss - 4 3
3 2026-01-12 21:28:46 cp - 5 3
4 2026-01-12 21:29:19 cp - 5 3
Mounting a snapshot
Mounting a snapshot has two options, a read-only option, -r or -o ro and a cp option to specify the number of the checkpoint to be mounted.
root #mkdir /mnt/nilfs-snapshotroot #mount -t nilfs2 -r -o cp=2 /dev/sda1 /mnt/nilfs-snapshotSee also
- bcachefs — a fully-featured B-tree filesystem based on bcache.
- btrfs — a copy-on-write (CoW) filesystem for Linux aimed at implementing advanced features while focusing on fault tolerance, self-healing properties, and easy administration.
- F2FS — a filesystem designed for NAND flash-based devices.
- ZFS — a next generation filesystem created by Matthew Ahrens and Jeff Bonwick.