The software described in this documentation is either in Extended Support or Sustaining Support. See https://www.oracle.com/us/support/library/enterprise-linux-support-policies-069172.pdf for more information.
Oracle recommends that you upgrade the software described by this documentation as soon as possible.

4.2 Creating a Btrfs File System

Note

If the btrfs-progs package is not already installed on your system, use yum to install it.

You can use the mkfs.btrfs command to create a btrfs file system that is laid out across one or more block devices. The default configuration is to stripe the file system data and to mirror the file system metadata across the devices. If you specify a single device, the metadata is duplicated on that device unless you specify that only one copy of the metadata is to be used. The devices can be simple disk partitions, loopback devices (that is, disk images in memory), multipath devices, or LUNs that implement RAID in hardware.

The following table illustrates how to use the mkfs.btrfs command to create various btrfs configurations.

Command

Description

mkfs.btrfs block_device

Create a btrfs file system on a single device. For example:

mkfs.btrfs /dev/sdb1

mkfs.btrfs -L label block_device

Create a btrfs file system with a label that you can use when mounting the file system. For example:

mkfs.btrfs -L myvolume /dev/sdb2

Note

The device must correspond to a partition if you intend to mount it by specifying the name of its label.

mkfs.btrfs -m single block_device

Create a btrfs file system on a single device, but do not duplicate the metadata on that device. For example:

mkfs.btrfs -m single /dev/sdc

mkfs.btrfs block_device1 block_device2 ...

Stripe the file system data and mirror the file system metadata across several devices. For example:

mkfs.btrfs /dev/sdd /dev/sde

mkfs.btrfs -m raid0 block_device1 block_device2 ...

Stripe both the file system data and metadata across several devices. For example:

mkfs.btrfs -m raid0 /dev/sdd /dev/sde

mkfs.btrfs -d raid1 block_device1 block_device2 ...

Mirror both the file system data and metadata across several devices. For example:

mkfs.btrfs -d raid1 /dev/sdd /dev/sde

mkfs.btrfs -d raid10 -m raid10 block_device1 block_device2 block_device3 block_device4

Stripe the file system data and metadata across several mirrored devices. You must specify an even number of devices, of which there must be at least four. For example:

mkfs.btrfs -d raid10 -m raid10 /dev/sdf \

/dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk

When you want to mount the file system, you can specify it by any of its component devices, for example:

# mkfs.btrfs -d raid10 -m raid10 /dev/sd[fghijk]
# mount /dev/sdf /raid10_mountpoint

To find out the RAID configuration of a mounted btrfs file system, use this command:

# btrfs filesystem df mountpoint
Note

The btrfs filesystem df command displays more accurate information about the space used by a btrfs file system than the df command does.

Use the following form of the btrfs command to display information about all the btrfs file systems on a system:

# btrfs filesystem show