[email protected]: / mnt / user /域/ centos7gnome lvdisplay警告:设备/dev/nbd0p2 60815360部门的大小小...">

当前位置:网站首页>The kvm virtual machine cannot be started, NOT available, and the PV is larger than the partition

The kvm virtual machine cannot be started, NOT available, and the PV is larger than the partition

2022-08-09 23:13:00 golden shell

在这里插入图片描述

[email protected]:/mnt/user/domains/centos7gnome# lvdisplay
WARNING: Device /dev/nbd0p2 has size of 60815360 sectors which is smaller than corresponding PV size of 209713152 sectors. Was device resized?
WARNING: One or more devices used as PVs in VG centos have changed sizes.
— Logical volume —
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID PzmI1T-EsXO-EODD-B2gf-1ks2-4D3W-JUURGB
LV Write Access read/write
LV Creation host, time localhost, 2022-02-19 15:39:45 +0800
LV Status available

open 0

LV Size 3.00 GiB
Current LE 768
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 256
    Block device 254:0

— Logical volume —
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID CUedtr-rcMs-kH1t-WnMS-oIy1-j07P-2i3vyI
LV Write Access read/write
LV Creation host, time localhost, 2022-02-19 15:39:45 +0800
LV Status NOT available
LV Size <97.00 GiB
Current LE 24831
Segments 1
Allocation inherit
Read ahead sectors auto

[email protected]:/mnt/user/domains/centos7gnome# lvchange -a y /dev/centos/root
WARNING: Device /dev/nbd0p2 has size of 60815360 sectors which is smaller than corresponding PV size of 209713152 sectors. Was device resized?
WARNING: One or more devices used as PVs in VG centos have changed sizes.
device-mapper: reload ioctl on (254:1) failed: Invalid argument

命令参考
kvmdisk change size
qemu-img resize vdisk1.img -10G

 modprobe nbd max_part=8
 modinfo nbd 
 网络挂载
 qemu-nbd --connect=/dev/nbd0 vdisk1.img 
ls /dev/nbd0*

lsblk
nbd0 43:0 0 110G 0 disk
├─nbd0p1 43:1 0 1G 0 part
└─nbd0p2 43:2 0 45.6G 0 part
#The following warning is created because ofPV在 分区2上,但是PVBut it is bigger than the partition,所以报警
[email protected]:~# lvdisplay
WARNING: Device /dev/nbd0p2 has size of 189307051 sectors which is smaller than corresponding PV size of 220198912 sectors. Was device resized?
WARNING: One or more devices used as PVs in VG centos have changed sizes.
— Logical volume —
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID CUedtr-rcMs-kH1t-WnMS-oIy1-j07P-2i3vyI
LV Write Access read/write
LV Creation host, time localhost, 2022-02-19 15:39:45 +0800
LV Status NOT available
LV Size <97.00 GiB

[email protected]:~# lvdisplay
— Logical volume —
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID CUedtr-rcMs-kH1t-WnMS-oIy1-j07P-2i3vyI
LV Write Access read/write
LV Creation host, time localhost, 2022-02-19 15:39:45 +0800
LV Status NOT available
LV Size <97.00 GiB
Current LE 24831
Segments 1
Allocation inherit
Read ahead sectors auto
调整分区2,增大分区
[email protected]:~# parted /dev/nbd0
GNU Parted 3.3
Using /dev/nbd0
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) resizepart
Partition number? 2
End? [98.0GB]? 150G
(parted) quit
Information: You may need to update /etc/fstab.
激活LV
[email protected]:~# lvchange -ay /dev/centos/root

ca参考
https://unix.stackexchange.com/questions/668491/how-can-i-fix-lvm-pv-size-after-a-botched-encrypted-partition-shrinking
[email protected]:~# qemu-nbd --disconnect /dev/nbd0
/dev/nbd0 disconnected

[email protected]:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nbd0 43:0 0 230G 0 disk
├─nbd0p1 43:1 0 1G 0 part
└─nbd0p2 43:2 0 138.7G 0 part
├─centos-root 253:0 0 97G 0 lvm /mnt
└─centos-swap 253:1 0 1G 0 lvm

// 下面 不加参数 --shrink The same will reduce the space,So it only needs to be executed once
[email protected]:~# qemu-img resize /data/centos7gnome/vdisk1.img -80G
WARNING: Image format was not specified for ‘/data/centos7gnome/vdisk1.img’ and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the ‘raw’ format explicitly to remove the restrictions.
qemu-img: warning: Shrinking an image will delete all data beyond the shrunken image’s end. Before performing such an operation, make sure there is no important data there.
qemu-img: warning: Using the --shrink option will suppress this message. Note that future versions of qemu-img may refuse to shrink images without this option.
Image resized.

