lvm逻辑卷管理 创建 |ext4 xfs扩容

盛年不重来,一日难再晨,及时当勉励,岁月不待人。这篇文章主要讲述lvm逻辑卷管理 创建 |ext4 xfs扩容相关的知识,希望能为你提供帮助。
老王运维博客 - 分享更多技术知识
创建逻辑卷创建新分区:

yum -y install gdisk [root@serverb ~]# gdisk /dev/vdb GPT fdisk (gdisk) version 1.0.3Partition table scan: MBR: not present BSD: not present APM: not present GPT: not presentCreating new GPT entries.Command (? for help): n Partition number (1-128, default 1): First sector (34-10485726, default = 2048) or +-sizeKMGTP: Last sector (2048-10485726, default = 10485726) or +-sizeKMGTP: +1G Current type is Linux filesystem Hex code or GUID (L to show codes, Enter = 8300): 8e00 Changed type of partition to Linux LVMCommand (? for help): wFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/vdb. The operation has completed successfully

创建物理卷
pvcreate/dev/vdb1 Physical volume "/dev/vdb1" successfully created. [root@serverb ~]# pvs PVVG FmtAttr PSize PFree /dev/vdb1lvm2 ---1.00g 1.00g

创建卷组
vgcreate vg1 /dev/vdb1 Volume group "vg1" successfully created [root@serverb ~]# vgs VG#PV #LV #SN AttrVSizeVFree vg1100 wz--n- 1020.00m 1020.00m

创建逻辑卷
[root@serverb ~]# lvcreate -n lv1 -L 500M vg1 Logical volume "lv1" created. [root@serverb ~]# [root@serverb ~]# [root@serverb ~]# [root@serverb ~]# lvs LVVGAttrLSizePool Origin Data%Meta%Move Log Cpy%Sync Convert lv1vg1 -wi-a----- 500.00m

格式化为ext4 或者xfs
mkfs.ext4|xfs /dev/mapper/vg1-lv1

创建挂载点并挂载
mkdir /mnt/lv1 mount /dev/mapper/vg1-lv1/mnt/lv1/df -Th |grep /mnt/lv1 /dev/mapper/vg1-lv1 ext4477M2.3M445M1% /mnt/lv1

ext4文件系统逻辑卷扩容将一块新的磁盘配置为物理卷 并加入卷组
pvcreate/dev/vdc Physical volume "/dev/vdc" successfully created. [root@serverb ~]# vgextend vg1 /dev/vdc Volume group "vg1" successfully extended [root@serverb ~]# vgs VG#PV #LV #SN AttrVSize VFree vg1210 wz--n- 5.99g 5.50g

扩容逻辑卷分区
lvextend -L +5G /dev/vg1/lv1 Size of logical volume vg1/lv1 changed from 500.00 MiB (125 extents) to < 5.49 GiB (1405 extents). Logical volume vg1/lv1 successfully resized. [root@serverb ~]# lvs LVVGAttrLSizePool Origin Data%Meta%Move Log Cpy%Sync Convert lv1vg1 -wi-a----- < 5.49g

使用resize2fs刷新文件系统
resize2fs -f /dev/mapper/ controlvg1-lv1 [root@serverb ~]# resize2fs -f /dev/mapper/vg1-lv1 resize2fs 1.45.4 (23-Sep-2019) Resizing the filesystem on /dev/mapper/vg1-lv1 to 5754880 (1k) blocks. The filesystem on /dev/mapper/vg1-lv1 is now 5754880 (1k) blocks long.

挂载查看容量
!mount mount /dev/mapper/vg1-lv1/mnt/lv1/ [root@serverb ~]# !df df -Th |grep /mnt/lv1 /dev/mapper/vg1-lv1 ext45.4G3.0M5.1G1% /mnt/lv1

xfs文件系统逻辑卷扩容将一块新的磁盘配置为物理卷 并加入卷组
pvcreate/dev/vdd Physical volume "/dev/vdd" successfully created. [root@serverb ~]# [root@serverb ~]# [root@serverb ~]# vgextendvg1 /dev/vdd Volume group "vg1" successfully extended [root@serverb ~]# vgs VG#PV #LV #SN AttrVSizeVFree vg1310 wz--n- < 10.99g 5.50g

扩容逻辑卷分区
lvextend -L +5G /dev/vg1/lv1 Size of logical volume vg1/lv1 changed from < 5.49 GiB (1405 extents) to < 10.49 GiB (2685 extents). Logical volume vg1/lv1 successfully resized.

【lvm逻辑卷管理 创建 |ext4 xfs扩容】使用xfs_growfs命令刷新文件系统并挂载
xfs_growfs/dev/mapper/vg1-lv1 xfs_growfs: /dev/mapper/vg1-lv1 is not a mounted XFS filesystem [root@serverb ~]# [root@serverb ~]# mount /dev/m mapper/mcelogmemmemory_bandwidthmqueue/ [root@serverb ~]# mount /dev/mapper/vg1-lv1 /mnt/lv1/df -Th |grep/mnt/lv1 /dev/mapper/vg1-lv1 xfs5.5G72M5.5G2% /mnt/lv1


    推荐阅读