kvm虚拟机出现启动不了,NOT available,PV大于分区 - 学新通技术网

  • 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

kvm虚拟机出现启动不了,NOT available,PV大于分区

武飞扬头像
金shell
帮助1

学新通

root@Tower:/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

root@Tower:/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

命令参考
kvm盘更改大小
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
#下面的警告是因为创建的PV在 分区2上,但是PV却比分区大,所以报警
root@ubuntu20:~# 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

root@ubuntu20:~# 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,增大分区
root@ubuntu20:~# 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
root@ubuntu20:~# 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
root@ubuntu20:~# qemu-nbd --disconnect /dev/nbd0
/dev/nbd0 disconnected

root@ubuntu20:~# 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 一样会减去空间,所以只需要执行一次就好
root@ubuntu20:~# 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.

root@ubuntu20:~# 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.

root@ubuntu20:~# 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.
root@ubuntu20:~# 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
root@ubuntu20:~# qemu-
qemu-img qemu-io qemu-make-debian-root qemu-nbd
root@ubuntu20:~# 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
root@ubuntu20:~# qemu-nbd --disconnect /dev/nbd0
/dev/nbd0 disconnected
root@ubuntu20:~# 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.
root@ubuntu20:~# qemu-nbd --disconnect /dev/nbd0
/dev/nbd0 disconnected
root@ubuntu20:~# 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
上面删减过头了,又加了70G,但是不识别,我重启了一下,重新挂载,可以了
reboot
root@ubuntu20:~# modprobe nbd max_part=8
root@ubuntu20:~# 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)
root@ubuntu20:~# 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.
root@ubuntu20:~# 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
root@ubuntu20:~# 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

root@ubuntu20:~# mount /dev/centos/
root swap
root@ubuntu20:~# mount /dev/centos/root /mnt/
root@ubuntu20:~# 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/
root@ubuntu20:~# ls /mnt/www/
这样LV 就能正常使用了,虚拟机也可以开机了

参考https://blog.csdn.net/zhongbeida_xue/article/details/81914357
修复指定分区

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

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhggefae
系列文章
更多 icon
同类精品
更多 icon
继续加载