[email protected]:~# qemu-img resize --shrink /data/centos7gnome/vdisk1.img -80G
WARNING: Image format was not specified for ‘/data/centos7gnome/vdisk1.img’ and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the ‘raw’ format explicitly to remove the restrictions.
Image resized.

[email protected]:~# qemu-nbd --connect=/dev/nbd0 /data/centos7gnome/vdisk1.img
WARNING: Image format was not specified for ‘/data/centos7gnome/vdisk1.img’ and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the ‘raw’ format explicitly to remove the restrictions.
[email protected]:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nbd0 43:0 0 70G 0 disk
├─nbd0p1 43:1 0 1G 0 part
└─nbd0p2 43:2 0 138.7G 0 part
├─centos-root 253:0 0 97G 0 lvm /mnt
└─centos-swap 253:1 0 1G 0 lvm
vda 252:0 0 100G 0 disk
├─vda1 252:1 0 512M 0 part /boot/efi
└─vda2 252:2 0 99.5G 0 part /
vdb 252:16 0 300G 0 disk
└─vdb1 252:17 0 300G 0 part /data
[email protected]:~# qemu-
qemu-img qemu-io qemu-make-debian-root qemu-nbd
[email protected]:~# qemu-img info /data/centos7gnome/vdisk1.img
image: /data/centos7gnome/vdisk1.img
file format: raw
virtual size: 70 GiB (75161927680 bytes)
disk size: 26.8 GiB
[email protected]:~# qemu-nbd --disconnect /dev/nbd0
/dev/nbd0 disconnected
[email protected]:~# qemu-img resize /data/centos7gnome/vdisk1.img +70G
WARNING: Image format was not specified for ‘/data/centos7gnome/vdisk1.img’ and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the ‘raw’ format explicitly to remove the restrictions.
Image resized.
[email protected]:~# qemu-nbd --disconnect /dev/nbd0
/dev/nbd0 disconnected
[email protected]:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nbd0 43:0 0 70G 0 disk
├─nbd0p1 43:1 0 1G 0 part
└─nbd0p2 43:2 0 138.7G 0 part
├─centos-root 253:0 0 97G 0 lvm /mnt
└─centos-swap 253:1 0 1G 0 lvm
vda 252:0 0 100G 0 disk
├─vda1 252:1 0 512M 0 part /boot/efi
└─vda2 252:2 0 99.5G 0 part /
vdb 252:16 0 300G 0 disk
└─vdb1 252:17 0 300G 0 part /data
The above is overdone,又加了70G,But not recognized,我重启了一下,重新挂载,可以了
reboot
[email protected]:~# modprobe nbd max_part=8
[email protected]:~# modinfo nbd
filename: /lib/modules/5.15.0-43-generic/kernel/drivers/block/nbd.ko
license: GPL
description: Network Block Device
srcversion: 731761EF8701CE7664A4043
depends:
retpoline: Y
intree: Y
name: nbd
vermagic: 5.15.0-43-generic SMP mod_unload modversions
sig_id: PKCS#7
signer: Build time autogenerated kernel key
sig_key: 7A:F3:57:B7:E5:14:B9:79:D9:12:51:C0:FF:1B:69:A6:3E:17:29:B3
sig_hashalgo: sha512
signature: 80:36:B3:26:15:71:36:53:89:1A:2F:45:9F:3E:33:98:16:07:0A:E8:
B5:F9:A6:52:36:92:0A:02:0C:E7:8D:C4:5A:87:DE:6C:B6:47:B9:58:
26:22:40:E8:68:C4:B9:B3:B1:B1:59:B6:F3:A7:88:CC:EA:0C:6C:45:
F5:2D:4E:70:0A:07:A9:65:23:A6:BA:2F:94:69:C3:94:D8:7F:06:09:
52:5F:F5:E4:8A:70:1E:6B:F3:AB:2E:F8:06:6A:43:59:58:7F:82:B1:
E5:83:4D:3A:D9:38:07:B5:1E:60:68:EB:35:21:CF:13:03:2E:FF:26:
64:ED:AD:B6:8C:A1:11:88:5C:0E:3B:79:2A:B1:9A:27:55:E4:D3:40:
AF:0D:A4:40:30:39:57:F8:34:45:B9:28:92:12:6B:6E:C7:90:1D:29:
AA:87:A2:38:B3:A6:DF:03:D6:EC:88:D8:07:25:8E:38:BE:5E:6B:6A:
DC:EE:F4:23:F8:DE:E6:5B:A7:28:D9:FA:3B:74:2F:D7:40:7D:97:D2:
DB:28:2F:2C:AF:DB:AF:07:FA:DD:F2:0C:5E:68:33:F9:58:81:EF:02:
5E:53:BB:F2:61:CC:7B:BE:2F:7A:B1:92:E7:42:70:35:5D:15:49:F3:
52:0D:88:4A:AE:B1:8F:D0:A8:C1:B8:F2:BB:E8:AD:6D:E9:2E:D5:51:
25:5E:FD:F7:0E:9D:12:BA:70:91:4C:24:B5:A6:14:06:19:2F:B8:A7:
4F:DC:9D:A2:C0:D0:47:B0:81:97:F0:26:A0:DF:11:BD:0C:DE:73:8A:
E2:02:31:23:9A:1D:9C:AD:B9:85:F6:D1:BA:52:15:8A:59:97:C7:3D:
CD:83:31:1B:DE:9A:39:9A:A2:47:7A:58:EB:8C:2B:25:87:48:6E:2E:
FE:2E:66:ED:1B:AE:CF:EF:2A:E4:C5:0C:1A:98:61:15:77:27:09:9E:
82:58:B4:86:D4:07:F4:F4:EB:8E:C6:FE:B5:B1:0F:CA:D4:E3:7F:26:
CB:87:69:69:AC:3B:93:F9:8C:3B:7A:F4:07:FB:3A:A3:B2:09:F3:21:
6E:00:BD:61:5D:AE:5A:23:91:CA:1B:E8:B0:29:38:83:84:80:DD:61:
AB:43:C1:82:40:86:E3:40:DE:11:08:A5:90:00:9C:A2:2E:C8:F1:96:
93:0B:7A:B0:EF:2F:C0:AE:67:6E:CA:7A:BA:5B:C9:AE:B9:4B:8E:6A:
FF:B9:DD:9F:C8:3B:08:01:4F:28:11:B8:D2:E7:2A:F2:FC:E8:FA:34:
BE:D4:30:CF:56:87:C9:AA:0D:30:F0:19:83:A2:BC:7A:90:4D:30:EE:
CE:33:0C:94:60:41:39:91:14:F5:4C:4C
parm: nbds_max:number of network block devices to initialize (default: 16) (int)
parm: max_part:number of partitions per device (default: 16) (int)
[email protected]:~# qemu-nbd --connect=/dev/nbd0 /data/centos7gnome/vdisk1.img
WARNING: Image format was not specified for ‘/data/centos7gnome/vdisk1.img’ and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the ‘raw’ format explicitly to remove the restrictions.
[email protected]:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nbd0 43:0 0 140G 0 disk
├─nbd0p1 43:1 0 1G 0 part
└─nbd0p2 43:2 0 138.7G 0 part
├─centos-root 253:0 0 97G 0 lvm
└─centos-swap 253:1 0 1G 0 lvm
vda 252:0 0 100G 0 disk
├─vda1 252:1 0 512M 0 part /boot/efi
└─vda2 252:2 0 99.5G 0 part /
vdb 252:16 0 300G 0 disk
└─vdb1 252:17 0 300G 0 part /data
[email protected]:~# lvdisplay
— Logical volume —
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID CUedtr-rcMs-kH1t-WnMS-oIy1-j07P-2i3vyI
LV Write Access read/write
LV Creation host, time localhost, 2022-02-19 15:39:45 +0800
LV Status available

