Btrfs File System

Source: Internet
Author: User

Btrfs (usually read as butter FS), announced by Oracle in 2007 and ongoing in the cow (copy-on-write) file system. The goal is to replace Linux's current Ext3 file system to improve ext3 limitations, especially single file size limits, total file system size limits, and the addition of file checksum features.

The first is extensibility (scalability)-related features, and Btrfs's most important design goal is to address the scalability requirements of large machines for file systems. Features such as extent,b-tree and dynamic inode creation ensure that Btrfs still has excellent performance on large machines, with overall performance not decreasing as the system capacity increases.

Next is the data integrity-related feature. The system is confronted with unpredictable hardware failures, and Btrfs uses COW transaction technology to ensure file system consistency. Btrfs also supports checksum and avoids the emergence of silent corrupt. Traditional file systems cannot do this.

The third is the features associated with multi-device management. Btrfs supports the creation of snapshots (snapshot), and Clone (clone) sub-volumes (sub_volume) for transparent compression. Btrfs can also easily manage multiple physical devices, making traditional volume management software redundant.

Finally, other features that are difficult to categorize. These features are more advanced technologies that can significantly improve the time/space performance of file systems, including delay allocation, storage optimization of small files, directory indexing, and more.

Extensibility-related features

B-tree

All metadata in the Btrfs file system are managed by B-tree. The main benefit of using B-tree is that it is efficient to find, insert, and delete operations. It can be said that B-tree is the core of Btrfs.

Blindly boast that B-tree is very good and efficient may not be convincing, but if a little bit of time to see the EXT2/3 metadata management implementation, you can contrast the advantages of b-tree. (The previous blog file system explained in detail the EXT series of file systems).

Extent-based file storage

Many modern file systems use extent instead of block to manage disks. Extent is a contiguous block, and a Extent is defined by the starting block plus the length, which can effectively reduce the metadata overhead.


Centos7 default support for Btrfs file system


File System creation:

Btrfs file system supports many subcommands:filesystem, device, balance, Subvolume

Managing sub-volumes:

Btrfs Subvolume Create [-I <qgroupid>] [<dest>/]<name>

Btrfs subvolume Delete [options] <subvolume> [<subvolume> ...]

Btrfs subvolume list [options] [-G [+|-]value] [-C [+|-]value] [--sort=gen,ogen,rootid,path] <path>

Btrfs Subvolume Snapshot [-r] <source> <dest>| [<dest>/]<name>

Btrfs Subvolume Get-default <path>

Btrfs subvolume Set-default <subvolid> <path>

Btrfs subvolume find-new <path> <lastgen>

Btrfs Subvolume Show <subvol-path>

Managing the B-tree File system:

Btrfs filesystem DF <path> Show B-tree file system space size

Btrfs filesystem Show [Options] [<path>|<uuid>|<device>|label] shows an existing B-tree file system

Btrfs filesystem Sync <path> Sync

Btrfs filesystem defragment [options] <file>|<dir> [<file>|<dir> ...]

Btrfs filesystem Resize [devid:][+/-]<newsize>[kkmmggttppee]| [Devid:]max <path> Sizing

Btrfs filesystem label [<device>|<mount_point>] [<newlabel>] Add volume label

Manage data for physical volumes:

Btrfs [filesystem] balance start [options] <path> file system balance

Btrfs [filesystem] Balance Pause <path>

Btrfs [filesystem] Balance Cancel <path>

Btrfs [filesystem] Balance resume <path>

Btrfs [filesystem] Balance status [-V] <path>

Manage Devices:

Btrfs device add [options] <device> [<device> ...] <path> New physical volume

Btrfs device Delete <device> [<device> ...] <path> physical volume removal

