标签:image mat evel 4.0 code inux sed 校验码 level
一、Btrfs文件系统Btrfs(B-tree, Butter FS, Better FS), Oracle从2007年开始研发的一种新的文件系统, 目标是用于取代ext3和ext4文件系统, 2014年8月发布稳定版本; 采用GPL授权.
# Btrfs命令的用法: btrfs <command> [<args>]
# command: 子命令; args: 参数
# 创建Btrfs文件系统: mkfs.btrfs
# -L ‘LABEL‘
# -d ‘<type>‘: raid0, raid1, raid5, raid6, raid10, single
# -m <profile>: raid0, raid1, raid5, raid6, raid10, single, dup
# -O <feature>:
# -O list-all: 列出支持的所有feature
[root@zabbix ~]# mkfs.btrfs -O list-all
Filesystem features available at mkfs time:
mixed-bg - mixed data and metadata block groups (0x4)
extref - increased hardlink limit per file to 65536 (0x40, default)
raid56 - raid56 extended format (0x80)
skinny-metadata - reduced-size metadata extent refs (0x100, default)
no-holes - no explicit hole extents for files (0x200)
# 创建一个btrfs
[root@zabbix ~]# mkfs.btrfs -L ‘mydata00‘ /dev/sdb /dev/sdc
btrfs-progs v3.19.1
See http://btrfs.wiki.kernel.org for more information.
Turning ON incompat feature ‘extref‘: increased hardlink limit per file to 65536
Turning ON incompat feature ‘skinny-metadata‘: reduced-size metadata extent refs
adding device /dev/sdc id 2
fs created label mydata00 on /dev/sdb
nodesize 16384 leafsize 16384 sectorsize 4096 size 4.00GiB
# 查看当前系统btrfs的结构信息:
# btrfs filesystem show [--mounted|--all-devices|<path>|<uuid>|<device>|<label>]
# 默认显示所有的btrfs信息
[root@zabbix ~]# btrfs filesystem show
Label: ‘mydata00‘ uuid: 609254ef-9665-4856-94f4-081643231507
Total devices 2 FS bytes used 112.00KiB
devid 1 size 2.00GiB used 437.50MiB path /dev/sdb
devid 2 size 2.00GiB used 417.50MiB path /dev/sdc
btrfs-progs v3.19.1
# 更改或者查看btrfs文件系统的label:
# btrfs filesystem label [<device>|<mount_point>] [<newlabel>]
[root@zabbix ~]# btrfs filesystem label /dev/sdb
mydata00
[root@zabbix ~]# btrfs filesystem label /dev/sdb ‘mydata01‘
[root@zabbix ~]# btrfs filesystem label /dev/sdb
mydata01
[root@zabbix ~]# btrfs filesystem label /dev/sdc
mydata01
# 挂载文件系统:
# mount -t btrfs /dev/btrfs_device MOUNT_POINT
# 挂载时透明压缩机制
# mount -o compress={lzo|zlib} -t btrfs /dev/btrfs_device MOUNT_POINT
# 修改btrfs的size
# btrfs filesystem resize [devid:][+/-]<newsize>[kKmMgGtTpPeE]|[devid:]max <path>
[root@zabbix ~]# btrfs filesystem show /mydata
Label: ‘mydata01‘ uuid: 609254ef-9665-4856-94f4-081643231507
Total devices 2 FS bytes used 256.00KiB
devid 1 size 2.00GiB used 429.50MiB path /dev/sdb
devid 2 size 2.00GiB used 417.50MiB path /dev/sdc
btrfs-progs v3.19.1
[root@zabbix ~]# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sdb 4.0G 17M 3.6G 1% /mydata
[root@zabbix ~]# btrfs filesystem resize -1G /mydata
Resize ‘/mydata‘ of ‘-1G‘
[root@zabbix ~]# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sdb 3.0G 17M 1.6G 2% /mydata
[root@zabbix ~]# btrfs filesystem resize +500M /mydata
Resize ‘/mydata‘ of ‘+500M‘
[root@zabbix ~]# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sdb 3.5G 17M 2.6G 1% /mydata
[root@zabbix ~]# btrfs filesystem resize max /mydata
Resize ‘/mydata‘ of ‘max‘
[root@zabbix ~]# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sdb 4.0G 17M 3.6G 1% /mydata
# 添加一个磁盘到现有的btrfs中
# btrfs device add [options] <device> [<device>...] <path>
[root@zabbix ~]# btrfs device add /dev/sdd /mydata
[root@zabbix ~]# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sdb 6.0G 17M 5.2G 1% /mydata
# btrfs中的chunk平衡, 用于将已使用的chunk平均的分布在所有的btrfs设备中
# 开启balance
# btrfs balance start [options] <path>
[root@zabbix ~]# btrfs balance start /mydata
Done, had to relocate 5 out of 5 chunks
# 暂停balance
# btrfs balance pause <path>
# 取消balance
# btrfs balance cancel <path>
# 重新开始balance
# btrfs balance resume <path>
# 显示正在运行中或暂停的balance状态
# btrfs balance status [-v] <path>
# 从btrfs中移除一块磁盘
# btrfs device delete <device> [<device>...] <path>
[root@zabbix ~]# btrfs device delete /dev/sdd /mydata
[root@zabbix ~]# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sdb 4.0G 17M 3.5G 1% /mydata
[root@zabbix ~]# btrfs filesystem show /mydata
Label: ‘mydata01‘ uuid: 609254ef-9665-4856-94f4-081643231507
Total devices 2 FS bytes used 392.00KiB
devid 1 size 2.00GiB used 496.00MiB path /dev/sdb
devid 2 size 2.00GiB used 496.00MiB path /dev/sdc
btrfs-progs v3.19.1
# 修改数据的raid级别; 不同的raid级别需要的设备数量不同
# btrfs balance start -d[<filters>] <path>
[root@zabbix ~]# btrfs balance start -dconvert=raid1 /mydata/
Done, had to relocate 1 out of 3 chunks
[root@zabbix ~]# btrfs balance start -dconvert=raid0 /mydata/
Done, had to relocate 1 out of 3 chunks
# 修改元数据raid级别; 不同的raid级别需要的设备数量不同
# btrfs balance start -m[<filters>] <path>
# 子卷管理
# 创建子卷:
# btrfs subvolume create [-i <qgroupid>] [<dest>/]<name>
[root@zabbix ~]# btrfs subvolume create /mydata/logs
Create subvolume ‘/mydata/logs‘
# 列出子卷和快照:
# btrfs subvolume list [options] [-G [+|-]value] [-C [+|-]value] [--sort=gen,ogen,rootid,path] <path>
[root@zabbix ~]# btrfs subvolume list /mydata
ID 264 gen 84 top level 5 path logs
# 挂载子卷
# mount -o subvol=subvol_name device /MOUNT_POINT
[root@zabbix ~]# umount /mydata/
[root@zabbix ~]# mount -o subvol=logs /dev/sdb /mnt/logs
[root@zabbix ~]# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sdb 4.0G 17M 3.5G 1% /mnt/logs
# 显示子卷的信息
# btrfs subvolume show <subvol-path>
[root@zabbix ~]# btrfs subvolume show /mnt/logs/
/mnt/logs
Name: logs
uuid: efd3a0ab-5af9-bf43-85bc-0efa369c8795
Parent uuid: -
Creation time: 2018-01-10 15:28:54
Object ID: 264
Generation (Gen): 87
Gen at creation: 84
Parent: 5
Top Level: 5
Flags: -
Snapshot(s):
# 删除子卷
# btrfs subvolume delete [options] <subvolume> [<subvolume>...]
# 创建快照
# btrfs subvolume snapshot [-r] [-i <qgroupid>] <source> <dest>|[<dest>/]<name>
[root@zabbix /]# btrfs subvolume snapshot /mydata/logs /mydata/logs-snapshot
Create a snapshot of ‘/mydata/logs‘ in ‘/mydata/logs-snapshot‘
[root@zabbix /]# btrfs subvolume list /mydata
ID 264 gen 89 top level 5 path logs
ID 265 gen 89 top level 5 path logs-snapshot
# 删除快照卷方法同删除子卷一样
# 将ext3或者ext4文件系统转换成btrfs
[root@zabbix ~]# fsck -f /dev/sdd1
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdd1: 11/131072 files (0.0% non-contiguous), 17964/524032 blocks
[root@zabbix ~]# btrfs-convert /dev/sdd1
creating btrfs metadata.
copy inodes [o] [ 0/ 11]
creating ext2fs image file.
cleaning up system chunk.
conversion complete.
[root@zabbix ~]# btrfs filesystem show
Label: ‘mydata01‘ uuid: 609254ef-9665-4856-94f4-081643231507
Total devices 2 FS bytes used 456.00KiB
devid 1 size 2.00GiB used 496.00MiB path /dev/sdb
devid 2 size 2.00GiB used 496.00MiB path /dev/sdc
Label: none uuid: a6a7705f-efa7-4cb6-bc96-0024ea49a6b2
Total devices 1 FS bytes used 70.30MiB
devid 1 size 2.00GiB used 2.00GiB path /dev/sdd1
btrfs-progs v3.19.1
标签:image mat evel 4.0 code inux sed 校验码 level
原文地址:http://blog.51cto.com/13501622/2059753