Will Btrfs be the new filesystem?

Will Btrfs be the new file system?

We all know that an operating system need a file system to provide access to the disks. So what is a file system? A file system (often also written as filesystem) is a method of storing and organizing computer files and the data they contain to make it easy to find and access them. The most known examples are:

  • FAT
  • FAT 32
  • NTFS
  • EXT
  • EXT2
  • EXT3
  • EXT4
  • ZFS (Oracle)

Btrfs (“B-tree file system,” pronounced “Butter F S”) is a GPL-licensed copy-on-write file system for Linux announced by Oracle in 2007. This filesystem is still under heavenly development and is NOT ready to be used in an production environment. Btrfs is licensed under the GPL and open for contribution from anyone. Btrfs can do raid0, raid1, raid10. When blocks are read in, checksums are verified and if there are any errors, Btrfs tries to read from an alternate copy.

So why we need Btrfs?

The current filesystems are perfect if you don’t care about data security.

The main Btrfs features :

  • Extent based file storage (2^64 max file size)
  • Space efficient packing of small files
  • Space efficient indexed directories
  • Dynamic inode allocation
  • Writable snapshots
  • Subvolumes (separate internal filesystem roots)
  • Object level mirroring and striping
  • Checksums on data and metadata (multiple algorithms available)
  • Compression
  • Integrated multiple device support, with several raid algorithms
  • Online filesystem check
  • Very fast offline filesystem check
  • Efficient incremental backup and FS mirroring
  • Online filesystem defragmentation

Note that Btrfs does not yet have a fsck tool that can fix errors. While Btrfs is stable, it is possible to get a corrupted filesystem that is irrecoverably if your machine crashes or loses power on disks that don’t handle flush requests correctly. This will be fixed when the fsck tool is ready. As soon as Btrfs is ready there will be a possibility to upgrade your existing EXT partitions to Btrfs. To be honest I would not really trust that. I suggest that you make a backup first before upgrading or you even just backup, format and restore.

Benchmarking

I’ve found some benchmarks on the following link, and on the official Wiki of Btrfs I’ve found the following

  • * 04-2008 Multi-device Benchmarks
  • * 10-2008 Btrfs performance analysis by Steven Pratt and IBM The benchmarks from IBM demonstrate some bottlenecks we have in the extent recording on large workloads. We’re working on fixes for these.
  • * 04-2009 Phoronix Performance Test on Fedora 11 Preview The phoronix workload is mostly CPU based, but they do have a few filesystem benchmarks. Btrfs performs well, but you can see the checksumming and metadata duplication show up on their single disk streaming write workload. dbench in general measures lots of different caching effects, and is not a great measure of everyday performance.
  • * 05-2009 Phoronix Test With SSD Mode This test show that btrfs is slower with ssd option activated. Ssd code has been updated during 2.6.30-rc and is expected to be faster.
  • * 10-2010 One Billion Files Btrfs performs well in comparison to other file systems, when there are a billion files in the filesystem.
  • * 11-2010 Phoronix: The Linux 2.6.37 Kernel With EXT4 & Btrfs Comparison between Btrfs and Ext4.
  • * 12-2010 Benchmarks Of The Btrfs Space Cache Option Comparing the performance of Btrfs using the default mount options, using the space_cache mount option, using the compress mount option for Btrfs file compression, and lastly using both the space_cache and compression mount options to benefit from the free space caching and Zlib compression.

Let’s get started!

Debian 6 has been released a couple of days ago and while installing it I noticed that I could choose a new filesystem, the Btrfs. First I tried to install it on my root partition but that failed :D apparently grub isn’t ready yet to work with the new filesystem. My backup plan was to create a few EXT4 partitions and my /home partion as the Btrfs. A couple of minutes later my system was installed and up & running. On the official wiki I’ve found the commands that I can use to manage my btrfs.

root@debian-testing:~# apt-get install btrfs-tools

The new commands

Manpages: mkfs.btrfs(8), btrfsctl(8), btrfs-show(8), mkfs.btrfs(8)

On my test server I have a disk (second disk) with 500GB. I partitioned it and formatted it with the following commands

root@debian-testing:~# fdisk -l

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001b2a1

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       60802   488384512   83  Linux

root@debian-testing:~# mkfs.btrfs /dev/sdb1

WARNING! – Btrfs Btrfs v0.19 IS EXPERIMENTAL DON’T USE IT IN A STABLE ENVIRONMENT
WARNING! – see http://btrfs.wiki.kernel.org before using

fs created label (null) on /dev/sdb1
nodesize 4096 leafsize 4096 sectorsize 4096 size 465.76GB
Btrfs Btrfs v0.19

My system has 1 disk with the Btrfs system on it

Btrfsctl – control a btrfs filesystem

root@debian-testing:~# btrfs-show
Label: none  uuid: be82c4df-9780-48b2-9625-e0e586b5c106
Total devices 1 FS bytes used 28.00KB
devid    1 size 465.76GB used 2.04GB path /dev/sdb1
Btrfs Btrfs v0.19

So now that Btrfs is up and running lets see what kind of commands we all have.

  • btrfs (btrfs is used to control the filesystem and the files and directories stored)
  • btrfs-convert
  • btrfs-debug-tree
  • btrfs-map-logical
  • btrfstune
  • btrfsck (btrfsck is used to check a btrfs filesystem.) does not really work for the moment :)
  • btrfsctl (btrfsctl – control a btrfs filesystem)
  • btrfs-image (btrfs-image  is  used to create an image of a btrfs filesystem.)
  • btrfs-show (btrfs-show – scan the /dev directory for btrfs partitions and print results.
  • btrfs-vol

I see a lot of new commands and I’m only going to explain a few of them. You will need to study yourself about Btrfs, remember this filesystem is not ready for deployment! Most of the commands are qieut easy to understand, the btrfs-convert command will convert and EXT partition to an Btrfs partition.

The Btrfs-show command will give us all the partitions with a btrfs filesystem. It will also show how much space is used on the specific disk.

root@debian-testing:/mnt# btrfs-show
Label: none  uuid: f49498d5-573e-412a-8093-a2fd7033a24b
Total devices 1 FS bytes used 356.68MB
devid    1 size 465.76GB used 3.04GB path /dev/sdb1
Btrfs Btrfs v0.19

Conclusion

There is still a lot of work on btrfs, but it seems to be quiet stable for me. I’m hoping for a stable release soon (or one with a fsck (that really would be nice)). When Btrfs supports the RAID 5 I will make a full new report. For now this is my final conclusion. Btrfs seems to be a really nice filesystem but there is still a lot of work. Like the the people of EXT4 said, Btrfs is the way forward. Data security will only become more important when people start to use the cloud. It will not only be important to have quick access to the data but also to make sure that the data’s integrity is saved.

If you want to learn more about btrfs use google or ask me some questions.

Official wiki

Comments are closed.