###########################################################################################
Btrfs(通常念成Butter FS),由Oracle于2007年宣布并进行中的COW(copy-on-write式)文件系统。目标是取代Linux目前的ext3文件系统,改善ext3的限制,特别是单一文件大小的限制,总文件系统大小限制以及加入文件校验和特性。加入目前ext3/4未支持的一些功能,例如可写的磁盘快照(snapshots),以及支持递归的快照(snapshots of snapshots),内建磁盘阵列(RAID)支持,支持子卷(Subvolumes)的概念,允许在线调整文件系统大小。
以上概念来源于百度百科
###########################################################################################
以下我们开始一些相关的练习:
在虚拟上添加三块15G硬盘,设备情况如下图:
创建btrfs:
[[email protected] ~]# mkfs.btrfs -L mydata /dev/sdb /dev/sdc
查看文件类型已为btrfs
[[email protected] ~]# blkid /dev/sdb
/dev/sdb: LABEL="mydata" UUID="8851183b-d7a9-4e0e-b44d-aa44d44e1c27" UUID_SUB="028bc3f3-8247-4aa8-974f-cb38a9bcdb20" TYPE="btrfs"
[[email protected] ~]# blkid /dev/sdc
/dev/sdc: LABEL="mydata" UUID="8851183b-d7a9-4e0e-b44d-aa44d44e1c27" UUID_SUB="50e498db-f7aa-4603-9473-c00934f54447" TYPE="btrfs"
[[email protected] ~]# btrfs filesystem show
Label: ‘mydata‘ uuid: 8851183b-d7a9-4e0e-b44d-aa44d44e1c27
Total devices 2 FS bytes used 112.00KiB
devid 1 size 15.00GiB used 2.03GiB path /dev/sdb
devid 2 size 15.00GiB used 2.01GiB path /dev/sdc
挂载:
[[email protected] ~]# mkdir /mydata
[[email protected] ~]# mount -t btrfs /dev/sdb /mydata
[[email protected] ~]# mount
/dev/sdb on /mydata type btrfs (rw,relatime,seclabel,space_cache)
[[email protected] ~]# df -h
/dev/sdb 30G 17M 28G 1% /mydata
[[email protected] ~]# btrfs filesystem df /mydata/
Data, RAID0: total=2.00GiB, used=768.00KiB
System, RAID1: total=8.00MiB, used=16.00KiB
System, single: total=4.00MiB, used=0.00B
Metadata, RAID1: total=1.00GiB, used=112.00KiB
Metadata, single: total=8.00MiB, used=0.00B
GlobalReserve, single: total=16.00MiB, used=0.00B
联机状态下加减5G空间:
[[email protected] ~]# btrfs filesystem resize -5G /mydata
[[email protected] ~]# df -h
/dev/sdb 25G 17M 18G 1% /mydata
[[email protected] ~]# btrfs filesystem resize +5G /mydata
Resize ‘/mydata‘ of ‘+5G‘
[[email protected] ~]# df -h
/dev/sdb 30G 17M 28G 1% /mydata
新增设备到/mydata,同时成为btrfs文件系统,如果是删除就是:delect,新增就是:add
[[email protected] ~]# btrfs device add /dev/sdd /mydata/
[[email protected] ~]# btrfs filesystem show /mydata/
Label: ‘mydata‘ uuid: 8851183b-d7a9-4e0e-b44d-aa44d44e1c27
Total devices 3 FS bytes used 896.00KiB
devid 1 size 15.00GiB used 2.02GiB path /dev/sdb
devid 2 size 15.00GiB used 2.01GiB path /dev/sdc
devid 3 size 15.00GiB used 0.00B path /dev/sdd
查看/mydata的信息:
[[email protected] ~]# btrfs filesystem df /mydata/
Data, RAID0: total=2.00GiB, used=768.00KiB
System, RAID1: total=8.00MiB, used=16.00KiB
System, single: total=4.00MiB, used=0.00B
Metadata, RAID1: total=1.00GiB, used=112.00KiB
Metadata, single: total=8.00MiB, used=0.00B
GlobalReserve, single: total=16.00MiB, used=0.00B
将/mydata转换为RAID5的数据格式
[[email protected] ~]# btrfs balance start -dconvert=raid5 /mydata/
Done, had to relocate 1 out of 5 chunks
将/mydata转换为RAID5的元数据格式
[[email protected] ~]# btrfs balance start -mconvert=raid5 /mydata/
Done, had to relocate 4 out of 5 chunks
[[email protected] ~]# btrfs filesystem df /mydata/
Data, RAID5: total=2.00GiB, used=576.00KiB
System, RAID5: total=64.00MiB, used=16.00KiB
Metadata, RAID5: total=256.00MiB, used=112.00KiB
GlobalReserve, single: total=16.00MiB, used=0.00B