Categories
Belekas Trumpi

mount KVM used LVM on host

  1. Identify VM which FS you need to mount on host. virsh list –all
  2. If that VM is on, maybe you can scp from there? If no, better poweroff VM.
  3. identify your VM used LV, or just check it: virsh domblklist vm01
  4. Create a temp LVM to have your host VG identified: lvcreate -L 1M -n identifier /dev/VolGroup_HOST .
  5. Scan partitions on LV: kpartx -av /dev/VolGroup_HOST/vm01
  6. vgscan
  7. IF you use same names for VG in VM and host, better rename VG for now, so you would not mix it. But keep in mind, that if you have any references in configs, this might impact your system, if you use UUID, should be ok. So: vgrename UUID VolGroup_VM01 # I use different VG names for hosts. (vgdisplay to identify which UUID is for your group, THANKS TO our identifier!).
  8. lvscan
  9. In my case after vgscan or lvscan my VG got activated. But If you don’t, here is how: vgchange -ay VolGroup_VM01 ; lvscan
  10. mkdir -p /mnt/vm01 ; mount /dev/VolGroup_VM01/root /mnt/vm01
  11. DO what you need
  12. Double check your /mnt/vm01/etc/fstab (We changed VGName, remember?!
  13. umount /mnt/vm01
  14. vgchange -an VolGroup_VM01
  15. kpartx -dv /dev/VolGroup_HOST/vm01
  16. pvscan
  17. Launch vm01: virsh start vm01 ; virsh console vm01
  18. and remove identifier if it is bothering you. lvremove /dev/VolGroup_HOST/identifier, I think…

External Link

https://serverfault.com/questions/287070/how-to-mount-virtual-machines-lvm-partition-on-kvm-host

By Ruslanas Gžibovskis

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.