如何将逻辑卷扩展到 100%?

如何将逻辑卷扩展到 100%?

我有一个 5 GB 的驱动器。我创建了一个 pv,然后是一个 vg,然后是一个大小为 2GB 的逻辑卷sudo lvcreate -L +2GB -n lv-test vg-test。然后我用以下命令格式化该卷sudo mkfs.ext4 /dev/vg-test/lv-test并用以下命令安装它:sudo mkdir -p /mnt/lv-test

现在我想将此逻辑卷扩展到 100%FREE(所有大小的磁盘 - 5GB)。当我运行时lvextend 100%FREE /dev/vg-test/lv-test,LV 仅扩展了 1 GB。现在是3GB了。怎么了?如何将其扩展至 5GB?

user@ubuntu2:~$ sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdj
  VG Name               vg-test
  PV Size               5.00 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              1279
  Free PE               512
  Allocated PE          767
  PV UUID               N5fWom-E678-uzKn-c4Dt-ielb-57GN-9h2kfm
user@ubuntu2:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               vg-test
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <5.00 GiB
  PE Size               4.00 MiB
  Total PE              1279
  Alloc PE / Size       767 / <3.00 GiB
  Free  PE / Size       512 / 2.00 GiB
  VG UUID               ZCjGyZ-n1Rs-bT8d-z0cg-k8fO-9d2J-Fonggh
user@ubuntu2:~$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg-test/lv-test
  LV Name                lv-test
  VG Name                vg-test
  LV UUID                GYtquF-h2H7-Ys2k-ec9G-BH00-ToTj-NY2Vdo
  LV Write Access        read/write
  LV Creation host, time ubuntu2, 2022-02-21 20:46:54 +0000
  LV Status              available
  # open                 0
  LV Size                <3.00 GiB
  Current LE             767
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
user@ubuntu2:~$ sudo lvextend -l 100%FREE vg-test/lv-test
  New size given (512 extents) not larger than existing size (767 extents)

答案1

你想要添加所有可用空间,因此需要+

lvextend -l +100%FREE /dev/vg-test/lv-test

如果没有这个,您就要求 LV 仅占用可用空间。

相关内容