lvm逻辑卷管理 创建 |ext4 xfs扩容
Posted 老王运维博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lvm逻辑卷管理 创建 |ext4 xfs扩容相关的知识,希望对你有一定的参考价值。
创建逻辑卷
创建新分区:
yum -y install gdisk
[root@serverb ~]# gdisk /dev/vdb
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating 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 LVM
Command (? for help): w
Final 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
PV VG Fmt Attr PSize PFree
/dev/vdb1 lvm2 --- 1.00g 1.00g
创建卷组
vgcreate vg1 /dev/vdb1
Volume group "vg1" successfully created
[root@serverb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg1 1 0 0 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
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1 vg1 -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 ext4 477M 2.3M 445M 1% /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 Attr VSize VFree
vg1 2 1 0 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
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1 vg1 -wi-a----- <5.49g
使用resize2fs刷新文件系统
resize2fs -f /dev/mapper/
control vg1-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 ext4 5.4G 3.0M 5.1G 1% /mnt/lv1
xfs文件系统逻辑卷扩容
将一块新的磁盘配置为物理卷 并加入卷组
pvcreate /dev/vdd
Physical volume "/dev/vdd" successfully created.
[root@serverb ~]#
[root@serverb ~]#
[root@serverb ~]# vgextend vg1 /dev/vdd
Volume group "vg1" successfully extended
[root@serverb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg1 3 1 0 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.
使用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/ mcelog mem memory_bandwidth mqueue/
[root@serverb ~]# mount /dev/mapper/vg1-lv1 /mnt/lv1/
df -Th |grep /mnt/lv1
/dev/mapper/vg1-lv1 xfs 5.5G 72M 5.5G 2% /mnt/lv1
以上是关于lvm逻辑卷管理 创建 |ext4 xfs扩容的主要内容,如果未能解决你的问题,请参考以下文章
Linux下对lvm逻辑卷分区大小的调整(针对xfs和ext4不同文件系统)
Linux下对lvm逻辑卷分区大小的调整(针对xfs和ext4不同文件系统)