Recent from talks
Contribute something
Nothing was collected or created yet.
NILFS
View on WikipediaThis article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
|
| Developer(s) | Nippon Telegraph and Telephone Cyber Space Laboratories |
|---|---|
| Full name | New Implementation of a Log-structured File System |
| Introduced | 2005 with Linux kernel 2.6.13 |
| Structures | |
| File allocation | B-tree |
| Limits | |
| Max volume size | 8 EiB |
| Max file size | 8 EiB |
| Max filename length | 255 bytes |
| Features | |
| Dates recorded | atime (planned) |
| Date resolution | 64-bit on-disk timestamps |
| Attributes | POSIX, with plans for extended attributes |
| File system permissions | POSIX, with plans for ACLs[1] |
| Transparent compression | No |
| Transparent encryption | No |
| Copy-on-write | Yes |
| Other | |
| Supported operating systems | Linux kernel, (ReadOnly for NetBSD) |
NILFS or NILFS2 (New Implementation of a Log-structured File System) is a log-structured file system implementation for the Linux kernel. It was developed by Nippon Telegraph and Telephone Corporation (NTT) CyberSpace Laboratories and a community from all over the world. NILFS was released under the terms of the GNU General Public License (GPL).
Design
[edit]"NILFS is a log-structured file system, in that the storage medium is treated like a circular buffer and new blocks are always written to the end.[…]Log-structured file systems are often used for flash media since they will naturally perform wear-leveling;[…]NILFS emphasizes snapshots. The log-structured approach is a specific form of copy-on-write behavior, so it naturally lends itself to the creation of file system snapshots. The NILFS developers talk about the creation of "continuous snapshots" which can be used to recover from user-initiated file system problems[…]."[2]
Using a copy-on-write technique known as a log-structured file system, NILFS records all data in a continuous log-like format that is only appended to, never overwritten, an approach that is designed to reduce seek times, as well as minimize the kind of data loss that occurs after a crash with conventional file systems. For example, data loss occurs on ext3 file systems when the system crashes during a write operation. When the system reboots, the journal notes that the write did not complete, and any partial data writes are lost.
Some file systems, like UFS-derived file systems used by the Solaris operating system and BSDs, provide a snapshot feature that prevents[citation needed] such data loss, but the snapshot configuration can be lengthy on large file systems. NILFS, in contrast, can "continuously and automatically [save] instantaneous states of the file system without interrupting service", according to NTT Labs.[3]
The "instantaneous states" that NILFS continuously saves can actually be mounted, read-only, at the same time that the actual file system is mounted read-write — a capability useful for data recovery after hardware failures and other system crashes. The "lscp" (list checkpoint) command of an interactive NILFS "inspect" utility is first used to find the checkpoint's address, in this case "2048":
# inspect /dev/sda2 ... nilfs> listcp 1 6 Tue Jul 12 14:55:57 2005 MajorCP|LogiBegin|LogiEnd 2048 2352 Tue Jul 12 14:55:58 2005 MajorCP|LogiEnd ... nilfs> quit
The checkpoint address is then used to mount the checkpoint:
# mount -t nilfs -r -o cp=2048 /dev/sda2 /nilfs-cp # df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 70332412 8044540 62283776 12% /nilfs /dev/sda2 70332412 8044540 62283776 12% /nilfs-cp
Features
[edit]NILFS provides continuous snapshotting. In addition to the versioning capability of the entire file system, users can even restore files mistakenly overwritten or deleted at any recent time. Since NILFS can keep consistency like conventional LFS, it achieves quick recovery after system crashes.
Continuous snapshotting is not provided by most file systems, including those supporting point-in-time snapshotting (e.g. Btrfs).
NILFS creates a number of checkpoints every few seconds or per synchronous write basis (unless there is no change). Users can select significant versions among continuously created checkpoints, and can change them into snapshots which will be preserved until they are changed back to checkpoints.
There is no limit on the number of snapshots until the volume gets full. Each snapshot is mountable as a read-only file system. It is mountable concurrently with a writable mount and other snapshots, and this feature is convenient for making consistent backups during use.
Possible uses of NILFS include versioning, tamper detection, SOX compliance logging, data loss recovery.
The current major version of NILFS is version 2, referred to as NILFS2. NILFS2 implements online garbage collection to reclaim disk space while keeping multiple snapshots.
Other NILFS features include:
- B-tree based file and inode management.
- Immediate recovery after system crash.
- 64-bit data structures; support many files, large files and disks.
- 64-bit on-disk timestamps which are free of the year 2038 problem.
Current status
[edit]Issues
[edit]As of 2023, NILFS lacks a dedicated consistency checking utility (fsck), and thus can't recover from severe errors that cause it to fail to find a valid checkpoint.[4][5]
Supported features
[edit]- Basic POSIX file system features
- Snapshots
- Automatically and continuously taken
- No limit on the number of snapshots until the volume gets full
- Mountable as read-only file systems
- Mountable concurrently with the writable mount (convenient to make consistent backups during use)
- Quick listing
- Background garbage collection (GC)
- Can maintain multiple snapshots
- Selectable GC Policy, which is given by a userland daemon.
- Quick crash recovery on-mount
- Read-ahead for meta data files as well as data files
- Block sizes smaller than page size (e.g. 1 KB or 2 KB)
- Online resizing (since Linux-3.x and nilfs-utils 2.1)
- Related utilities (by contribution of Jiro SEKIBA)
- grub2
- util-linux (blkid, libblkid, uuid mount)
- udisks, palimpsest
- File system label (nilfs-tune)
Additional features
[edit]- Fast write and recovery times
- Minimal damage to file data and system consistency on hardware failure
- Internal data is processed in 64-bit wide word size
- Can create and store huge files (8 EiB)
Compatibility
[edit]NILFS is available in various GNU/Linux distributions like Arch Linux,[8] Debian[9] (since version 5.0), Fedora, Gentoo,[10] Linux Mint, NixOS, Ubuntu (since version 9.10), etc. To use it, users typically need to install the nilfs-utils or nilfs-tools package. A boot-cd with NILFS is also available on PrRescue.
It is also supported by partition-editing applications like GParted.[11]
A separate, BSD licensed implementation, currently with read-only support, is included in NetBSD.[12]
Relative performance
[edit]In the January 2015 presentation SD cards and file systems for embedded systems at Linux.conf.au, it was stated:[13]
If you've got a workload that's latency sensitive, you might want to use NILFS. If you've got one that's throughput sensitive, you might want to use F2FS.
— Peter Chubb
NILFS2 works much better for the lots of small files case than F2FS or EXT4.
— Peter Chubb
License
[edit]The NILFS2 file system utilities are made available under the GNU General Public License version 2, with the exception of the lib/nilfs libraries and their header files, which are made available under the GNU Lesser General Public License Version 2.1.
Developers
[edit]The Japanese primary authors and major contributors to the nilfs-utils who worked or are working at labs of NTT Corporation are:
- Ryusuke Konishi (Primary maintainer, 02/2008–Present)
- Koji Sato
- Naruhiko Kamimura
- Seiji Kihara
- Yoshiji Amagai
- Hisashi Hifumi and
- Satoshi Moriai.
Other major contributors are:
- Andreas Rohner[14]
- Dan McGee
- David Arendt
- David Smid
- dexen deVries
- Dmitry Smirnov
- Eric Sandeen
- Jiro SEKIBA
- Matteo Frigo
- Hitoshi Mitake
- Takashi Iwai
- Vyacheslav Dubeyko
See also
[edit]- ZFS
- Btrfs
- F2FS, another log-structured file system implementation
- List of file systems
- Comparison of file systems
- Log-structured File System (BSD)
- Sprite operating system
References
[edit]- ^ "NILFS Current Status".
- ^ "BTRFS and NILFS [LWN.net]".
- ^ "An article about NILFS". Retrieved 2008-07-28.
- ^ Corrupted NILFS2 partition (/var) - Opinions on a better FS for /var?
- ^ Kernel archives: Can't mount nilfs - error searching super root.
- ^ the NILFS version 1: overview
- ^ does not verify: Re: Does nilfs2 checksum all data?; kernel 4.4.38-v7+ does not verify, too.
- ^ "Arch Linux - nilfs-utils 2.2.9-1 (X86_64)".
- ^ "Debian -- Details of package nilfs-tools in bullseye".
- ^ "Sys-fs/Nilfs-utils – Gentoo Packages".
- ^ "GParted -- Features".
- ^ NiLFS(2) source commit
- ^ Peter Chubb. "SD cards and filesystems for embedded systems". Linux.conf.au.
- ^ "State-of-the-art Garbage Collection Policies for NILFS2" (PDF). Archived from the original (PDF) on 2019-07-30.
External links
[edit]- Official website
- "An Article Describing High-level Features". Archived from the original on 2013-01-03.
- "World's Largest TELCO Joins Open Source Development Labs". Archived from the original on 2013-01-27.
- NILFS: A File System to Make SSDs Scream
- Manjaro tutorial NILFS: A filesystem designed to minimize the likelyhood [sic] of data loss Archived 2017-01-06 at the Wayback Machine
NILFS
View on Grokipedianilfs_cleanerd handles background garbage collection to reclaim space from obsolete checkpoints, ensuring sustained performance over time.[2] As of September 2025, the latest release of nilfs-utils (version 2.2.12) includes fixes for stability issues, underscoring the project's active development for Linux environments.[3]
Introduction
Overview
NILFS2 (New Implementation of a Log-structured File System version 2) is a log-structured file system designed for the Linux kernel, developed by Nippon Telegraph and Telephone (NTT) Corporation's Cyber Space Laboratories.[5] It appends all modifications sequentially to the disk in a continuous log, enabling efficient management of filesystem updates without the fragmentation issues common in traditional in-place update systems.[1] The primary purpose of NILFS2 is to provide continuous snapshotting and versioning capabilities, allowing users to restore overwritten or deleted files, or even the entire filesystem state, to any point in the past.[2] This versioning ensures that the filesystem maintains a history of changes through automatically generated checkpoints, facilitating recovery from errors or accidental modifications without manual intervention.[1] NILFS2 offers key advantages such as crash recovery in seconds—limited to replaying only the most recent log segment—resulting in minimal data loss compared to traditional filesystems like ext3 or ext4, which may require longer journaling or fsck operations.[1] Additionally, it supports unlimited snapshots that persist until storage capacity is exhausted, mountable as read-only instances for backup or auditing purposes.[2] Development of NILFS began with its initial release in September 2005, followed by the open-source launch of NILFS2 in June 2007, and its integration into the mainline Linux kernel with version 2.6.30 in June 2009, marking the first filesystem from Japan to achieve this milestone.[5]History
NILFS was developed by Nippon Telegraph and Telephone (NTT) Corporation's Cyber Space Laboratories as a research project beginning in 2005, aimed at implementing advanced log-structured file system (LFS) features within the Linux kernel to enhance data reliability and recovery capabilities.[6] The initial prototype, known as NILFS version 1, was released as open-source software in September 2005 under the GNU General Public License version 2.0.[6] This early version focused on continuous snapshotting to prevent data loss in enterprise Linux environments. A major milestone came with the release of NILFS2 in June 2007, which introduced improved snapshot management mechanisms for better versioning and space efficiency.[5] NILFS2 was subsequently upstreamed into the mainline Linux kernel as version 2.6.30 in June 2009, marking the first file system originating from Japan to be integrated into the kernel.[5] Further enhancements included the addition of online resizing capabilities, enabled in Linux kernel version 3.0 (released December 2011) alongside nilfs-utils version 2.1 (stable release November 2011), allowing dynamic volume expansion or shrinkage without unmounting.[7][8] Development activity slowed significantly after 2015, with only sporadic bug fixes and minor updates, fostering perceptions of project abandonment among the Linux community.[4] This dormancy persisted until 2024, when a series of fixes addressing issues like potential deadlocks and buffer access errors were merged into Linux kernel 6.12.[9] Renewed interest emerged in late 2025, highlighted by the announcement on November 8, 2025, of Viacheslav Dubeyko as a second maintainer alongside Ryusuke Konishi, updating the kernel's MAINTAINERS file to reflect co-maintenance status.[10] This development signals potential for future enhancements, such as optimizations to garbage collection processes.[4]Design Principles
Log-Structured Architecture
NILFS employs a log-structured file system (LFS) architecture, treating the storage device as a continuous, circular log buffer where all file system modifications—both data and metadata—are appended sequentially rather than updated in place. This approach utilizes copy-on-write (COW) semantics, ensuring that existing data blocks remain unchanged while new versions are written to fresh locations in the log, thereby preserving previous states and enabling efficient versioning. By appending updates in a log-like manner, NILFS avoids the fragmentation and seek overhead associated with random writes in traditional file systems.[1] The architecture divides the storage volume into fixed-size segments, typically 8 MB each, which serve as the fundamental units for log management and garbage collection. Each segment consists of payload blocks containing actual data or metadata and summary blocks that record the organization of these payloads, including file information (finfo) and block information (binfo) structures to facilitate recovery and navigation. File and directory contents are organized using B-tree structures: inodes are managed via B-trees rooted in the superblock, while file blocks use B-trees rooted in their respective inodes, supporting efficient lookups and scalability. Additionally, NILFS incorporates 64-bit addressing to handle large volumes, with virtual block addressing achieved through a dedicated Data Address Translation (DAT) file that maps logical to physical locations.[1] This LFS design yields significant benefits, including minimized disk seeks through sequential appends, which substantially improves write throughput—particularly for synchronous operations—and ensures the atomicity of updates by grouping them into complete segments. The continuous logging mechanism also enhances crash recovery, as the file system can be reconstructed from the log without extensive scanning. Unlike journaling file systems such as ext4, which selectively log metadata or data in a separate journal for recovery, NILFS logs all changes continuously across the entire volume, integrating versioning directly into the core architecture rather than as an add-on feature.[1]Checkpointing and Versioning
NILFS employs checkpointing as a core mechanism to capture atomic, consistent states of the filesystem at regular intervals, serving as the foundation for its versioning capabilities. Checkpoints represent periodic points in the log-structured sequence where all modified data and metadata blocks are fully written to disk, ensuring a complete and recoverable filesystem image without partial updates. These checkpoints are generated automatically every few seconds or upon synchronous write operations, provided there are changes to the filesystem, and are sequentially numbered for identification, such as checkpoint #2048. This process integrates with the log-structured appends, where ongoing writes accumulate until a checkpoint finalizes the segment. Checkpoints can be converted to snapshots by marking them as protected, preventing garbage collection and preserving them indefinitely until space management requires otherwise.[1] The versioning process in NILFS leverages these checkpoints to enable full filesystem versioning, allowing multiple historical states to coexist on the same volume without overwriting prior data. Each checkpoint defines a distinct version of the entire filesystem, including all files, directories, and metadata, which can be accessed independently. Users mount specific checkpoints in read-only mode using the mount optioncp=<checkpoint_number>, such as mount -t nilfs2 -r -o cp=2048 /dev/sda1 /mnt/version, enabling concurrent access alongside the active writable mount of the current checkpoint. This facilitates features like online backups or forensic analysis of past states without interrupting operations. There is no inherent limit to the number of checkpoints or versions retained, as they persist until disk space is exhausted, with management handled through filesystem-internal mechanisms.[1]
For recovery, NILFS relies on the latest valid checkpoint to restore consistency after a crash or power failure, achieving near-instantaneous replay without extensive scanning of the log. The system identifies the most recent checkpoint containing a valid super root block, which encapsulates the root of the filesystem structure, and replays only the necessary atomic segments to bring the mount to that state. Checksum validation on log segments ensures the integrity of this process, minimizing data loss to the interval since the last checkpoint. Current implementations maintain snapshots as read-only.[1]
Core Features
Snapshotting Capabilities
NILFS supports continuous snapshotting through its automatic checkpoint mechanism, where read-only snapshots are created at regular intervals, typically every few seconds to tens of seconds during file system operations. These snapshots capture the state of the entire file system, enabling users to restore overwritten or deleted files to their condition from mere seconds prior without interrupting ongoing writes. This feature stems from the log-structured design, where each checkpoint represents a consistent, versioned view of the file system that can be selectively promoted to a persistent snapshot.[11][2] Practical use cases for NILFS snapshots include data protection and recovery, such as restoring accidentally deleted or overwritten files to previous states, which provides versioning benefits for file integrity and tamper detection. In backup scenarios, snapshots facilitate online, incremental copies by allowing read-only mounts alongside the active writable volume, minimizing downtime and enabling efficient data replication without quiescing the system. For debugging and compliance, such as SOX logging, snapshots allow reversion to prior file system versions, preserving historical states for analysis or audit trails.[2][11] Snapshots in NILFS offer mounting flexibility, permitting multiple concurrent read-only mounts of different snapshots on the same volume without impacting the performance of the writable mount or reads from the snapshots themselves. Users mount a specific snapshot using options like-r -o cp=<checkpoint_number>, providing direct access to historical data as if it were a separate file system. There is no inherent limit to the number of snapshots, constrained only by available disk space.[11][2]
Advanced management includes policy-based snapshot retention, configured via the protection_period parameter in /etc/nilfs_cleanerd.conf, which specifies the minimum age (in seconds) before a snapshot or checkpoint becomes eligible for garbage collection, ensuring critical versions are preserved as needed.[12]
Garbage Collection and Maintenance
NILFS employs an online garbage collection mechanism to reclaim disk space by identifying and removing obsolete log segments associated with deleted checkpoints. The process is managed by the background daemonnilfs_cleanerd, which operates continuously on mounted file systems without requiring unmounting, ensuring uninterrupted access to data and snapshots. This daemon uses kernel ioctls, such as NILFS_IOCTL_CLEAN_SEGMENTS, to perform cleanup operations, focusing on segments that contain outdated versions of files generated during the file system's log-structured writes.[1][13][14]
The garbage collection process divides log segments into hot (actively modified) and cold (obsolete or infrequently accessed) categories based on usage patterns, allowing the daemon to prioritize reclamation of cold segments. During cleanup, valid data blocks from these obsolete segments are copied to new, clean segments, after which the old segments are freed, thereby maintaining the integrity of active snapshots and checkpoints. The behavior is configurable through the nilfs_cleanerd.conf file, which supports policies like the timestamp-based selection of segments (processing from oldest to newest) and parameters such as cleanup intervals (defaulting to 5 seconds, or 1 second when clean segments are low) and segment allocation limits (e.g., minimum and maximum clean segments set to 10% and 20% of disk capacity, respectively).[1][15][13]
Space management in NILFS ensures reliable operation by triggering prioritized garbage collection when free space falls below configurable thresholds, such as the minimum number of clean segments, preventing the file system from filling up and halting writes. Additionally, NILFS supports the FITRIM operation via the discard mount option, which notifies the underlying storage device (e.g., SSDs) of freed blocks to enable wear-leveling and optimize thin provisioning. Online resizing is integrated with garbage collection through ioctls like NILFS_IOCTL_RESIZE and NILFS_IOCTL_SET_ALLOC_RANGE, allowing dynamic adjustment of the file system's volume size while the cleaner daemon adapts to the new allocation range without downtime.[1][15][13]
Implementation
Kernel Integration
NILFS2 has been supported in the Linux kernel since version 2.6.30, when it was merged as the first file system originating from Japan.[5] To enable NILFS2 support during kernel compilation, the configuration optionCONFIG_NILFS2_FS must be selected, which builds the nilfs2.ko module or integrates it directly into the kernel.[16] The file system supports block sizes of 1 KB, 2 KB, 4 KB, and 8 KB, with larger sizes up to the system page size also possible depending on the architecture.[17] NILFS2 leverages 64-bit addressing, supporting volume sizes up to approximately 8 exabytes.
Mounting a NILFS2 file system is performed using the standard mount command with the -t nilfs2 option, specifying a block device such as /dev/sda1. The available mount options include barrier (enabled by default) and nobarrier to control write barriers for data integrity on storage devices.[1] The cp=n option allows mounting a specific checkpoint (snapshot) as a read-only file system, where n is the checkpoint number.[1] For synchronous write ordering, order=relaxed (default) or order=strict can be specified to manage how the kernel handles write-back behavior.[1] The discard option enables TRIM support for SSDs to optimize wear leveling, while nodiscard is the default.[1] Error handling is configurable via errors=remount-ro (default, remounts read-only on errors) or errors=panic (triggers a kernel panic).[1]
NILFS2 integrates seamlessly with the Linux kernel's device mapper subsystem, allowing it to be used on logical volumes managed by LVM or other stacked block devices without requiring additional kernel modules beyond the standard nilfs2 module.[1] It operates on any supported block device, such as /dev/sda or /dev/mapper/vg-lv, treating them as generic storage targets.
Recent kernel updates have focused on stability and functionality enhancements for NILFS2. In Linux 6.12, released on November 17, 2024, several fixes were incorporated, including support for common ioctls such as FS_IOC_SETFSLABEL and FS_IOC_GETUUID to enable modern file system operations.[9] As of November 2025, development continues with the appointment of a new co-maintainer, Viacheslav Dubeyko, to sustain ongoing improvements.[4]
User-Space Utilities
The nilfs-utils package provides essential user-space tools for managing NILFS2 filesystems, including formatting, tuning, and maintenance operations.[1] This package is required to create a new NILFS2 filesystem usingmkfs.nilfs2, which formats a block device with the necessary superblock and metadata structures.[18] For tuning filesystem parameters, such as segment size or checkpoint intervals, the nilfs-tune utility serves a role analogous to tune2fs for other filesystems, allowing adjustments to an existing NILFS2 volume.[18] Additionally, the nilfs_cleanerd daemon handles garbage collection by periodically cleaning up obsolete segments to reclaim space, integrating with the kernel's cleaner interface.[1]
Key tools in nilfs-utils enable checkpoint management and filesystem resizing. The lscp command lists all checkpoints and snapshots on a NILFS2 device, displaying details like creation time and sequence numbers.[18] Manual checkpoint creation is supported via mkcp, which triggers an immediate checkpoint for versioning purposes.[18] To manage storage, rmcp allows deletion of specific checkpoints, helping to control the number of retained versions and reduce garbage collection overhead.[18] For dynamic volume adjustments, nilfs-resize resizes a mounted NILFS2 filesystem online, supporting both expansion and shrinkage without unmounting.[19]
Installation of nilfs-utils is straightforward through distribution repositories; for example, on Debian-based systems, it is available as the nilfs-tools package via apt install nilfs-tools.[18] Source builds require dependencies like libuuid-devel and libmount-devel for compilation.[20] NILFS2 filesystems support labels and UUIDs for identification in /etc/fstab, leveraging blkid for reliable mounting.[1]
The utilities integrate with standard Linux tools for broader ecosystem compatibility, including util-linux for mount operations, grub2 for booting NILFS2 root partitions, and udisks for disk management interfaces.[21]
Performance Characteristics
Benchmark Comparisons
Historical benchmarks have shown mixed results for NILFS2 compared to other Linux file systems. In 2009 tests on a Seagate SATA HDD with Linux 2.6.30, NILFS2 underperformed EXT4 and Btrfs in the PostMark benchmark for small-file operations, achieving 357 transactions per second compared to EXT4's 2777.[22] This reflects the overhead of its log-structured design in certain metadata-intensive workloads at the time. NILFS2 has demonstrated advantages in sequential write throughput, often reaching 200-300 MB/s in IOzone tests on HDDs, comparable to or higher than EXT4 and Btrfs due to its continuous logging mechanism, though it trails in random writes for larger blocks.[23] A 2011 study on multiple SSD models (Micron realSSD C300, Samsung 470, OCZ Vertex2, Intel X25-M) under Linux confirmed NILFS2's compatibility with flash storage, outperforming EXT3 and EXT4 in small-block random writes while maintaining similar sequential read speeds around 250 MB/s.[24] In more recent 2020 benchmarks on Linux 5.8 with a Ryzen 9 3900X and Seagate FireCuda 520 NVMe SSD, NILFS2 generally lagged behind EXT4, Btrfs, F2FS, and XFS in most tests, including compile times, I/O throughput, and database workloads, highlighting its niche suitability rather than broad superiority.[25] As of November 2025, no major comprehensive benchmarks for NILFS2 have emerged, though the project has seen renewed interest with an additional maintainer, potentially improving future performance.[4] The 2024 Linux kernel updates in version 6.12 included stability fixes for error handling and state management, enhancing reliability in high-I/O scenarios without introducing performance regressions.[9] Key metrics from historical comparisons include:| Metric | NILFS2 Example | Comparison (e.g., vs. EXT4) | Context/Source |
|---|---|---|---|
| Small-File Creation (transactions/s) | 357 (PostMark) | Slower | HDD, 2009[22] |
| Random Write Throughput (4KB IOPS) | Higher for small blocks | Better than EXT3/EXT4 | SSD random I/O, 2011[24] |
| Sequential Write (MB/s) | 200-300 | Comparable or higher | Log appends on HDD/SSD, 2009[23] |
| Crash Recovery Time | Quick (seconds via checkpoint) | Faster than fsck on large volumes | Design feature[1] |
Optimization Factors
NILFS performance can be tuned through several parameters that balance write efficiency, resource usage, and data integrity. One key tunable is the relaxed order mount option, which permits modified data blocks to be written to disk without creating a checkpoint when no metadata updates occur, accelerating synchronous writes at the cost of slightly relaxed recovery ordering during filesystem recovery.[1] Segment size, set during filesystem creation with mkfs.nilfs2, defaults to 2048 blocks (8 MB assuming 4 KB block size) but can be adjusted based on workload; larger segments reduce commit frequency and metadata overhead for sequential write-heavy tasks, while smaller ones suit random access patterns by minimizing write amplification.[17] The garbage collection (GC) interval, configurable via the nilfs_cleanerd daemon in /etc/nilfs_cleanerd.conf, defaults to 5 seconds between cleaning steps but can be increased to lower CPU usage during idle periods, trading off against potential space reclamation delays.[26] Best practices for optimizing NILFS include enabling the discard mount option on SSDs to issue TRIM commands when blocks are freed, enhancing wear leveling and longevity without significant runtime overhead.[1] Barriers should remain enabled (the default) to ensure proper write ordering for data integrity, particularly on journaling devices, though disabling them via the nobarrier option may yield minor speedups on safe hardware at the risk of corruption after power loss.[1] Administrators should monitor free space levels using tools like df to preempt GC stalls, as low space triggers aggressive cleaning that can temporarily elevate CPU and I/O loads.[27] NILFS is particularly suited to write-intensive workloads requiring versioning, such as databases or system logs, where its continuous checkpointing minimizes data loss and supports efficient recovery without full backups.[2] However, it performs less optimally in read-dominated environments without active snapshot usage, as the log-structured design incurs higher latency for random reads compared to traditional filesystems. Trade-offs include elevated metadata overhead from perpetual logging, which amplifies write amplification on flash media, and periodic CPU spikes from online GC during sustained high-write activity, potentially requiring tuning of cleanerd parameters like max_clean_segments (default 20% of total) to cap reclamation bursts.[26] In benchmark comparisons with other filesystems, these optimizations highlight NILFS's strengths in snapshot-enabled scenarios.[1]Compatibility and Limitations
Platform Support
NILFS2 provides full read/write support on Linux kernels starting from version 2.6.30, where it was merged into the mainline kernel.[5][28] This integration allows seamless use as a native file system on standard block devices. On NetBSD, NILFS is supported in read-only mode since NetBSD 6, implemented as a cleanroom port without write capabilities.[29] There is no native support for NILFS on Windows or macOS; access typically requires running Linux in a virtual machine or, if available, mounting via FUSE-based tools, though no dedicated NILFS FUSE implementation exists.[1] NILFS2 is available across major Linux distributions through standard repositories or packages, including Ubuntu, Debian, Fedora (via kernel inclusion), Arch Linux (through the nilfs-utils package), and others such as Raspbian (for Raspberry Pi), Linux Mint, NixOS, openSUSE, Gentoo, and CentOS (with standalone kernel modules for RHEL-based systems).[30] For partitioning, tools such as GParted include NILFS2 as a supported file system type.[30] In terms of hardware, NILFS2 operates on any block device, including traditional hard disk drives (HDDs) and solid-state drives (SSDs). It is SSD-friendly, featuring support for the discard/TRIM command to optimize performance and longevity on flash storage by notifying the device of unused blocks.[1] While NILFS2 does not natively implement RAID or ZFS layering, it is compatible with Logical Volume Manager (LVM) as an underlying volume management layer, allowing NILFS2 volumes to be created on LVM logical volumes.[1] To set up NILFS2, the kernel must be configured with the NILFS_FS option enabled during compilation, which is included by default in most modern distributions.[1] The nilfs-utils package provides essential user-space tools like mkfs.nilfs2 for formatting and mount.nilfs2 for mounting.[30] An example entry in /etc/fstab for automatic mounting is:/dev/sda1 /mnt/nilfs nilfs2 defaults 0 2, where the file system type is specified as nilfs2.[1] After installation, formatting a partition involves running mkfs -t nilfs2 /dev/block_device, followed by mounting with mount -t nilfs2 /dev/block_device /mountpoint.[1]
