如何将卷组扩展到Linux物理卷的大小

如何将卷组扩展到Linux物理卷的大小

我一开始有一个 25GB 的硬盘,想把它扩展到 150GB。我曾经将fdisk/dev/sda2 分区从 26GB 扩展到 149GB。lsblk显示以下信息:

NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0  150G  0 disk
├─sda1          8:1    0    1G  0 part /boot
└─sda2          8:2    0  149G  0 part
  ├─rhel-root 253:0    0   76G  0 lvm  /
  └─rhel-swap 253:1    0    3G  0 lvm  [SWAP]
sdb             8:16   0   50G  0 disk
└─rhel-root   253:0    0   76G  0 lvm  /
sr0            11:0    1 1024M  0 rom

fdisk -l显示以下输出:

Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 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


Disk /dev/sda: 161.1 GB, 161061273600 bytes, 314572800 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
Disk label type: dos
Disk identifier: 0x000b0bb3

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   314572799   156236800   83  Linux

Disk /dev/mapper/rhel-root: 81.6 GB, 81595990016 bytes, 159367168 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


Disk /dev/mapper/rhel-swap: 3221 MB, 3221225472 bytes, 6291456 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

我放入了第二个 50GB 磁盘,可以使用vgextend并将xfs_growfs其添加到卷组。现在,rhel 卷组为 76GB。但是,我不明白为什么卷组不是 200GB,因为它sda2是 149GB。结果pvscan如下:

  PV /dev/sda2   VG rhel            lvm2 [<29.00 GiB / 0    free]
  PV /dev/sdb    VG rhel            lvm2 [<50.00 GiB / 0    free]
  Total: 2 [78.99 GiB] / in use: 2 [78.99 GiB] / in no VG: 0 [0   ]

它显示 /dev/sda2 小于 29.00GB,这让我很惊讶。我原本以为它会是 149G,如 所示lsblk。我尝试执行vgextend rhel /dev/sda2,它说物理卷 /dev/sda2 已经在卷组 rhel 中,这是有道理的。我只是不明白为什么df -h只显示 76GB,而我认为它会是 200GB。以下是 的输出df -h

Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   76G   11G   66G  14% /
devtmpfs               3.9G     0  3.9G   0% /dev
tmpfs                  3.9G     0  3.9G   0% /dev/shm
tmpfs                  3.9G  9.0M  3.9G   1% /run
tmpfs                  3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1             1014M  217M  798M  22% /boot
tmpfs                  783M     0  783M   0% /run/user/1000
tmpfs                  783M     0  783M   0% /run/user/0

请告诉我可以采取什么步骤来使 /dev/mapper/rhel-root 达到应有的 200GB。

答案1

尝试使用pvresize。最终分区大小被调整了,但 lvm 中的物理卷没有被调整。

https://linux.die.net/man/8/pvresize

相关内容