Difference between revisions of "Btrfs"

From ArchWiki
Jump to: navigation, search
m (Defragmentation)
(improved formatting throughout)
Line 8: Line 8:
 
{{Article summary end}}
 
{{Article summary end}}
  
Btrfs is a new copy on write (COW) filesystem for Linux aimed at implementing advanced features while focusing on fault tolerance, repair and easy administration. Jointly developed at Oracle, Red Hat, Fujitsu, Intel, SUSE and many others, Btrfs s licensed under the GPL and open for contribution from anyone.
+
Btrfs is a new copy on write (COW) filesystem for Linux aimed at implementing advanced features while focusing on fault tolerance, repair and easy administration. Jointly developed by Oracle, Red Hat, Fujitsu, Intel, SUSE and many others, Btrfs is licensed under the GPL and open for contribution from anyone.
  
 
== Recent Developments and News Links ==
 
== Recent Developments and News Links ==
 
*[http://www.phoronix.com/scan.php?page=news_item&px=MTA4Mzc Summary of Chris Mason's talk from LFCS 2012]
 
*[http://www.phoronix.com/scan.php?page=news_item&px=MTA4Mzc Summary of Chris Mason's talk from LFCS 2012]
*On 28-Mar-2012, {{Pkg|btrfs-progs}} includes btrfsck, '''a tool that can fix errors on btrfs filesystems.'''
+
*On 2012-03-28, {{Pkg|btrfs-progs}} includes btrfsck, '''a tool that can fix errors on btrfs filesystems.'''
 
*Oracle has packaged this version of btrfs-progs and released it to their customers Oracle Linux 6 and backported to 5.
 
*Oracle has packaged this version of btrfs-progs and released it to their customers Oracle Linux 6 and backported to 5.
 
*Arch Linux supplies this version in core/btrfs-progs (since version 0.19.20120328-1).
 
*Arch Linux supplies this version in core/btrfs-progs (since version 0.19.20120328-1).
Line 18: Line 18:
 
== Installation ==
 
== Installation ==
  
Btrfs support is included in the the core/linux package (hardcoded into the kernel).  User space utils are available from [core]:
+
Btrfs support is included in the the [core]/{{pkg|linux}} package (hardcoded into the kernel).  User space utilities are available in [core]/{{pkg|btrfs-progs}}.
  
# pacman -S btrfs-progs
+
If using btrfs as the root filesystem, users ''may'' want to install {{AUR|mkinitcpio-btrfs}} from the [[Arch User Repository|AUR]]. This package will install a mkinitcpio hook intended for those who wish to have a single or multi-drive BTRFS file system as their {{ic|/}} (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.
 
+
If using btrfs as the root filesystem, users ''may'' want to install {{AUR|mkinitcpio-btrfs}} from AUR. 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 ==
 
== Basic Use ==
Line 29: Line 27:
 
  # mkfs.btrfs [options] dev [dev ...]
 
  # mkfs.btrfs [options] dev [dev ...]
  
One 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.
+
One can select multiple devices to create a RAID. Supported RAID levels include RAID 0, RAID 1 and RAID 10. By default, metadata is mirrored and data is striped.
  
 
=== Convert Ext3/4 to Btrfs ===
 
=== Convert Ext3/4 to Btrfs ===
{{Warning|Grub cannot boot btrfs root.  Users need to install either [[Grub2]] or [[Syslinux]]!  This guide assumes users are aware of this limitation to Grub.}}
+
{{Warning|GRUB cannot boot btrfs root.  Users need to install either [[GRUB2]] or [[Syslinux]]!  This guide assumes users are aware of this limitation in GRUB.}}
  
 
# Boot a live CD (Arch for example)
 
# Boot a live CD (Arch for example)
Line 40: Line 38:
 
# Install btrfs-progs (make sure versions of dependencies match: glibc,e2fsprogs)
 
# Install btrfs-progs (make sure versions of dependencies match: glibc,e2fsprogs)
 
# Run btrfs-convert
 
# Run btrfs-convert
# Mount the converted partition and modify the /etc/fstab specifying either 'auto' or 'btrfs' for the partition type.
+
# Mount the converted partition and modify the {{ic|/etc/fstab}} file specifying either 'auto' or 'btrfs' for the partition type.
# Chroot into the system and rebuild the grub2 entry (see [[Install from Existing Linux]] and [[Grub2]] articles if unfamiliar with this procedure.
+
# Chroot into the system and rebuild the grub2 entry (see [[Install from Existing Linux]] and [[GRUB2]] articles if unfamiliar with this procedure.
  
 
=== Subvolumes ===
 
=== Subvolumes ===
Line 73: Line 71:
  
 
== Compression ==
 
== Compression ==
Btrfs supports transparent compression, which means every file on the partition is automatically compressed. This does not only reduce the size of those files, but also [http://www.phoronix.com/scan.php?page=article&item=btrfs_compress_2635&num=1 improves performance], in particular if using the [http://www.phoronix.com/scan.php?page=article&item=btrfs_lzo_2638&num=1 lzo algorithm]. Compression is enabled using the compress=gzip or compress=lzo mount options. Only files created or modified after the mount option is added will be compressed, so to fully benefit from compression it should be enabled during installation. After [[Beginners%27_Guide#Prepare_hard_drive|preparing the hard drive]], simply switch to another terminal (Ctrl+Alt+number), and run the following command:
+
Btrfs supports transparent compression, which means every file on the partition is automatically compressed. This does not only reduce the size of those files, but also [http://www.phoronix.com/scan.php?page=article&item=btrfs_compress_2635&num=1 improves performance], in particular if using the [http://www.phoronix.com/scan.php?page=article&item=btrfs_lzo_2638&num=1 lzo algorithm]. Compression is enabled using the compress=gzip or compress=lzo mount options. Only files created or modified after the mount option is added will be compressed, so to fully benefit from compression it should be enabled during installation. After [[Beginners%27_Guide#Prepare_hard_drive|preparing the hard drive]], simply switch to another terminal ({{keypress|Ctrl+Alt+number}}), and run the following command:
 
  # mount -o remount,compress=lzo /dev/partition /mnt/target # note: replace /dev/partition by the partition on which Arch Linux is installed.
 
  # mount -o remount,compress=lzo /dev/partition /mnt/target # note: replace /dev/partition by the partition on which Arch Linux is installed.
  

Revision as of 22:06, 4 June 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Summary help replacing me
Provides an overview and setup of Btrfs on Arch Linux.
Related
Installing on Btrfs root

Btrfs is a new copy on write (COW) filesystem for Linux aimed at implementing advanced features while focusing on fault tolerance, repair and easy administration. Jointly developed by Oracle, Red Hat, Fujitsu, Intel, SUSE and many others, Btrfs is licensed under the GPL and open for contribution from anyone.

Recent Developments and News Links

  • Summary of Chris Mason's talk from LFCS 2012
  • On 2012-03-28, btrfs-progs includes btrfsck, a tool that can fix errors on btrfs filesystems.
  • Oracle has packaged this version of btrfs-progs and released it to their customers Oracle Linux 6 and backported to 5.
  • Arch Linux supplies this version in core/btrfs-progs (since version 0.19.20120328-1).

Installation

Btrfs support is included in the the [core]/linux package (hardcoded into the kernel). User space utilities are available in [core]/btrfs-progs.

If using btrfs as the root filesystem, users may want to install mkinitcpio-btrfsAUR from the AUR. 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

Format a New Partition to Btrfs

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

One can select multiple devices to create a RAID. Supported RAID levels include RAID 0, RAID 1 and RAID 10. By default, metadata is mirrored and data is striped.

Convert Ext3/4 to Btrfs

Warning: GRUB cannot boot btrfs root. Users need to install either GRUB2 or Syslinux! This guide assumes users are aware of this limitation in GRUB.
  1. Boot a live CD (Arch for example)
  2. Enable [remote-core] and [remote-testing]
  3. Setup the network
  4. modprobe btrfs
  5. Install btrfs-progs (make sure versions of dependencies match: glibc,e2fsprogs)
  6. Run btrfs-convert
  7. Mount the converted partition and modify the /etc/fstab file specifying either 'auto' or 'btrfs' for the partition type.
  8. Chroot into the system and rebuild the grub2 entry (see Install from Existing Linux and GRUB2 articles if unfamiliar with this procedure.

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 optionally be given a quota of blocks. 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. One can also mount the subvolumes with different mount options giving more flexibility in security.

To create a subvolume:

# btrfs subvolume create [<dest>/]

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

rootflags=subvol=<whatever you called the subvol>

In the kernel boot parameters. It makes system rollbacks possible.

If using for the root partition, it is advisable to add crc32c to the modules array in /etc/mkinitcpio.conf as well as adding btrfs to the HOOKS array in /etc/mkinitcpio.conf.

Snapshots

To create a snapshot:

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

Snapshots are not recursive, this means that every subvolume inside subvolume will be an empty directory inside the snapshot.

Defragmentation

Btrfs supports online defragmentation. To defragment the metadata of the root folder, simply do:

# btrfs filesystem defragment /

This will not defragment the entire system. For more information, see this page on the btrfs wiki.

Compression

Btrfs supports transparent compression, which means every file on the partition is automatically compressed. This does not only reduce the size of those files, but also improves performance, in particular if using the lzo algorithm. Compression is enabled using the compress=gzip or compress=lzo mount options. Only files created or modified after the mount option is added will be compressed, so to fully benefit from compression it should be enabled during installation. After preparing the hard drive, simply switch to another terminal (Template:Keypress), and run the following command:

# mount -o remount,compress=lzo /dev/partition /mnt/target # note: replace /dev/partition by the partition on which Arch Linux is installed.

Verify if compression is enabled with the mount command. After the installation is finished, add compress=lzo to the mount options of the root filesystem in /etc/fstab.

Resources