Home  >  Article  >  System Tutorial  >  In-depth analysis of centos7’s btrfs file system management

In-depth analysis of centos7’s btrfs file system management

王林
王林forward
2023-12-31 09:46:12725browse

1. Basic introduction

Btrfs (also known as: B-tree, Butter FS, Better FS), GPL authorized, Oracle developed from 2007, realistic copy update mechanism CoW, which is mainly to replace ext2, ext3, ext4, its main functions are

For example, if we modify a file A now, the COW mechanism is to first copy the target file A into file B. Then when we modify the file, we modify the copied file B, which is equivalent to taking a snapshot of the source file A, such as If you make a mistake in modifying file B, you can effectively restore the source file A.

Multiple physical volume support: btrfs can be composed of multiple underlying physical volumes, with built-in support for RAID (that is, support for striping, mirror, etc.), with online "add", "remove", and "modify" operations

Supporting b-tree file function means supporting subvolume function, just like creating lv in vg

Copy-on-write update mechanism (English translation CoW): copy, update and replace pointers, rather than "in-place" update mechanism

Data and source data check code mechanism checksum: When we store a file, checksum will save the source data and data check code through the attribute expansion of the file respectively. When we read the data again It can easily detect whether the data is damaged, and if the file is damaged, the system can automatically repair it.

Support subvolume sub_volume: You can create subvolumes on a volume and then mount them separately

Snapshot: The snapshot function that supports snapshot is incremental snapshot

Transparent compression: that is, data is automatically compressed and decompressed to save space, which will consume a certain amount of CPU

2. File system creation

Command help btrfs --help

mkfs.btrfs

-L 'LABEL' specifies the volume label

-d : raid0,raid1, raid5, raid6, raid10, single Specify the data storage type

-m : raid0, raid1, raid5, raid6, raid10, single, dup specifies the source data storage mechanism

-O specifies the feature to use when formatting

-O list-all: List all supported features

man btrfs-filesystemView more subcommands

mount -t btrfs /dev/sdbMOUNT_POINT Mount file system

mount -o compress={lzo|zlib} DEVICE MOUNT_POINT transparent compression mechanism

btrfs filesystem resize ±VALUE MOUNT_POINT Adjust disk size

btrfs devices [subcommand] args manages disk devices

btrfs-balance subcomand|args balanced data

btrfs subvolume [subcommand][args] Create subvolume

btrfs snapshot Create snapshot

The snapshot must be in the same volume group as the original volume, and the snapshot of the subvolume must be in the same parent volume as the subvolume

btrfs subvolume delete snapshot-name delete sub-snapshot

3. Create application examples

# fdisk -l View the disks of existing partitions

# mkfs.btrfs -L"mybtrfs" /dev/sdb /dev/sdc Create sdb and sdc disks into a btrfs system

# btrfs filesystem show View the created btrfs file system

# blid /dev/sdb Check that the UUIDs are the same (indicating that they actually belong to the same volume)

# mkdir /mybtrfs Create mount point

# mount -t btrfs /dev/sda (the mount point is /dev/sda is also acceptable)

# umount /dev/sda uninstall

# mount -o compress=lzo /dev/sdb /mybtrs re-use, this time it is automatic compression (transparent compression)

#btrfs filesystem resize -10G /mybtrfs

(btrfs filesystem resize adjusts disk size)

# btrfs devices add /dev/sdd /mybtrfs automatic disk expansion logical boundary

# man btrfs-balance start /mytrfs

# btrfs-lalance start -mconvert=raid1 /mytrfs Modify the raid level of metadata

# btrfs balance status /mytrfs

# btrfs device delete /dev/sda /mybtrfs Remove the device and the system will automatically move the data

# btrfs sublimvolume create /mybtrfs Create subvolume

# btrfs subvolume create /mybtrfs/logs Create logs subvolume

umount /mybtrfs

mount /dev/sdb /mybtrfs can unmount the parent volume and only hang the child volume

btrfs subvolume list /mybtrfs show mybtrs

The above is the detailed content of In-depth analysis of centos7’s btrfs file system management. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete