Getting started

From btrfs Wiki
Revision as of 16:57, 11 December 2008 by Mason (Talk | contribs)

Jump to: navigation, search



Download the latest utility programs and modules from:

Example: btrfs-0.16.tar.bz2, btrfs-progs-0.16.tar.bz2

See also Btrfs source repositories for SCM access, and Hot Fixes for links to the latest updates.

Compiling the Kernel Module

Btrfs uses libcrc32c in the kernel for file and metadata checksums. You need to compile the kernel with: CONFIG_LIBCRC32C=m or CONFIG_LIBCRC32C=y

If you are running the latest Btrfs code from the unstable repository, you'll need to also configure zlib compression into your kernel:

CONFIG_ZLIB_INFLATE and CONFIG_ZLIB_DEFLATE for btrfs newer than v0.16

Once your kernel is setup, typing make in the btrfs module sources will build against the running kernel. When the build is complete:

modprobe libcrc32c ; modprobe zlib_inflate zlib_deflate ; insmod btrfs.ko

Compiling Btrfs Utilities

The Btrfs utility programs require libuuid to build. This can be found in the e2fsprogs sources, and is usually available as libuuid, uuid-dev or e2fsprogs-devel from various distros. Building the ext3 conversion tools requires libe2fs, which is usually available in e2fsprogs-devel as well.

Building the utilities is just make. If you would also like the ext3 conversion program, type make convert.

make install will copy the programs into /usr/local/bin

Basic Filesystem Commands

  • mkfs.btrfs: create a filesystem
  • btrfsctl: control program to create snapshots and subvolumes and scan devices
    • Scan all devices looking for btrfs filesystems, or scan just one partition
      • btrfsctl -a
      • btrfsctl -A /dev/sda2
  • Snapshots and subvolumes
    • mount -t btrfs -o subvol=. /dev/sda2 /mnt
    • btrfsctl -s new_subvol_name /mnt
    • btrfsctl -s snapshot_of_default /mnt/default
    • btrfsctl -s snapshot_of_new_subvol /mnt/new_subvol_name
    • btrfsctl -s snapshot_of_a_snapshot /mnt/snapshot_of_new_subvol
      • ls /mnt
        • default snapshot_of_a_snapshot snapshot_of_new_subvol
        • new_subvol_name snapshot_of_default
  • btrfsck: do a limited check of the FS extent trees.
  • debug-tree: print all of the FS metadata in text form
    • debug-tree /dev/sda2 >& big_output_file
  • If a problem occures you can create an image of the fs with btrfs-image and send it to the devs. (All data will be zeroed, but metadata and the like is preserved.)
    • btrfs-image -c 9 /dev/sda2 /tmp/btrfs_dump.z

More Informations on the commands.

Personal tools