Centos7 动态创建文件系统
linux 想要动态扩展文件系统,需要将磁盘做成LVM动态卷
以centos 7为例
挂载两块磁盘
vdb
vdc
安装 ssm 管理磁盘工具
yum -y install system-storage-manager-0.4-7.el7.noarch
创建卷组,并将物理磁盘添加到该卷组中
语法格式: ssm add -p 存储池(卷组) 设备
ssm add -p vg1 /dev/vdb
ssm add -p vg1 /dev/vdc
[root@centos7docker ~]# ssm add -p vg1 /dev/vdb
Physical volume "/dev/vdb" successfully created.
Volume group "vg1" successfully created
提示创建成功
查看卷组
ssm list
[root@centos7docker ~]# ssm list
-----------------------------------------------------------
Device Free Used Total Pool Mount point
-----------------------------------------------------------
/dev/loop0 100.00 GB
/dev/loop1 2.00 GB
/dev/vda 20.00 GB PARTITIONED
/dev/vda1 20.00 GB /
/dev/vdb 50.00 GB 0.00 KB 50.00 GB vg1
/dev/vdc 50.00 GB 0.00 KB 50.00 GB vg1
-----------------------------------------------------------
------------------------------------------------
Pool Type Devices Free Used Total
------------------------------------------------
vg1 lvm 2 99.99 GB 0.00 KB 99.99 GB
------------------------------------------------
--------------------------------------------------------------------
Volume Volume size FS FS size Free TypeMount point
--------------------------------------------------------------------
/dev/loop0 100.00 GB xfs 9.99 GB 9.99 GB
/dev/vda1 20.00 GB ext4 20.00 GB 17.41 GB part/
--------------------------------------------------------------------
创建 一个10G的LVM卷 卷名为lv2 文件系统为xfs,使用vg1卷组
ssm create -s 10G -n lv2 --fstype xfs -p vg1
[root@centos7docker ~]# ssm create -s 10G -n lv2 --fstype xfs -p vg1
Logical volume "lv2" created.
meta-data=/dev/vg1/lv2 isize=256 agcount=4, agsize=655360 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
查看磁盘,发现在volume中多出一个lv2的磁盘
[root@centos7docker ~]# ssm list
------------------------------------------------------------
Device Free Used Total Pool Mount point
------------------------------------------------------------
/dev/loop0 100.00 GB
/dev/loop1 2.00 GB
/dev/vda 20.00 GB PARTITIONED
/dev/vda1 20.00 GB /
/dev/vdb 40.00 GB 10.00 GB 50.00 GB vg1
/dev/vdc 50.00 GB 0.00 KB 50.00 GB vg1
------------------------------------------------------------
-------------------------------------------------
Pool Type Devices Free Used Total
-------------------------------------------------
vg1 lvm 2 89.99 GB 10.00 GB 99.99 GB
-------------------------------------------------
------------------------------------------------------------------------------
Volume Pool Volume size FS FS size Free Type Mount point
------------------------------------------------------------------------------
/dev/vg1/lv2 vg1 10.00 GB xfs 9.99 GB 9.99 GB linear
/dev/loop0 100.00 GB xfs 9.99 GB 9.99 GB
/dev/vda1 20.00 GB ext4 20.00 GB 17.41 GB part /
------------------------------------------------------------------------------
挂载该磁盘在 /data 目录下,并查看
[root@centos7docker ~]# mkdir /data
[root@centos7docker ~]# mount /dev/vg1/lv2 /data/
[root@centos7docker ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 20G 4.7G 14G 25% /
devtmpfs devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs tmpfs 7.8G 41M 7.8G 1% /run
tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/mapper/vg1-lv2 xfs 10G 33M 10G 1% /data
可以看出,/data 磁盘为10G
接下来扩展该文件系统大小
[root@centos7docker ~]# ssm resize -s +10G /dev/vg1/lv2
Size of logical volume vg1/lv2 changed from 10.00 GiB (2560 extents) to 20.00 GiB (5120 extents).
Logical volume vg1/lv2 successfully resized.
meta-data=/dev/mapper/vg1-lv2 isize=256 agcount=4, agsize=655360 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2621440 to 5242880
[root@centos7docker ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 20G 4.7G 14G 25% /
devtmpfs devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs tmpfs 7.8G 41M 7.8G 1% /run
tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/mapper/vg1-lv2 xfs 20G 33M 20G 1% /data
[root@centos7docker ~]#
可以看出,磁盘已经扩容为20G
完成
本文来自博客园,作者:曹艳飞,转载请注明原文链接:https://www.cnblogs.com/caoyf1992/p/8243192.html