新盘挂载现有的vg模式
fdisk -l #查看添加磁盘信息
pvcreate /dev/vdc # 创建pv
vgextend ubuntu-vg /dev/vdc # 将盘给现有的vg
lvresize -L +10G /dev/mapper/ubuntu--vg-root # 扩容10G
## lvextend -l +100%FREE /dev/mapper/ubuntu--vg-root ## 全部扩容
resize2fs /dev/mapper/data--vg-data--lv # 刷新
## 查看添加磁盘信息
root@h3c-test:~# fdisk -l
Disk /dev/vdc: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
## 创建 pv
root@h3c-test:~# pvcreate /dev/vdc
Physical volume "/dev/vdc" successfully created
## 查询pv
root@h3c-test:~# pvs
PV VG Fmt Attr PSize PFree
/dev/vda5 ubuntu-vg lvm2 a-- 29.28g 40.00m
/dev/vdb data-vg lvm2 a-- 120.00g 10.00g
/dev/vdc lvm2 --- 30.00g 30.00g
## 查询pv
root@h3c-test:~# vgs
VG #PV #LV #SN Attr VSize VFree
data-vg 1 1 0 wz--n- 120.00g 10.00g
ubuntu-vg 1 2 0 wz--n- 29.28g 40.00m
## 将新的盘 指定给现有的 vg
root@h3c-test:~# vgextend ubuntu-vg /dev/vdc
Volume group "ubuntu-vg" successfully extended
## 查询当前 vg 变化
root@h3c-test:~# vgs
VG #PV #LV #SN Attr VSize VFree
data-vg 1 1 0 wz--n- 120.00g 10.00g
ubuntu-vg 2 2 0 wz--n- 59.28g 30.04g
## 给lv 扩容查询
root@h3c-test:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sr0 11:0 1 1024M 0 rom
vda 253:0 0 30G 0 disk
├─vda1 253:1 0 731M 0 part /boot
├─vda2 253:2 0 1K 0 part
└─vda5 253:5 0 29.3G 0 part
├─ubuntu--vg-root 252:0 0 28.3G 0 lvm /
└─ubuntu--vg-swap_1 252:1 0 976M 0 lvm [SWAP]
vdb 253:16 0 120G 0 disk
└─data--vg-data--lv 252:2 0 110G 0 lvm /work
vdc 253:32 0 30G 0 disk
## 给lv 扩容 10G
root@h3c-test:~# lvresize -L +10G /dev/mapper/ubuntu--vg-root
Size of logical volume ubuntu-vg/root changed from 28.29 GiB (7242 extents) to 38.29 GiB (9802 extents).
Logical volume root successfully resized.
## 刷新
root@h3c-test:~# resize2fs /dev/mapper/ubuntu--vg-root
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mapper/ubuntu--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/mapper/ubuntu--vg-root is now 10037248 (4k) blocks long.
## 查询扩展后 lv 信息
root@h3c-test:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sr0 11:0 1 1024M 0 rom
vda 253:0 0 30G 0 disk
├─vda1 253:1 0 731M 0 part /boot
├─vda2 253:2 0 1K 0 part
└─vda5 253:5 0 29.3G 0 part
├─ubuntu--vg-root 252:0 0 38.3G 0 lvm /
└─ubuntu--vg-swap_1 252:1 0 976M 0 lvm [SWAP]
vdb 253:16 0 120G 0 disk
└─data--vg-data--lv 252:2 0 110G 0 lvm /work
vdc 253:32 0 30G 0 disk
└─ubuntu--vg-root 252:0 0 38.3G 0 lvm /
网友评论