I. Basic Introduction: Btrfs (also known as B-tree, ButterFS, BetterFS), GPL authorization, Oracle R & D from 2007, realistic replication and update mechanism CoW, mainly to replace ext2, ext3, for example, if we modify File A, the COW mechanism first copies the target file A as file B.
I. Basic Introduction
Btrfs (also known as B-tree, Butter FS, Better FS), GPL authorization, Oracle R & D from 2007, realistic replication and update mechanism CoW, mainly to replace ext2, ext3, ext4, its main functions include:
For example, if we want to modify File A, and the COW mechanism is to copy file A to file B first, we will modify the copy file B, it is equivalent to taking A snapshot of source file A. If file B is modified incorrectly, it can effectively restore source file.
Multi-physical volume support: btrfs can be composed of multiple underlying physical volumes. it supports RAID (supporting strip, mirror, and other functions) and online "add" and "remove ", "modify" operation
The B-tree file function is supported, that is, the sub-volume function is supported, just like creating a lv in vg.
Replication and update mechanism during writing (CoW): replication, update, and replace pointer instead of local update mechanism
Data and source data verification code mechanism checksum: When we store a file, checksum will save the source data and data verification code through the file property extension, respectively, when we read the data again, we can easily check whether the data is damaged. if the file is damaged, the system can perform automatic repair.
Subvolume sub_volume: you can create a subvolume on a volume and then mount and use it separately.
Snapshots: Supports the snapshot feature, that is, incremental snapshots.
Transparent compression: data is automatically compressed and decompressed to save space and consume a certain amount of cpu
:
II. file system creation
Command help btrfs -- help
Mkfs. btrfs
-L 'label' specifies the volume LABEL
-D : Raid0, raid1, raid5, raid6, raid10, single indicates the data storage type
-M : Raid0, raid1, raid5, raid6, raid10, single, dup indicates the source data storage mechanism.
-O Specifying features used during formatting
-O list-all: list all supported feature
Man btrfs-filesystem view more sub-commands
Mount-t btrfs/dev/sdbMOUNT_POINT mount the file system
Mount-o compress = {lzo | zlib} DEVICE MOUNT_POINT transparent compression mechanism
Btrfs filesystem resize ± VALUE MOUNT_POINT resize disk
Btrfs devices [subcommand] args manage disk devices
Btrfs-balance subcomand | args balanced data
Btrfs subvolume [subcommand] [args] create a subvolume
Create a snapshot using btrfs snapshot
The snapshot must be in the same volume group as the original volume, and the snapshot of the child volume must be in the same parent volume as the child volume.
Btrfs subvolume delete snapshot-name delete sub-snapshot
3. create an application example
# Fdisk-l view disks with existing partitions
# Mkfs. btrfs-L "mybtrfs"/dev/sdb/dev/sdc create sdb and sdc disks as a btrfs system
# Btrfs filesystem show view the created btrfs file system
# Blid/dev/sdb check that the UUID is the same (meaning it actually belongs to the same volume)
# Mkdir/mybtrfs create a mount point
# Mount-t btrfs/dev/sda (the mount point is/dev/sda)
# Umount/dev/sda uninstall
# Mount-o compress = lzo/dev/sdb/mybtrs re-use, which is automatic compression (transparent compression)
# Btrfs filesystem resize-10G/mybtrfs
(Btrfs filesystem resize to adjust the disk size)
# Btrfs devices add/dev/sdd/mybtrfs automatic disk expansion logic 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 a subvolume
# Btrfs subvolume create/mybtrfs/logs create a logs subvolume
Umount/mybtrfs
Mount/dev/sdb/mybtrfs can unmount the parent volume, with only the child volume hanging
Btrfs subvolume list/mybtrfs display mybtrs