当我尝试扩展 / 文件系统的 lvm 时,我犯了一个错误。我不确定这是否也是一个错误。
我没有创建新分区并将其添加到 pv、vg,然后扩展 lv,而是从为根文件系统提供服务的当前分区开始使用命令“pvresize”。
我执行的命令是:
[root@...]pvresize /dev/sda3 --setphysicalvolumesize 40G
然后我尝试使用以下命令扩展 vg:
[root@...]# vgextend titan /dev/sda3
/dev/sdc: open failed: No medium found
WARNING: Device /dev/sda3 has size of 58351616 sectors which is smaller than corresponding PV size of 83884032 sectors. Was device resized?
WARNING: One or more devices used as PVs in VG vg have changed sizes.
Physical volume '/dev/sda3' is already in volume group 'vg'
Unable to add physical volume '/dev/sda3' to volume group 'vg'
/dev/sda3: physical volume not initialized.
看到上面的输出后,我意识到我必须在我正在操作的单个磁盘上创建另一个分区并将其添加到 pv 组,扩展卷组,然后为根文件系统增加我的逻辑卷。
问题:如何安全地将物理卷大小恢复到我开始时的点,以使有关大小变化的警告消失?
您可以在这里找到我认为您需要的进一步解决方案指导的信息:
[root@...]# lsblk -b
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 480103981056 0 disk
├─sda1 8:1 0 629145600 0 part /boot/efi
├─sda2 8:2 0 1073741824 0 part /boot
└─sda3 8:3 0 29876027392 0 part
├─lv-root 253:0 0 21474836480 0 lvm /
└─lv-swap 253:1 0 8396996608 0 lvm [SWAP]
[root@t...]# pvdisplay -m -v
WARNING: Device /dev/sda3 has size of 58351616 sectors which is smaller than corresponding PV size of 83884032 sectors. Was device resized?
WARNING: One or more devices used as PVs in VG titan have changed sizes.
--- Physical volume ---
PV Name /dev/sda3
VG Name vg
PV Size <40.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 10239
Free PE 3117
Allocated PE 7122
PV UUID FgC2QI-pRpK-LZNS-di9w-Jc1d-XGXZ-2QxZI2
--- Physical Segments ---
Physical extent 0 to 5119:
Logical volume /dev/lv/root
Logical extents 0 to 5119
Physical extent 5120 to 7121:
Logical volume /dev/lv/swap
Logical extents 0 to 2001
Physical extent 7122 to 10238:
FREE
答案1
在互联网上花了很多时间却不知道该怎么做之后,我才注意到错误本身,并被告知我可以使用上面提到的确切扇区大小。所以我执行了命令:
[root@...] pvresize --setphysicalvolumesize 58351616s
并且它运行完美。
[root@t...]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vg
PV Size 27.82 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 7122
Free PE 0
Allocated PE 7122
PV UUID FgC2QI-pRpK-LZNS-di9w-Jc1d-XGXZ-2QxZI2
--- Physical volume ---
PV Name /dev/sda4
VG Name vg
PV Size 20.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 5119
Free PE 0
Allocated PE 5119
PV UUID n5CdvZ-0s9A-iZoz-A2i7-icF9-Wv42-CsL3s9