/dev/sdb之前是3G容量,现在扩容了sdb的容量到8G,需要将新扩容的5G容量扩展到现有的逻辑卷中。
image.png# pvresize /dev/sdb
Physical volume "/dev/sdb" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
# pvdisplay
--- Physical volume ---
PV Name /dev/sdb
VG Name vg_data
PV Size 8.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2047
Free PE 1280
Allocated PE 767
PV UUID Do2B23-Mg1v-z5JX-6NoJ-sXIk-Smwy-uR7IoE
# vgdisplay
--- Volume group ---
VG Name vg_data
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 8.00 GiB
PE Size 4.00 MiB
Total PE 2047
Alloc PE / Size 767 / 3.00 GiB
Free PE / Size 1280 / 5.00 GiB
VG UUID 4Shwbf-0m2N-3icW-cEil-6W5x-JNLS-bXCZ7W
# lvextend -l +100%FREE /dev/vg_data/lv_data
Size of logical volume domuvg/lv_data changed from 2.00 GiB (511 extents) to 7.00 GiB (1791 extents).
Logical volume lv_data successfully resized
# lvdisplay
--- Logical volume ---
LV Path /dev/vg_data/swap
LV Name swap
VG Name vg_data
LV UUID xZdi63-3wLm-rKE5-1EYh-0Q7p-bHZM-oibkoj
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2015-10-08 15:10:14 +0800
LV Status available
# open 1
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_data/lv_data
LV Name lv_ata
VG Name vg_data
LV UUID g2pjLY-epuy-2Ba0-eBLc-EjIr-sSAO-mt8VOF
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2015-10-08 15:10:15 +0800
LV Status available
# open 1
LV Size 7.00 GiB
Current LE 1791
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
# resize2fs /dev/vg_data/lv_data
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_data/lv_data is mounted on /data; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg_data/lv_data to 1833984 (4k) blocks.
The filesystem on /dev/vg_data/lv_data is now 1833984 blocks long.
# df -Ph
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 7.3G 1020M 5.9G 15% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/mapper/vg_data-lv_data 6.9G 4.5M 6.6G 1% /data
参考
物理硬盘增加容量的LVM扩容
https://www.jianshu.com/p/752af350d6dc
How to resize/expand an Ubuntu LVM disk?
https://kb.vander.host/disk-management/how-to-resize-expand-an-ubuntu-lvm-disk/
How to extend root filesystem using LVM on Linux
https://computingforgeeks.com/extending-root-filesystem-using-lvm-linux
网友评论