lvresize 命令不会增加 lvm 的大小

lvresize 命令不会增加 lvm 的大小

这是我的 lsblk 输出:

 lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0          7:0    0  63.3M  1 loop /snap/core20/1828
loop1          7:1    0  63.3M  1 loop /snap/core20/1852
loop2          7:2    0  67.2M  1 loop /snap/lxd/21835
loop3          7:3    0  91.9M  1 loop /snap/lxd/24061
loop4          7:4    0  49.9M  1 loop /snap/snapd/18357
loop5          7:5    0  49.9M  1 loop /snap/snapd/18596
loop6          7:6    0   3.1G  0 loop /var/tmp
sda            8:0    0   155G  0 disk
├─sda1         8:1    0   1.1G  0 part /boot/efi
└─sda2         8:2    0 138.7G  0 part
  └─vg0-root 253:0    0    74G  0 lvm  /
sr0           11:0    1  1024M  0 rom

但是当我想将 lvm 大小增加到 sda2 的最大值时,它会显示“无事可做”消息:

root:~# sudo lvresize -tvl +100%FREE /dev/mapper/vg0-root
  TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.
  Converted 100%FREE into at most 0 physical extents.
  New size (18930 extents) matches existing size (18930 extens).

root:~# sudo lvresize -vl +100%FREE /dev/mapper/vg0-root
  Converted 100%FREE into at most 0 physical extents.
  New size (18930 extents) matches existing size (18930 extents).
root:~# sudo resize2fs -p /dev/mapper/vg0-root

resize2fs 1.45.5 (07-Jan-2020)
The filesystem is already 19384320 (4k) blocks long.  Nothing to do!

vgdisplay 的输出:

# vgdisplay
  --- Volume group ---
  VG Name               vg0
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <73.95 GiB
  PE Size               4.00 MiB
  Total PE              18930
  Alloc PE / Size       18930 / <73.95 GiB
  Free  PE / Size       0 / 0
  VG UUID               anzb9z-z1ML-h0xn-21Eq-WvLn-Pgpl-NwH5OR

更新:

pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               vg0
  PV Size               <73.95 GiB / not usable 2.98 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              18930
  Free PE               0
  Allocated PE          18930
  PV UUID               SiNEeE-3Wjm-ZrrC-cTji-9Tzc-DZtw-bWLW4O

答案1

您需要调整 PV 的大小:

sudo pvresize /dev/sda2

分区已经扩大,但PV不知道,因此LVM无法使用额外的空间。

完成后,VG 将显示可用空间,您将能够调整 LV 的大小。

相关内容