Size: 14609
Comment: Add unsupported tag as page appears to relate to old versions of Ubuntu
|
Size: 8714
Comment: Major cleanup, removed EOL-information, removed all general non-Ubuntu information, created a much shorter overview, switched btrfs scrub to use the official tool, ...
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
<<Include(Tag/Unsupported)>> |
|
Line 4: | Line 2: |
= What is btrfs? = The B-tree file system is a “copy-on-write (COW)” check-summed file system with multi-device support and writable snapshots. A snapshot is an image or copy of the file system at a point in time. This feature facilitates system rollback and instant backup when combined with supporting software. Since the snapshot is writable, it can be modified. A subvolume is like a directory - it has a name, there's nothing on it when it is created, and it can hold files and other directories. There's at least one subvolume in every Btrfs filesystem, the "default" subvolume. The equivalent in Ext4 would be a filesystem. Each subvolume behaves as a individual filesystem. The difference is that in Ext4 you create each filesystem in a partition, in Btrfs however all the storage is in the 'pool', and subvolumes are created from the pool, you don't need to partition anything. You can create as many subvolumes as you want, as long as you have storage capacity. Btrfs uses Rodeh's b-trees which are COW friendly. [[http://www.cs.tau.ac.il/~ohadrode/papers/btree_TOS.pdf]] Check-summing is a data integrity method. Multi-device support is part of the subvolume structure btrfs uses to grow or shrink a file system. “A short history of btrfs” (LWN.NET July 22, 2009) by Valerie Aurora (formerly Henson) is available at [[http://lwn.net/Articles/342892/]] A 45 minute video "Btrfs: Filesystem Status and Future Plans" by Chris Mason of Oracle is available at [[http://video.linux.com/videos/btrfs-filesystem-status-and-new-features]] (uploaded April 11, 2012) More Information on btrfs is available at [[https://btrfs.wiki.kernel.org [[https://btrfs.wiki.kernel.org/index.php/Category:Documentation]] and [[http://en.wikipedia.org/wiki/Btrfs]] Btrfs is under heavy development, but with Linux 2.6.31 the Btrfs disk format has been finalized and is not considered experimental any more. [[http://lkml.org/lkml/2010/6/12/66]] = Stability = Oracle's Unbreakable Enterprise Kernel Release 2 supports the cutting-edge Btrfs file system [[http://www.itworld.com/open-source/258238/oracle-updates-its-linux-kernel-new-advanced-file-system]] Fedora17 to seriously consider Btrfs as default file system [[https://fedoraproject.org/wiki/Features/F17BtrfsDefaultFs]] Initial online fsck support announced June 30, 2011. [[http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg10864.html]] "The main concern against BTRFS is not stability, but the lack of a functional fsck utility." [[http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg06277.html]] Update on btrfsck from Chris Mason (October 4, 2011): http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg12598.html Update on btrfsck from Chris Mason (August 18, 2011): http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg11836.html Btrfs wins Linux New Media Award (Chris Mason March 23, 2011). http://oss.oracle.com/~mason/btrfs/btrfs_award.jpg = Features = * Extent based file storage (2^64 max file size) * Space efficient packing of small files * Space efficient indexed directories * Dynamic inode allocation * Writable snapshots * Subvolumes (separate internal filesystem roots) * Object level mirroring and striping * Checksums on data and metadata (multiple algorithms available) * Compression * Integrated multiple device support, with several raid algorithms * Online filesystem check * Very fast offline filesystem check * Efficient incremental backup and FS mirroring * Online filesystem defragmentation |
= Overview = 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. Btrfs is under heavy development, but every effort is being made to keep the filesystem stable and fast. Because of the speed of development, running the latest possible Linux kernel is highly recommended. More Information on Btrfs is available at [[http://btrfs.ipv5.de]] (currently most up-to-date), [[https://btrfs.wiki.kernel.org]] (old wiki) and [[http://en.wikipedia.org/wiki/Btrfs]] == Features == * Extent based file storage * 2^64 byte == 16 EiB maximum file size * Space-efficient packing of small files * Space-efficient indexed directories * Dynamic inode allocation * Writable snapshots, read-only snapshots * Subvolumes (separate internal filesystem roots) * Checksums on data and metadata * Compression (gzip and LZO) * Integrated multiple device support . File Striping, File Mirroring, and File Striping+Mirroring implementations * Efficient incremental backup * Background scrub process for finding and fixing errors on files with redundant copies * Online filesystem defragmentation * Offline filesystem check |
Line 125: | Line 87: |
= Fresh Install on 10.10 Maverick = Obtain the latest install cd from [[http://cdimage.ubuntu.com/]] Do a regular installation except use manual partitioning to create: * a ext2 or ext3 partition of about 250MB for /boot * a btrfs partition for / * a linux swap partition large enough to allow for suspending to RAM (amount of ram plus 100MB is a good size) If you don't need suspend support then not more than 2GB is sufficent. |
|
Line 139: | Line 91: |
= Installing on 8.10 Intrepid = == PPA deb packages == The PPA specified in this community documentation is out of date, more recent packages can be found in the standard repositories. [[https://launchpad.net/~brcha/+archive/ppa]] Lines for sources.list.d: {{{ deb http://ppa.launchpad.net/brcha/ppa/ubuntu intrepid main deb-src http://ppa.launchpad.net/brcha/ppa/ubuntu intrepid main }}} Add the GPG key: {{{ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 17f547c39c5c4071e254d0a7313d312748a22a95 }}} Download module source and btrfs tools: {{{ sudo apt-get install btrfs btrfs-progs module-assistant }}} Build and install kernel module: {{{ sudo module-assistant auto-install btrfs sudo modprobe btrfs }}} == Compile from Source == '''NOT ACTUALLY WORKING YET''' [[http://btrfs.wiki.kernel.org/index.php/Getting_started | btrfs wiki getting started page]] === Kernel Module Dependencies === 8.10 Kernel 2.6.27-9-generic * CONFIG_LIBCRC32C=m * CONFIG_ZLIB_INFLATE=y * CONFIG_ZLIB_DEFLATE=m * build-essential: make, compiler, etc * linux-headers-2.6.27-9-generic: latest kernel headers {{{ sudo apt-get install build-essential linux-headers-2.6.27-9-generic }}} Patch: [[http://permalink.gmane.org/gmane.comp.file-systems.btrfs/2562]] Download, patch and compile code: {{{ wget http://www.kernel.org/pub/linux/kernel/people/mason/btrfs/btrfs-0.17.tar.bz2 tar -jxvf btrfs-0.17.tar.bz2 cd btrfs-0.17 #apply patch make }}} '''Currently btrfs does not work with kernel 2.6.27''' Ensure modules are up and running, and insert btrfs module into kernel. {{{ sudo modprobe libcrc32c zlib_inflate zlib_deflate sudo insmod btrfs.ko }}} === btrfs progs dependencies === {{{ sudo apt-get install e2fsprogs uuid-dev }}} {{{ wget http://www.kernel.org/pub/linux/kernel/people/mason/btrfs/btrfs-progs-0.17.tar.bz2 tar -jxvf btrfs-progs-0.17.tar.bz2 make }}} '''btrfs-progs compile fine''' = Demo Script = A demo of how to use btrfs features by Valerie Aurora (formerly Henson): [[attachment:btrfs_demo.sh]] = Snapshots & Subvolumes = |
= Managing Btrfs = == Snapshots & Subvolumes == |
Line 256: | Line 125: |
= Adding Filesystem Compression = | == Adding Filesystem Compression == |
Line 280: | Line 149: |
= Display Filesystem Information = | == Display Filesystem Information == |
Line 310: | Line 179: |
= Validate Filesystem Integrity = | == Validate Filesystem Integrity == |
Line 332: | Line 202: |
Install btrfs-scrub using instructions at [[http://xercestech.com/how-to-scrub-btrfs.geek]] {{{ btrfs-scrub Videos }}} The btrfs-scrub routine reads every file in the directory Videos. Use dmesg to view errors. = Improve Filesystem Performance = |
{{{ btrfs scrub Videos }}} == Improve Filesystem Performance == |
Line 344: | Line 212: |
In this case the Rodeh b-trees in path /home/myhome are being balanced. This could take some time. | This operation could take some time. |
Line 351: | Line 219: |
= How to use = * How to format disk as btrfs * How to grow/shrink file system * How to create snapshots * How to access snapshots * How to convert ext2/3(/4?) partitions to btrfs * How to create an image of a btrfs file system * How to restore from an image of a btrfs file system * How to recover from a failed device * How to add another device to file system [[http://btrfs.wiki.kernel.org/index.php/Category:Documentation|btrfs wiki documentation category]] = Links = * [[http://btrfs.wiki.kernel.org/|btrfs home page]] * [[http://en.wikipedia.org/wiki/Btrfs|btrfs wikipedia page]] * [[http://geb.german-elite.net/blog.php?b=113| Installation BTRFS 0.18 on Ubuntu Intrepid(german)]] |
|
Overview
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.
Btrfs is under heavy development, but every effort is being made to keep the filesystem stable and fast. Because of the speed of development, running the latest possible Linux kernel is highly recommended.
More Information on Btrfs is available at http://btrfs.ipv5.de (currently most up-to-date), https://btrfs.wiki.kernel.org (old wiki) and http://en.wikipedia.org/wiki/Btrfs
Features
- Extent based file storage
- 2^64 byte == 16 EiB maximum file size
- Space-efficient packing of small files
- Space-efficient indexed directories
- Dynamic inode allocation
- Writable snapshots, read-only snapshots
- Subvolumes (separate internal filesystem roots)
- Checksums on data and metadata
- Compression (gzip and LZO)
- Integrated multiple device support
- File Striping, File Mirroring, and File Striping+Mirroring implementations
- Efficient incremental backup
- Background scrub process for finding and fixing errors on files with redundant copies
- Online filesystem defragmentation
- Offline filesystem check
Ubuntu-specific subvolume layout in 11.04 and later
In Ubuntu 11.04 and later, the installer sets up btrfs with a specific layout:
The default subvolume to mount is always the top of the btrfs tree (subvolid=5).
Subvolumes are created below the top of the btrfs tree as needed, e.g. for / and /home, it creates subvolumes named @ and @home. This means that specific options are needed in order to mount the subvolumes, instead of the default btrfs tree top:
The @ subvolume is mounted to / using the kernel boot option rootflags=subvol=@
The @home subvolume (if it is used), is mounted via the mount option subvol=@home in fstab.
How to work with snaphots in Ubuntu's layout
In order to work with snapshots of / or /home in the Ubuntu layout it is very convenient to mount the btrfs filesystem at a separate location, and work from the top of the btrfs tree, rather than from the mounted subvolumes.
sudo mount /dev/sdX# /mnt
Create snapshots
To create a snapshot use
sudo btrfs subvolume snapshot /mnt/@ /mnt/@_snapshot
this will create a snapshot of the @ subvolume named @_snapshot located also in the top of the btrfs tree.
Rollback to a snapshot
To roll back to a snapshot, you simply need to change it's name to the name that ubuntu mounts, using
sudo mv /mnt/@ /mnt/@_badroot sudo mv /mnt/@_snapshot /mnt/@
and reboot.
Delete a snapshot
To delete a snapshot use
sudo btrfs subvolume delete /mnt/@_badroot
btrfs snapshots are subvolumes in themselves, and self-contained, deleting the old @ subvolume like this is fine, provided we have a replacement.
The btrfs-tools command ''set-default'' will break Ubuntu's layout
Since Ubuntu is set up to always keep the top of the btrfs tree as the default mounting subvolume it will break when using the btrfs-tools command set-default, since this command is specifically designed to change the default mounting subvolume.
The mount options for / and /home described above relies on the fact that the corresponding subvolumes @ and @home can be located below the default mounting subvolume, and if set-default is used, this is no longer the case.
If you have accidentally used set-default and want to revert, you can do the following
sudo mount /dev/sdX# /mnt sudo btrfs subvolume set-default 5 /mnt
since the id 5 is a permanent alias for the top of the btrfs tree.
Fresh Install on 11.04 Natty
As of 11.04-beta1, it is possible to use only btrfs file systems with the caveat that grub _MUST_NOT_ be installed to the boot sector of the btrfs volume containing /boot. See also Ubuntu Grub2 Bug 757446 and Ubuntu Grub2 Bug 759772. You must install it to either the parent (sda rather than sda1; MBR/Reserved Sectors) _OR_ use a dedicated /boot partition as shown in the following example (in Fresh Install on 10.10 Maverick).
When installing Ubuntu in one large btrfs-Partition without an extra boot-partition, take care to keep about 1 Mib space free at the beginning of the disk. This is possible using the partition manager in the Ubuntu installer. When there is not this space, the installer fails at the end when trying to install Grub!
Install as Root on versions prior to 10.10
An excellent HowTo is available at http://ubuntuforums.org/showpost.php?p=8716089&postcount=1
Managing Btrfs
Snapshots & Subvolumes
Create a subvolume:
btrfs subvolume create test
This creates a subvolume in your home area called test. It appears to be a directory.
Do a snapshot copy of a subvolume:
btrfs subvolume snapshot test snap-copy-one
This creates a subvolume in your home area called snap-copy-one complete with all the data contained in test at the time of the snapshot.
List your subvolume:
sudo btrfs subvolume list test
This lists your subvolumes. Root privileges and the name of one of your subvolumes is required.
Sample Output:
ID 264 top level 5 path home/myhome/test ID 265 top level 5 path home/myhome/snap-copy-one
Delete your subvolume:
sudo btrfs subvolume delete test
Root privileges are required to delete subvolumes.
Adding Filesystem Compression
Edit /etc/fstab:
# <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda2 during installation UUID=07e198ed-18a3-41ed-9e48-bde82ead65fc / btrfs defaults, compress 0 1 # /boot was on /dev/sda1 during installation UUID=90983817-83f8-464f-a50c-39cd02317447 /boot ext2 defaults 0 2 # swap was on /dev/sda5 during installation UUID=a3da3212-876f-4350-94b3-4b5b5040c871 none swap sw 0 0
The compress option was added. Remount the filesystem using "sudo mount -o remount /" or simply reboot.
Compression algorithm:
Since kernel 2.6.38 you can choose between zlib (default) and lzo as compression algorithms. zlib has a higher compression ratio while lzo is faster and takes less cpu load. To use lzo you edit your fstab and add "compress=lzo" to your mount options as described above. Specifying "compress" equals "compress=zlib".
See Phoronix for a benchmark between zlib and lzo.
NOTE: Grub2 in 11.04 can't read lzo compressed root so you'll need a /boot partition to use it.
Display Filesystem Information
Show a device:
sudo btrfs filesystem show /dev/sda2
Displays information about device /dev/sda2.
Sample Output:
failed to read /dev/sr0 Label: none uuid: 07e198ed-18a3-41ed-9e48-bde82ead65fc Total devices 1 FS bytes used 26.80GB devid 1 size 912.20GB used 28.27GB path /dev/sda2 Btrfs Btrfs v0.19
Show Filesystem Information for a path:
btrfs filesystem df /home/myhome
Displays information about path /home/myhome.
Sample Output:
Metadata: total=640.00MB, used=265.57MB Data: total=27.00GB, used=26.54GB System: total=12.00MB, used=12.00KB
Validate Filesystem Integrity
Fsck a device:
sudo btrfsck /dev/sda2
Does online filesystem check of device /dev/sda2.
Sample Output:
found 28752076800 bytes used err is 0 total csum bytes: 27806792 total tree bytes: 277921792 total fs tree bytes: 233484288 btree space waste bytes: 76057148 file data blocks allocated: 35377807360 referenced 28362235904 Btrfs Btrfs v0.19
Scrub a directory:
btrfs scrub Videos
Improve Filesystem Performance
Balance the B-Tree:
btrfs filesystem balance /home/myhome
This operation could take some time.
Defragment a directory:
sudo btrfs filesystem defragment Videos
All the files in the Videos directory are defragmented. Sudo is required to get ioctl access to the files.