Btrfs device Scan [(-d|--all-devices) |<device> [<device> ...]

Btrfs Device Ready <device>

Btrfs device stats [-z] <path>|<device>

Erase data:

Btrfs scrub start [-BDQRRF] [-C ioprio_class-n Ioprio_classdata] <path>|<device>

Btrfs Scrub Cancel <path>|<device>

Btrfs scrub Resume [-BDQRR] [-C ioprio_class-n Ioprio_classdata] <path>|<device>

Btrfs scrub Status [-DR] <path>|<device>


Btrfs check [options] <device>

Emergency rescue and Repair:

Btrfs rescue Chunk-recover [Options] <device>

Btrfs rescue Super-recover [Options] <device>

......


Mkfs.btrfs

-L ' LABEL ' specifies the volume label

-D <type>: Raid0, RAID1, RAID5, Raid6, RAID10, single indicates how data is stored across devices

-M <profile>: RAID0, RAID1, RAID5, Raid6, RAID10, single, DUP indicates metadata storage

-O <feature> what features are directly turned on when formatting, version support required

-O List-all: Lists all supported feature;


Add 4 hard disks to the virtual machine and create the file system:(First use 3, fourth standby)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/66/wKioL1XjDmXQ1msRAAD8uHt-BsM217.jpg "title=" image 000. JPG "alt=" wkiol1xjdmxq1msraad8uht-bsm217.jpg "/>

Properties View:

btrfs filesystem Show

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/66/wKioL1XjDxXChXglAADNpimuQnY855.jpg "title=" image 001. JPG "alt=" wkiol1xjdxxchxglaadnpimuqny855.jpg "/>

Mount File System:

mount-t btrfs/dev/sdb mount_point

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/66/wKioL1XjDuTC8BUMAAJu4poVVAk392.jpg "title=" image 003. JPG "alt=" wkiol1xjdutc8bumaaju4povvak392.jpg "/>

Transparent compressor System:

mount-o Compress={lzo|zlib} DEVICE mount_point

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/6A/wKiom1XjDxaRWK5JAACaePP-xho287.jpg "title=" image 005. JPG "alt=" wkiom1xjdxarwk5jaacaepp-xho287.jpg "/>

Dynamic space:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/67/wKioL1XjGJHT1Xk4AAJ3d_M3PAc099.jpg "style=" float: none; "title=" Image 006.jpg "alt=" Wkiol1xjgjht1xk4aaj3d_m3pac099.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/67/wKioL1XjGM_i2n3yAAEYvLfD7XA571.jpg "title=" image 007. JPG "alt=" wkiol1xjgm_i2n3yaaeyvlfd7xa571.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/67/wKioL1XjGYjRtYiuAAIFkZtkGkY541.jpg "title=" image 008. JPG "alt=" wkiol1xjgyjrtyiuaaifkztkgky541.jpg "/>

To add a physical device:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/67/wKioL1XjGdjgRMzzAAIon7RaMCY424.jpg "title=" image 009. JPG "alt=" wkiol1xjgdjgrmzzaaion7ramcy424.jpg "/>

Data balancing:(because this example is new, there is little balance data)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/6A/wKiom1XjF_bzkGfjAACCnQQ6G-M069.jpg "title=" image 010. JPG "alt=" wkiom1xjf_bzkgfjaaccnqq6g-m069.jpg "/>

To remove a physical device:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/6A/wKiom1XjGIrgZ99KAAEshOM_98I116.jpg "title=" image 012. JPG "alt=" wkiom1xjgirgz99kaaeshom_98i116.jpg "/>

Btrfs supports raid directly, such as changing the storage level of metadata to RAID5:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/67/wKioL1XjGt6zXTHqAABUzwpkWMk707.jpg "title=" image 013. JPG "alt=" wkiol1xjgt6zxthqaabuzwpkwmk707.jpg "/>

Btrfs supports sub-volumes:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/6A/wKiom1XjG-nydhCOAACEbQPoa5A620.jpg "title=" image 014. JPG "alt=" wkiom1xjg-nydhcoaacebqpoa5a620.jpg "/>

List lists the details of the sub-volumes, show is used to view the details of a given sub-volume

Create a sub-volume Logs,chche under/mydata and try to mount logs to/mnt separately, showing details:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/6A/wKiom1XjHATCyf8SAAIwi83c78U591.jpg "style=" float: none; "title=" Image 015.jpg "alt=" Wkiom1xjhatcyf8saaiwi83c78u591.jpg "/>

To re-mount to/mydata, the file is also:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/67/wKioL1XjHiKxjYuVAABhoiQTm-8764.jpg "style=" float: none; "title=" Image 016.jpg "alt=" Wkiol1xjhikxjyuvaabhoiqtm-8764.jpg "/>

Note: When you mount a parent volume, the data of the child volume is accessible, such as when you mount a child volume separately, the parent volume cannot access only the child volume

Mount Sub-volumes can also be implemented using Mount Subvolid= "sub-volume ID" "Mount location"


A sub-volume can also be deleted:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/6B/wKiom1XjI6CACoVkAACiMo9TKEY645.jpg "title=" image 001. JPG "alt=" wkiom1xji6cacovkaacimo9tkey645.jpg "/>

The sub-volume supports snapshot creation: (To make it easier to view, copy part of the data beforehand)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/68/wKioL1XjJz6hEVdIAAGKzKsD2vw361.jpg "title=" image 002. JPG "alt=" wkiol1xjjz6hevdiaagkzksd2vw361.jpg "/>

Modify the data of the original volume, the snapshot volume does not change.

When the snapshot is exhausted, it can be deleted:

[Email protected] ~]# Btrfs subvolume delete/mydata/logs_snapshot


The B-tree file system also supports snapshots of individual files:

[email protected] logs]# CP--reflink grub2.cfg Grub2.cfg_snap

Change the original file, the snapshot file will not change


Alternatively, you can convert the Ext file system to Btrfs:

First remove a physical device:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/68/wKioL1XjK0eRb6YZAAFUAE-IYHE429.jpg "title=" image 003. JPG "alt=" wkiol1xjk0erb6yzaafuae-iyhe429.jpg "/>

To create a disk partition:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/68/wKioL1XjK83i5rZTAAH53vadS4g589.jpg "title=" image 004. JPG "alt=" wkiol1xjk83i5rztaah53vads4g589.jpg "/>

[email protected] mydata]# partx-a/DEV/SDD

[[email protected] mydata]# mke2fs-t ext4/dev/sdd1 format

[[email protected] mydata]# mount/dev/sdd1/mnt mount

[[email protected] mydata]# cp/etc/fstab/mnt/copy a file for verification

Uninstall/DEV/SDD1 to perform force detection

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/68/wKioL1XjLZnRCMTNAAEDFYLMtOk177.jpg "title=" image 005. JPG "alt=" wkiol1xjlznrcmtnaaedfylmtok177.jpg "/>

To perform the conversion:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/68/wKioL1XjLi3RRaDNAAGdwq2lPzw728.jpg "title=" image 006. JPG "alt=" wkiol1xjli3rradnaagdwq2lpzw728.jpg "/>

The new file system has appeared, mounted under/mnt and viewed:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/6B/wKiom1XjLJmSNTtcAABWyQdvdtw956.jpg "title=" image 007. JPG "alt=" wkiom1xjljmsnttcaabwyqdvdtw956.jpg "/>

Can be rolled back:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/68/wKioL1XjL2Tg5k3iAAClSersugE096.jpg "title=" image 008. JPG "alt=" wkiol1xjl2tg5k3iaaclsersuge096.jpg "/>

This is a lossless conversion in Btrfs and EXT4 file systems.





Btrfs File System

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.