动态扩展磁盘(LVM)
阅读原文时间:2023年07月09日阅读:1

使用gtp格式磁盘为lvm类型

[root@elk-log-srv01 ~]# parted /dev/vdd
GNU Parted 3.1
Using /dev/vdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdd: 6604GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags

(parted) mkpart primary xfs 0G 6603.5GB
(parted) set 1 lvm on
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdd: 6604GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 6604GB 6604GB primary lvm

(parted) quit
Information: You may need to update /etc/fstab.

 查看磁盘现有lvm格式 

[root@elk-log-srv01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/vdb1 VolGroup01 lvm2 a-- <1000.00g 0
/dev/vdc1 VolGroup01 lvm2 a-- 2.00t 0
/dev/vdd1 lvm2 --- <6.01t <6.01t
[root@elk-log-srv01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup01 2 1 0 wz--n- <2.98t 0
[root@elk-log-srv01 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lvm_data VolGroup01 -wi-ao---- <2.98t
[root@elk-log-srv01 ~]#

磁盘添加至pv

[root@elk-log-srv01 ~]# pvcreate /dev/vdd1
Physical volume "/dev/vdd1" successfully created.

扩展vg

[root@elk-log-srv01 ~]# vgextend VolGroup01 /dev/vdd1
Volume group "VolGroup01" successfully extended
[root@elk-log-srv01 ~]#

扩展容量

[root@elk-log-srv01 ~]# lvextend -l +100%FREE /dev/mapper/VolGroup01-lvm_data
Size of logical volume VolGroup01/lvm_data changed from <2.98 TiB (780798 extents) to 8.98 TiB (2355197 extents).
Logical volume VolGroup01/lvm_data successfully resized.

[root@elk-log-srv01 ~]# xfs_growfs /dev/mapper/VolGroup01-lvm_data
meta-data=/dev/mapper/VolGroup01-lvm_data isize=512 agcount=13, agsize=65470464 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=799537152, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=127872, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 799537152 to 2411721728
[root@elk-log-srv01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 50G 8.1G 39G 18% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 24K 16G 1% /dev/shm
tmpfs 16G 744K 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
tmpfs 3.2G 0 3.2G 0% /run/user/0
/dev/mapper/VolGroup01-lvm_data 9.0T 2.0T 7.1T 22% /opt
tmpfs 3.2G 0 3.2G 0% /run/user/1008
[root@elk-log-srv01 ~]#