linux 如何增加lvm分区的大小?

jum4pzuy  于 2023-01-08  发布在  Linux
关注(0)|答案(1)|浏览(122)

我有一个ubuntu 18系统。我总共有3个分区,在第三个分区中,我有一个LVM分区。我需要增加那个分区的大小。下面是lsblk的输出,我需要增加/dev/sda3ubuntu--vg-ubuntu--lv分区的大小

NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                         8:0    0  140G  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0   49G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0 24.5G  0 lvm  /
sr0                        11:0    1  969M  0 rom

以下是df-h的输出

udev                               3.9G     0  3.9G   0% /dev
tmpfs                              789M  1.3M  787M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   24G   22G  1.4G  95% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda2                          974M  219M  688M  25% /boot
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/bb5dcb08fd6998aa3e438d3f2a43aeaea79fb22964abf42b4c5a869cde848b2a/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/55b43f1550428d3a82d2c2aebeb71bc9d53aac8185dd92644dfb27e806643b21/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/d812b2347f599e207581e3cd6465013c5bf397aed3e4574a029f0289c42b3a4a/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/742e299d503c794052c173e34c78c75034e96870802856cfb15475478cbc6b01/merged
shm                                 64M   28K   64M   1% /var/lib/docker/containers/551b12883006bdf12d8a7602d862639b25cefdaac1623c62a0dfbc54970e6134/mounts/shm
shm                                 64M     0   64M   0% /var/lib/docker/containers/5f0ba3554d80c9b04823d09fed7a8c07c79f0059ba53d5a302ad981c6c419f42/mounts/shm
shm                                 64M     0   64M   0% /var/lib/docker/containers/aa50634d995d73db38c109365c7a7f330d3ba3dd8adf6901ab0668536787ea21/mounts/shm
shm                                 64M     0   64M   0% /var/lib/docker/containers/058f86b327e7efb701b5741a529157fdd01cc4785f3fb71a02355f3533664b5b/mounts/shm
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/d59ce13ad4c6790a0870b3f493b7093173c72da454eeaf03f96a311e16287d4b/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/474c51077a4becbc431b85ae8204648206cb3321ccf5b778882961d410ba32c2/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/fb516c559bd0d8368215a888320ab9624f6eac47fce9536ca6c3c4eddcb98af4/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/f4d78c070438f018f39cd7a170594c84b6d5b1983eb9240f55e3c33c131503c9/merged
shm                                 64M     0   64M   0% /var/lib/docker/containers/eea2e2895e013598106f35980d444b0b192a9ad60e8d12071edc729f1b38a9de/mounts/shm
shm                                 64M     0   64M   0% /var/lib/docker/containers/7df0cb94fb37ee61fdec8fb2db4fc4938fe56b8ac5809f109b9ed73fd6cb07d6/mounts/shm
shm                                 64M   16K   64M   1% /var/lib/docker/containers/5a1f23081c327b5e431b985f051c85c02eaf143db4bca9984cd55c5b69485e0e/mounts/shm
shm                                 64M  8.0K   64M   1% /var/lib/docker/containers/a8b8c20bdaa2ca9f934348ec9aa754399217f9e58e69e886deef5b0df3ab7074/mounts/shm
tmpfs                              789M     0  789M   0% /run/user/1000

以下是lvs的输出

LV        VG        Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- 24.50g

以下是vgs的输出

VG        #PV #LV #SN Attr   VSize   VFree
  ubuntu-vg   1   1   0 wz--n- <49.00g <24.50g

请帮助我将我的lv inside /dev/sda 3的大小从24.5G扩展到49 G

vc9ivgsu

vc9ivgsu1#

您可以尝试以下操作:找到您需要扩展的分区可用的FREE PE的数量(在我的例子中是0,但是您应该有一些FREE PE可用)

vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <222.00 GiB
  PE Size               4.00 MiB
  Total PE              56831
  Alloc PE / Size       56831 / <222.00 GiB
  Free  PE / Size       0 / 0
  VG UUID               JjwxRB-Cq29-fCJW-FQJm-FLwW-UTds-iMrq2j

扩展逻辑卷:

lvextend -l +<number-of-free-pe> /dev/mapper/ubuntu--vg-ubuntu--lv

调整需要扩展的分区的大小以占用所有可用空间:

# if you have xfs file system
xfs_growfs  /dev/mapper/ubuntu--vg-ubuntu--lv
# if you have ext* file system
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

相关问题