由Oracle于2007年宣布并进行中的COW(copy-on-write式)文件系统。目标是取代Linux目前的ext3文件系统,改善ext3的限制,特别是单一文件大小的限制,总文件系统大小限制以及加入文件校验和特性。加入目前ext3/4未支持的一些功能,例如可写的磁盘快照(snapshots),以及支持递归的快照(snapshots of snapshots),内建磁盘阵列(RAID)支持,支持子卷(Subvolumes)的概念,允许在线调整文件系统大小。(自百度百科)
以下自马哥课程笔记和CentOS7帮助文档: 核心特性:
btrfs: NAME
btrfs - control a btrfs filesystem SYNOPSIS
btrfs <command> [<args>] COMMANDS
balance
Balance btrfs filesystem chunks across single or several devices.
See btrfs-balance(8) for details.
check
Do off-line check on a btrfs filesystem.
See btrfs-check(8) for details.
device
Manage devices managed by btrfs, including add/delete/scan and so on.
See btrfs-device(8) for details.
filesystem
Manage a btrfs filesystem, including label setting/sync and so on.
See btrfs-filesystem(8) for details.
receive
Receive subvolume data from stdin/file for restore and etc.
See btrfs-receive(8) for details.
replace
Replace btrfs devices.
See btrfs-replace(8) for details.
subvolume
Create/delete/list/manage btrfs subvolume.
See btrfs-subvolume(8) for details.
btrfs filesystem: NAME
btrfs-filesystem - control btrfs filesystem SYNOPSIS
btrfs filesystem <subcommand> <args> SUBCOMMAND
df [options] <path>
Show space usage information for a mount point.
show [--mounted|--all-devices|<path>|<uuid>|<device>|<label>]
Show the btrfs filesystem with some additional info.
resize [<devid>:][+/-]<size>[kKmMgGtTpPeE]|[<devid>:]max <path>
Resize a filesystem identified by <path> for the underlying device devid online.
不常用,一般调整子卷。
label [<dev>|<mountpoint>] [<newlabel>]
Show or update the label of a filesystem.
btrfs device: NAME
btrfs-device - control btrfs devices SYNOPSIS
btrfs device <subcommand> <args> DEVICE MANAGEMENT
RAID level
Btrfs filesystem supports most of the standard RAID level: 0/1/5/6/10.
Balance
btrfs-balance(8) subcommand can be used to balance or rebuild chunks to the desired profile.
Device add/remove/replace
Device can be added/removed using btrfs-replace(8) subcommand and replaced using btrfs-replace(8).
When device is removed or replaced, btrfs will do the chunk rebuild if needed. SUBCOMMAND
add [-Kf] <dev> [<dev>...] <path>
Add device(s) to the filesystem identified by <path>.
delete <dev> [<dev>...] <path>
Remove device(s) from a filesystem identified by <path>.
拆除物理卷时会自动迁移要移除的物理卷中的数据。
ready <device>
Check device to see if it has all of it’s devices in cache for mounting.
scan [(--all-devices|-d)|<device> [<device>...]]
Scan devices for a btrfs filesystem.
stats [-z] <path>|<device>
Read and print the device IO stats for all devices of the filesystem identified by <path> or for a single <device>.
btrfs balance: NAME
btrfs-balance - balance btrfs filesystem SYNOPSIS
btrfs balance <subcommand> <args> SUBCOMMAND
cancel <path>
Cancel running or paused balance.
pause <path>
Pause running balance.
resume <path>
Resume interrupted balance.
start [options] <path>
Balance chunks across the devices online.
Options:
-d[<filters>]
act on data chunks. See FILTERS section for details about <filters>.
修改数据的组织机制。
-m[<filters>]
act on metadata chunks. See FILTERS section for details about <filters>.
修改元数据的组织机制。
-s[<filters>]
act on system chunks (only under -f). See FILTERS section for details about <filters>.
-v
be verbose
-f
force reducing of metadata integrity
status [-v] <path>
Show status of running or paused balance.
If -v option is given, output will be verbose. FILTERS
convert
Convert each selected block group to the given profile name identified by parameters.
btrfs subvolume: NAME
btrfs-subvolume - control btrfs subvolume(s) SYNOPSIS
btrfs subvolume <subcommand> [<args>] DESCRIPTION
btrfs subvolume is used to control the filesystem to create/delete/list/show subvolumes and snapshots. SUBCOMMAND
create [-i <qgroupid>] [<dest>]<name>
Create a subvolume <name> in <dest>.
If <dest> is not given, subvolume <name> will be created in the currently directory.
Options
-i <qgroupid>
Add the newly created subvolume to a qgroup. This option can be given multiple times.
delete [options] <subvolume> [<subvolume>...]
-c|--commit-after
wait for transaction commit at the end of the operation
-C|--commit-each
wait for transaction commit after delet each subvolume
list <path>
List the subvolumes present in the filesystem <path>.
snapshot [-r] <source> <dest>|[<dest>/]<name>
挂载文件系统:
mount -t btrfs /dev/sdb MOUNT_POINT
启用透明压缩机制:
压缩和解压缩自动透明运行,启用后会增加CPU负载
mount -o compress={lzo|zlib} DEVICE MOUNT_POINT
btrfs文件系统管理实例:
(1)、CentOS7中加载磁盘设备(多块);
如/dev/sd{b,c,d};
(2)、将硬盘格式化为btrfs文件系统;
命令:# mkfs.btrfs -L MYDATA /dev/sd{b,c}
查看:# btrfs filesystem show
(3)、挂载btrfs文件系统;
命令:# mount -t btrfs /dev/sdc /mydata/
设备可为任意一个btrfs设备名,如/dev/sdb或/dev/sdc
启用透明压缩机制(可选):# mount -t btrfs -o compress=lzo /dev/sdc /mydata/