Btrfs

From ArchWiki
Revision as of 01:13, 18 November 2010 by Eigrad (Talk | contribs) (Resources)

Jump to: navigation, search

Btrfs is a new copy on write filesystem for Linux aimed at implementing advanced features while focusing on fault tolerance, repair and easy administration. Initially developed by Oracle, Btrfs is licensed under the GPL and open for contribution from anyone. Linux has a wealth of filesystems to choose from, but we are facing a number of challenges with scaling to the large storage subsystems that are becoming common in today's data centers. Filesystems need to scale in their ability to address and manage large storage, and also in their ability to detect, repair and tolerate errors in the data stored on disk. Btrfs is under heavy development, but every effort is being made to keep the filesystem stable and fast. As of 2.6.31, they only plan to make forward compatible disk format changes. Note: Btrfs does not yet have a fsck tool that can fix errors. While Btrfs is stable on a stable machine, it is currently possible to corrupt a filesystem 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.

Installation

To install:

Template:Filename

There are helper programs in AUR such as

If using btrfs as your root filesystem, you may also want to install mkinitcpio-btrfs from AUR http://aur.archlinux.org/packages.php?ID=33376

This package will install a mkinitcpio hook intended for those who wish to have a single or multi-drive BTRFS file system as their / (root). the hook will ensure that the chosen root device from the kernel command line is intact and safe to boot. If root is not a BTRFS device, the hook is quietly skipped

Basic Use

To format a device to btrfs

mkfs.btrfs [options] dev [dev ...]

You can select multiple devices to create a raid. Supported raids include raid1, raid0, and raid 10. By default, metadata is mirrored and data is striped.

Subvolumes

One of the features of btrfs is the use of subvolumes. Subvolumes are basically a named btree that holds files and directories. They have inodes inside the tree of tree roots and can have non-root owners and groups. Subvolumes can be given a quota of blocks, and once this quota is reached no new writes are allowed. All of the blocks and file extents inside of subvolumes are reference counted to allow snapshotting. Similar to the dynamically expanding storage of a virtual machine that will only use as much space on a device as needed. Eliminating several half-filled partitions. You can also mount the subvolumes with different mount options giving more flexibility in security.

To create a subvolume:

btrfs subvolume create [<dest>/]

For flexibility, you should install your system INTO A DEDICATED SUBVOLUME, and use:

rootflags=subvol=<whatever you called the subvol>

in your kernel boot parameters. It makes system rollbacks possible.

If using for your root partition you'll want to add crc32c to the modules array in your Template:Filename as well as add Template:Filename to the HOOKS array.

Snapshots

To create a snapshot:

btrfs subvolume snapshot <source> [<dest>/]<name>

See also

Resources