The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "Btrfs"
(Marked this version for translation) |
|||
Line 1: | Line 1: | ||
<translate> | <translate> | ||
<!--T:1--> | |||
BTRFS is a file system based on the copy-on-write (COW) principle, initially designed at Oracle Corporation for use in Linux. The development of Btrfs began in 2007, and since August 2014 the file system's on-disk format has been marked as stable. | BTRFS is a file system based on the copy-on-write (COW) principle, initially designed at Oracle Corporation for use in Linux. The development of Btrfs began in 2007, and since August 2014 the file system's on-disk format has been marked as stable. | ||
<!--T:2--> | |||
In 2015, Btrfs was adopted as the default filesystem for SUSE Linux Enterprise Server 12. SUSE reaffirmed its commitment to Btrfs in 2017 after RedHat announced to stop supporting Btrfs. | In 2015, Btrfs was adopted as the default filesystem for SUSE Linux Enterprise Server 12. SUSE reaffirmed its commitment to Btrfs in 2017 after RedHat announced to stop supporting Btrfs. | ||
<!--T:3--> | |||
Btrfs is intended to address the lack of pooling, snapshots, checksums, and integral multi-device spanning in Linux file systems. | Btrfs is intended to address the lack of pooling, snapshots, checksums, and integral multi-device spanning in Linux file systems. | ||
<!--T:4--> | |||
It is easy to set up and use BTRFS. In this simple introduction, we're going to set up BTRFS under Funtoo Linux using an existing {{c|debian-sources}} or {{c|debian-sources-lts}} kernel, like the one that comes pre-built for you with Funtoo Linux, and we will also be using our BTRFS storage pool for storing data that isn't part of the Funtoo Linux installation itself. Funtoo Linux will boot from a non-BTRFS filesystem, and as part of the initialization process will initialize our BTRFS storage and mount it at the location of our choice. | It is easy to set up and use BTRFS. In this simple introduction, we're going to set up BTRFS under Funtoo Linux using an existing {{c|debian-sources}} or {{c|debian-sources-lts}} kernel, like the one that comes pre-built for you with Funtoo Linux, and we will also be using our BTRFS storage pool for storing data that isn't part of the Funtoo Linux installation itself. Funtoo Linux will boot from a non-BTRFS filesystem, and as part of the initialization process will initialize our BTRFS storage and mount it at the location of our choice. | ||
== Installation == | == Installation == <!--T:5--> | ||
<!--T:6--> | |||
To install BTRFS no aditional steps are needed as it is part of Linux Kernel (in mainline Linux kernel since 2.6.29). Let's emerge the BTRFS userspace tools ({{c|btrfs-progs}}): | To install BTRFS no aditional steps are needed as it is part of Linux Kernel (in mainline Linux kernel since 2.6.29). Let's emerge the BTRFS userspace tools ({{c|btrfs-progs}}): | ||
<!--T:7--> | |||
{{console|body= | {{console|body= | ||
# ##i##emerge btrfs-progs | # ##i##emerge btrfs-progs | ||
}} | }} | ||
<!--T:8--> | |||
BTRFS is now ready for use. | BTRFS is now ready for use. | ||
== BTRFS Concepts == | == BTRFS Concepts == <!--T:9--> | ||
<!--T:10--> | |||
BTRFS can be used to manage the physical disks that it uses, and physical disks are added to a BTRFS volume. Then, BTRFS can create subvolumes from the volume on which files can be stored. | BTRFS can be used to manage the physical disks that it uses, and physical disks are added to a BTRFS volume. Then, BTRFS can create subvolumes from the volume on which files can be stored. | ||
<!--T:11--> | |||
Unlike traditional Linux filesystems, BTRFS filesystems will allocate storage on-demand from the underlying volume. | Unlike traditional Linux filesystems, BTRFS filesystems will allocate storage on-demand from the underlying volume. | ||
<!--T:12--> | |||
In the BTRFS world, the word volume corresponds to a storage pool (ZFS) or a volume group (LVM). | In the BTRFS world, the word volume corresponds to a storage pool (ZFS) or a volume group (LVM). | ||
<!--T:13--> | |||
* ''devices'' - one or multiple underlying physical volumes. | * ''devices'' - one or multiple underlying physical volumes. | ||
* ''volume'' - one large storage pool comprised of all space of the devices and can support different redundancy levels | * ''volume'' - one large storage pool comprised of all space of the devices and can support different redundancy levels | ||
Line 31: | Line 42: | ||
* ''snapshots'' - a read-only copy of a subvolume at a given point in time and/or read-write copy of a ''subvolume'' in time (aka clone). | * ''snapshots'' - a read-only copy of a subvolume at a given point in time and/or read-write copy of a ''subvolume'' in time (aka clone). | ||
== Creating a Volume == | == Creating a Volume == <!--T:14--> | ||
<!--T:15--> | |||
To create a basic BTRFS volume, you will need an extra empty disk. Perform the following steps: | To create a basic BTRFS volume, you will need an extra empty disk. Perform the following steps: | ||
<!--T:16--> | |||
{{console|body= | {{console|body= | ||
# ##i## mkfs.btrfs /dev/sdxy | # ##i## mkfs.btrfs /dev/sdxy | ||
Line 40: | Line 53: | ||
See http://btrfs.wiki.kernel.org for more information. | See http://btrfs.wiki.kernel.org for more information. | ||
<!--T:17--> | |||
Detected a SSD, turning off metadata duplication. Mkfs with -m dup if you want to force metadata duplication. | Detected a SSD, turning off metadata duplication. Mkfs with -m dup if you want to force metadata duplication. | ||
Performing full device TRIM /dev/sdj (223.57GiB) ... | Performing full device TRIM /dev/sdj (223.57GiB) ... | ||
Line 59: | Line 73: | ||
}} | }} | ||
<!--T:18--> | |||
{{c|/dev/sdxy}} should be an unused disk. You may need to use the following command if this disk contains any pre-existing data on it: | {{c|/dev/sdxy}} should be an unused disk. You may need to use the following command if this disk contains any pre-existing data on it: | ||
<!--T:19--> | |||
{{console|body= | {{console|body= | ||
# ##i## mkfs.btrfs -f /dev/sdxy | # ##i## mkfs.btrfs -f /dev/sdxy | ||
}} | }} | ||
<!--T:20--> | |||
Now you can mount the created volume as you would mount any other linux filesystem. | Now you can mount the created volume as you would mount any other linux filesystem. | ||
<!--T:21--> | |||
{{console|body= | {{console|body= | ||
# ##i## mkdir /data | # ##i## mkdir /data | ||
Line 75: | Line 93: | ||
}} | }} | ||
<!--T:22--> | |||
To automatically mount this volume after reboot you need to add a simple fstab entry: | To automatically mount this volume after reboot you need to add a simple fstab entry: | ||
<!--T:23--> | |||
{{console|body= | {{console|body= | ||
/dev/sdxy /data btrfs defaults 0 0 | /dev/sdxy /data btrfs defaults 0 0 | ||
}} | }} | ||
<!--T:24--> | |||
You should now be at the point where you can begin to use BTRFS for a variety of tasks. While there is a lot more to BTRFS than what is covered in this short introduction, you should now have a good understanding of the fundamental concepts on which BTRFS is based. | You should now be at the point where you can begin to use BTRFS for a variety of tasks. While there is a lot more to BTRFS than what is covered in this short introduction, you should now have a good understanding of the fundamental concepts on which BTRFS is based. | ||
<!--T:25--> | |||
[[Category:BTRFS]] | [[Category:BTRFS]] | ||
[[Category:Filesystems]] | [[Category:Filesystems]] |
Revision as of 04:58, September 12, 2018
BTRFS is a file system based on the copy-on-write (COW) principle, initially designed at Oracle Corporation for use in Linux. The development of Btrfs began in 2007, and since August 2014 the file system's on-disk format has been marked as stable.
In 2015, Btrfs was adopted as the default filesystem for SUSE Linux Enterprise Server 12. SUSE reaffirmed its commitment to Btrfs in 2017 after RedHat announced to stop supporting Btrfs.
Btrfs is intended to address the lack of pooling, snapshots, checksums, and integral multi-device spanning in Linux file systems.
It is easy to set up and use BTRFS. In this simple introduction, we're going to set up BTRFS under Funtoo Linux using an existing debian-sources
or debian-sources-lts
kernel, like the one that comes pre-built for you with Funtoo Linux, and we will also be using our BTRFS storage pool for storing data that isn't part of the Funtoo Linux installation itself. Funtoo Linux will boot from a non-BTRFS filesystem, and as part of the initialization process will initialize our BTRFS storage and mount it at the location of our choice.
Installation
To install BTRFS no aditional steps are needed as it is part of Linux Kernel (in mainline Linux kernel since 2.6.29). Let's emerge the BTRFS userspace tools (btrfs-progs
):
root # emerge btrfs-progs
BTRFS is now ready for use.
BTRFS Concepts
BTRFS can be used to manage the physical disks that it uses, and physical disks are added to a BTRFS volume. Then, BTRFS can create subvolumes from the volume on which files can be stored.
Unlike traditional Linux filesystems, BTRFS filesystems will allocate storage on-demand from the underlying volume.
In the BTRFS world, the word volume corresponds to a storage pool (ZFS) or a volume group (LVM).
- devices - one or multiple underlying physical volumes.
- volume - one large storage pool comprised of all space of the devices and can support different redundancy levels
- subvolumes - these are what get mounted and you store files in.
- snapshots - a read-only copy of a subvolume at a given point in time and/or read-write copy of a subvolume in time (aka clone).
Creating a Volume
To create a basic BTRFS volume, you will need an extra empty disk. Perform the following steps:
root # mkfs.btrfs /dev/sdxy btrfs-progs v4.17.1 See http://btrfs.wiki.kernel.org for more information. Detected a SSD, turning off metadata duplication. Mkfs with -m dup if you want to force metadata duplication. Performing full device TRIM /dev/sdj (223.57GiB) ... Label: (null) UUID: d6bcba6e-8fd5-41fc-9bb4-79628c5c928c Node size: 16384 Sector size: 4096 Filesystem size: 223.57GiB Block group profiles: Data: single 8.00MiB Metadata: single 8.00MiB System: single 4.00MiB SSD detected: yes Incompat features: extref, skinny-metadata Number of devices: 1 Devices: ID SIZE PATH 1 223.57GiB /dev/sdxy
/dev/sdxy
should be an unused disk. You may need to use the following command if this disk contains any pre-existing data on it:
root # mkfs.btrfs -f /dev/sdxy
Now you can mount the created volume as you would mount any other linux filesystem.
root # mkdir /data root # mount /dev/sdxy /data root # mount ... /dev/sdxy on /data type btrfs (rw,relatime,ssd,space_cache,subvolid=5,subvol=/)
To automatically mount this volume after reboot you need to add a simple fstab entry:
/dev/sdxy /data btrfs defaults 0 0
You should now be at the point where you can begin to use BTRFS for a variety of tasks. While there is a lot more to BTRFS than what is covered in this short introduction, you should now have a good understanding of the fundamental concepts on which BTRFS is based.