KVM Gotchas
Jump to navigation
Jump to search
Common useful commands for KVM Guests
LVM error fixes:
- not exclusive for KVM, but since I have so many of these VM's thats where I see it a lot.
- commonly happens when do-release-upgrade is run, or when some updates happen to the lvm code. My GUESS is that the metadata contains the lvm version in there somewhere and does not get updated.
- This fix is only for the metadata
WARNING: PV /dev/sda5 in VG dns01-vg is using an old PV header, modify the VG to update.
Fix:
vgck --updatemetadata dns01-vg vgck --updatemetadata <VG Name from warning message>
Create new Image
qemu-img create -f qcow2 -o preallocation=metadata FILENAME.qcow2 XXXG
Repair damaged guest disk
This is the fourth time I have had to do this after power outages.. Document it dummy!
IMAGE=/media/kvm/some_disk_image
sudo cp --reflink=auto --sparse=always "$IMAGE" "${IMAGE}.before-fsck"
sudo modprobe nbd max_part=16
sudo qemu-nbd --connect=/dev/nbd0 "$IMAGE"
sudo partprobe /dev/nbd0
sudo udevadm settle
lsblk -f /dev/nbd0
sudo blkid /dev/nbd0p*
sudo e2fsck -f /dev/87ef1064-be4b-40dd-90d4-1d10ba844913
sudo e2fsck -f /dev/nbd0p1 -y
sudo qemu-nbd --disconnect /dev/nbd0