个人运维博客 - 老王运维博客 分享技术知识
环境:vmware system: rhel8.4
创建逻辑卷
创建新分区:
yum -y install gdisk
[root@serverb ~]
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 {+-}size{KMGTP}:
Last sector (2048-10485726, default = 10485726) or {+-}size{KMGTP}: +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 ~]
PV VG Fmt Attr PSize PFree
/dev/vdb1 lvm2 --- 1.00g 1.00g
创建卷组
vgcreate vg1 /dev/vdb1
Volume group "vg1" successfully created
[root@serverb ~]
VG
vg1 1 0 0 wz--n- 1020.00m 1020.00m
创建逻辑卷
[root@serverb ~]
Logical volume "lv1" created.
[root@serverb ~]
[root@serverb ~]
[root@serverb ~]
[root@serverb ~]
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 ~]
Volume group "vg1" successfully extended
[root@serverb ~]
VG
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 ~]
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 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 -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 ~]
Volume group "vg1" successfully extended
[root@serverb ~]
VG
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 ~]
mapper/ mcelog mem memory_bandwidth mqueue/
[root@serverb ~]
df -Th |grep /mnt/lv1
/dev/mapper/vg1-lv1 xfs 5.5G 72M 5.5G 2% /mnt/lv1
|