open 0

LV Size <97.00 GiB
Current LE 24831
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 256
    Block device 253:0

— Logical volume —
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID MpdAnz-8fCp-ghjW-FduO-QsPQ-lmvS-0tpptx
LV Write Access read/write
LV Creation host, time ubuntu20, 2022-08-05 11:28:12 +0800
LV Status available

open 0

LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 256
    Block device 253:1

[email protected]:~# mount /dev/centos/
root swap
[email protected]:~# mount /dev/centos/root /mnt/
[email protected]:~# ls /mnt/
.autorelabel dev/ lib/ mnt/ proc/ root/ srv/ usr/ yum/
bin/ etc/ lib64/ opt/ ql/ run/ sys/ var/
boot/ home/ media/ patch/ .Recycle_bin/ sbin/ tmp/ www/
[email protected]:~# ls /mnt/www/
这样LV 就能正常使用了,The virtual machine can also be powered on

参考https://blog.csdn.net/zhongbeida_xue/article/details/81914357
Repair the specified partition

fsck -y /dev/VolGroup00/LogVol0

… …
Free blocks count wrong (5069553, counted=5070543).
Fix? yes

/dev/mapper/VolGroup00-LogVol00: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/VolGroup00-LogVol00: 79036/5744640 files (0.7% non-contiguous), 672049/5742592 blocks

原网站

版权声明
本文为[golden shell]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208091941455893.html