Get the App
SLTechnology News&Howtos  ›  Database  › 

Management and Application of btrfs

Shulou Source: shulou.com Published: 2022-06-01 17:39:04 10月02日 Update

Btrfs file system (only available in centos 7. 0). )

Btrfs (usually pronounced Butter FS), a COW (copy-on-write) file system in progress announced by Oracle in 2007. The goal is to replace Linux's current ext3 file system and improve ext3 restrictions, especially the single file size limit, the total file system size limit, and the addition of file checksum features. Add some features that are not currently supported by ext3/4, such as writable disk snapshots (snapshots), recursive snapshots (snapshots of snapshots), built-in disk array (RAID) support, support the concept of subvolumes (Subvolumes), and allow file system resizing online.

Core features of btrfs

Multi-physical volume support: btrfs can be composed of multiple underlying physical volumes; RAID is supported to "add", "remove" and "modify" online

Copy update mechanism on write (CoW): copy, update, and replace pointers, rather than "in-place" updates. That is, when we modify a file, we will not directly modify the source file, but copy a copy and then modify the copied file and point the pointer of the source file to the copied file.

Data and metadata check code: when storing each file, the data check code and metadata check code are saved through some extensions of the file, and each file is read to quickly check whether the file is damaged. If damage is detected, it will automatically try to repair it.

Sub-volume: sub_volume. Each sub-volume can be mounted independently

Snapshot: Btrfs supports the creation of snapshots (snapshot), clones (clone), and snapshots of snapshots

Transparent compression: when any data stream is sent to the btrfs file system, it can automatically compress and store the data by occupying the clock cycle of the CPU, and automatically decompress the file when it needs to be read. It saves space, but costs CPU clock cycles.

File system creation:

Mkfs.btrfs

-Lhasa Labelle'

-d: raid0, raid1, raid5, raid6, raid10, single

-m: raid0, raid1, raid5, raid6, raid10, single, dup

-O

-Olist-all: lists all supported feature

Here are the two disks I created.

[root@localhost ~] # fdisk-l

Disk / dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0003b92c

Device Boot Start End Blocks Id System

/ dev/sda1 * 1 64 512000 83 Linux

Partition 1 does not end on cylinder boundary.

/ dev/sda2 64 2611 20458496 8e Linux LVM

Disk / dev/mapper/VolGroup-lv_root: 18.9 GB, 18865979392 bytes

255 heads, 63 sectors/track, 2293 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk / dev/mapper/VolGroup-lv_swap: 2080 MB, 2080374784 bytes

255 heads, 63 sectors/track, 252 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Property View:

Btrfsfilesystem show

Mount the file system:

Mount-t btrfs / dev/sdb MOUNT_POINT

Transparent compression mechanism:

Mount-o compress= {lzo | zlib} DEVICE MOUNT_POINT

Here subcommands: filesystem,device, balance, subvolume

Tags: File support system snapshot data time size disk update limit cycle pointer clock mechanism source file physics feature two size function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi Linux OPPO Reno macOS