Linux Learning notes: Btrfs

Source: Internet
Author: User

Btrfs
Technical Preview, Technical previews
BtrFS (B-tree file system, also known as butter FS or better FS), 2007 by Oracle Open Source, by the IBM, Intel and other manufacturers of strong support, the goal is to replace the current Linux ext3/ 4, become the next generation Linux standard file system.
A powerful file system that runs on Linux and adheres to the GPL protocol. A stable version was released in August 2014.

Features of Btrfs:
1. Extensibility:
1) The EXT Series file system uses block bitmaps to hold each block free or not (each block uses a bit to indicate whether it is idle), and when the capacity expands, the space occupied by the block bitmap increases linearly, just imagine that if the fast bitmap becomes large, then finding the free block takes a lot of time ; btrfs the smallest unit of managed disk space is extent, a extent consists of a contiguous set of blocks, extent is managed by a extent tree, so it takes 10 bits to represent the 10 block of the Ext series, and btrfs requires only one extent to , thus reducing the amount of metadata. For large files, extent shows superior management performance.

2) Ext system Inode is pre-allocated and fixed size, for example, 100G partition, Inode table can only hold 131,072 inode, which means it is impossible to create 131,072 files, at the same time, the inode allocation is too small, easy to cause disk space is not fully utilized, too large , it is easy to waste disk space; Btrfs to solve this problem, using the dynamic allocation of inode, for example, each inode is only one node in the FS tree, the user can arbitrarily insert the new inode, the physical storage location is dynamically allocated, so there is no limit on the number of files.

2. Multi-Physical volume support:
Btrfs can span multiple physical disk devices, dynamically increase/decrease the device to achieve the purpose of expansion/contraction, technical support (RAID0, RAID1, RAID5, RAID10 and other features), as well as online "add", "Remove" and "modify"

3. Copy-on-write update mechanism (CoW):
Copy, update, and replace pointers instead of "in-place" updates; Btrfs data consistency is guaranteed by cow (copy on write) transactions, so-called cow, that is, each time the disk data is written, the current block data is copied to a new block, and then the new block is updated to write, when the new block writes complete, Simply point the original pointer to the old block to the new block.

4. Data and meta-data check code: Checksum
Another feature of Btrfs is the use of checksum to ensure data reliability, assuming that a block of data is read from disk, you can compare its checksum to determine whether the data is complete, other file systems at the file system level is not aware of the data corruption At the same time, because checksum data is stored on the nodes of the checksum tree and is managed separately from the block data, the benefit is to avoid checksum and the data in the same block, It is not known when the upper layer of the filesystem gets a block of the wrong location (because checksum only calculates whether the block data is complete and not which block the data should have, as long as the data inside the block is not corrupted, checksum is always correct)

5. Sub-Volume: Sub_volume
Creating a sub-volume on a file system (or logical volume) does not have a hierarchy limit, and the amount of space for all volumes can be dynamically adjusted. The scenario is that each user can be assigned a separate, isolated volume space to achieve the purpose of permission control and quota management.

6. Snapshots: Snapshots that support snapshots

7. Transparent compression, Stealth compression:

Mkfs.btrfs
Options:
-l|--label <name>: Assigning a volume label to the Btrfs file system that is about to be created
-d|--data <type>: Specifies the type for the data store; the types you can choose are: RAID0, RAID1, RAID5, Raid6, RAID10, or single
-m|--metadata <profile>: Specifies how metadata is stored; the types you can choose are: RAID0, RAID1, RAID5, Raid6, RAID10, single or DUP
-o|--features <feature1>[,<feature2&gt ...] : Specifies the features of the Btrfs file system, and if you want to see which features, you can use the command: Mkfs.btrfs-o list-all

The transparent compression function can be turned on using the Mount command that supports the Btrfs file system in the following ways:
Mount-o Compress={lzo|zlib} DEVICE mount_point

Btrfs
Btrfs-control a btrfs filesystem
Btrfs <command> [<args>]

Btrfs filesystem Show
View detailed properties of the Btrfs file system;

Btrfs filesystem DF Mount_point
Viewing file system mounts and usage
Example: Btrfs filesystem df/mnt/btrfs/

Modify file system size online:
Btrfs filesystem Resize {+|-}size[kkmmggttppee] Mount_point

Example: Btrfs filesystem resize-15g/mnt/btrfs/
Btrfs FileSystem Resize +5g/mnt/btrfs/
Btrfs FileSystem Resize max/mnt/btrfs/

Adding or removing devices to the Btrfs file system
Btrfs Device
Btrfs device add [options] <device> [<device> ...] <path>
Add a new device to the file system
Btrfs device Delete <device> [<device> ...] <path>
Remove a device from the file system


Balance data:
Btrfs balance start [options] <path>
Turn on data balancing for chunk across devices
-mconvert={radi0|raid1|raid5|radi10|raid6|single|dup}
Changing the data-balanced layout of metadata
Example: Btrfs balance start-mconvert=raid5/mnt/btrfs/

-dconvert={radi0|raid1|raid5|radi10|raid6|single}
Change the way data is balanced and laid out
Example: Btrfs balance start-dconvert=raid6/mnt/btrfs/

Btrfs Balance Pause <path>
Pause Data balancing
Btrfs Balance Cancel <path>
Cancel a data balance that is in progress or has been paused
Btrfs Balance Resume <path>
Recovering interrupted data balance
Btrfs balance Status [-V] <path>
Displays status information for an in-progress or paused data balance

Sub-volume Management:
Btrfs Subvolume Create [-I <qgroupid>] [<dest>/]<name>
Create a sub-volume
Example: Btrfs subvolume create/mnt/btrfs/mysub1/

Btrfs subvolume Delete [options] <subvolume> [<subvolume> ...]
Delete a child volume
Example: Btrfs subvolume delete/mnt/btrfs/mysub1/

Btrfs Subvolume Show <subvol-path>
Displaying information for a sub-volume
Example: Btrfs subvolume show/mnt/btrfs/mysub1/


A sub-volume is similar to an operation in an ext file system that mounts another partition to a free subdirectory under the root directory;

Snapshot:
Btrfs Subvolume Snapshot [-r] [-I <qgroupid>] <source> <dest>| [<dest>/]<name>
To create a snapshot volume for a specified sub-volume

Example: Btrfs subvolume snapshot/mnt/btrfs/mysub1//mnt/btrfs/snap_mysub1

Convert Btrfs and EXT series:
Btrfs-convert
Btrfs-convert-convert from EXT2/3/4 filesystem to btrfs or rollback
Btrfs-convert [Options] <device>

Convert the file system from ext to Btrfs:
~]# BTRFS-CONVERT/DEV/SDB1

Note:/DEV/SDB1 partitions should be formatted in advance to the Ext series file system;

Rollback the file system from Btrfs to Ext
~]# Btrfs-convert-r/DEV/SDB1

Linux Learning notes: Btrfs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.