There has been a lot of buzz regarding future Linux filesystems lately. Btrfs, Reiser4, and exofs have received most of the hype. Lurking in the shadows, NiLFS2 is waiting for its own time in the spotlight, but for now, there is a July 2009 benchmark comparison from Phoronix.
NiLFS2, which stands for New Implementation of a Log-structure File System, is a log-structured filesystem being developed by Nippon Telephone and Telegraph CyberSpace Laboritories. The current version, which is still under active development and, like its peers, still not ready for production purposes, was first included in the mainline Linux kernel version 2.6.30. With current support for the basic POSIX filesystem features, continuous snapshots, and more, along with planned support of online resizing and defragmentation and checkpoint rollback, NiLFS2 certainly has great potential.
Now, to apply that potential, a Linux distribution with version 2.6.30 or later of the kernel with NiLFS2 support is required, with version 2.6.31.6 as the current stable kernel at the time of this writing. If a new kernel must be compiled, the NiLFS2 option is under the "File systems" menu during the configuration process. It is still labeled experimental. Also required are the NiLFS2 userland tools, which are available for free in both binary and source-code formats from the NiLFS download page. After these prerequisites are taken care of, it's time to create and explore a NiLFS2 filesystem.
Note: The following tutorial assumes the use of the "sudo" utility. If you prefer an alternative method of superuser action, please adjust accordingly. Also, as NiLFS2 is still experimental, and is clearly identified as such, use of it is done at the user's own risk. As a precaution, this tutorial illustrates use of NiLFS2 in a temporary loopback mounted image.
1. Create your image:
$ dd if=/dev/zero of=/tmp/disk.img bs=384M count=1
This creates a temporary disk image of around 400MB.
2. Make your new filesystem on the disk image:
$ mkfs.nilfs2 /tmp/disk.img
For those wishing to specify filesystem creation options, see the mkfs.nilfs2 manpage.
3. Mount the new filesystem image using the loop device and enter the new filesystem:
$ sudo losetup /dev/loop0 /tmp/disk.img
$ sudo mkdir /mnt/nilfs
$ sudo mount.nilfs2 /dev/loop0 /mnt/nilfs/
$ cd /mnt/nilfs
Now, simply create or copy some files into your NiLFS2 filesystem, to start exploring some of the basic features. The four main commands are:
lscp list checkpoints or snapshots.
mkcp make a checkpoint or a snapshot.
chcp convert an existing checkpoint to a snapshot or vice versa.
rmcp reclaim specified checkpoint or checkpoints.
For more details on each of these commands see their respective manpages.
Once some files are present in the system, the checkpoints created in the process can be viewed with:
$ lscp
Each checkpoint has its own number. To make a snapshot of the current filesystem state, run:
$ mkcp -s
Running "lscp" again will now show two checkpoints and a snapshot.
It is helpful to know that snapshots persist, but checkpoints can be reclaimed when space is needed using:
$ rmcp checkpoint-number
If you add more files, but wish to view a previous snapshot, the desired snapshot can be mounted, read-only, in a directory of your choice with a command such as:
$ sudo mount.nilfs2 -r /dev/loop0 /mnt/nilfs-ss/ -o cp=X
Where "X" is the number of the snapshot you wish to mount. To unmout the snapshot, simply unmount the snapshot directory. In the future, users shoule be able to roll the filesystem back to a specified snapshot.
Even though the project is still under development, there is a lot of potential. Users can help by testing, filing bug reports, and offering feedback. Be watching for continued progress, improvements, and evolution from NiLFS2.












Comments