Mounting / Unmounting KVM Image: Difference between revisions
From Leo's Notes
This page was last edited on 1 September 2019, at 06:21.
m Text replacement - "<code>" to "{{code|" |
m Text replacement - "Category:Linux{{Navbox Linux}}" to "{{Navbox Linux}}Category:Linux" |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Suppose you have a KVM virtual machine using a virtual disk located in a LV group. To gain access to the data, use {{code|kpartx | Suppose you have a KVM virtual machine using a virtual disk located in a LV group. To gain access to the data, use {{code|kpartx}}. | ||
To list partitions in the disk image: | To list partitions in the disk image: | ||
| Line 6: | Line 6: | ||
vol_vm1-kvm101_img2 : 0 1048576 /dev/vol_vm1/kvm101_img 61861504 | vol_vm1-kvm101_img2 : 0 1048576 /dev/vol_vm1/kvm101_img 61861504 | ||
Knowing that the first partition is {{code|/ | Knowing that the first partition is {{code|/}} and the second is the swap, we will attempt to mount the first partition. | ||
To map the parititions: | To map the parititions: | ||
| Line 20: | Line 20: | ||
# kpartx -d /dev/vol_vm1/kvm101_img | # kpartx -d /dev/vol_vm1/kvm101_img | ||
[[Category:Linux]] | {{Navbox Linux}}[[Category:Linux]] | ||
Latest revision as of 06:21, 1 September 2019
Suppose you have a KVM virtual machine using a virtual disk located in a LV group. To gain access to the data, use kpartx.
To list partitions in the disk image:
# kpartx -l /dev/vol_vm1/kvm101_img vol_vm1-kvm101_img1 : 0 61861441 /dev/vol_vm1/kvm101_img 63 vol_vm1-kvm101_img2 : 0 1048576 /dev/vol_vm1/kvm101_img 61861504
Knowing that the first partition is / and the second is the swap, we will attempt to mount the first partition.
To map the parititions:
# kpartx -av /dev/vol_vm1/kvm101_img add map vol_vm1-kvm101_img1 (253:6): 0 61861441 linear /dev/vol_vm1/kvm101_img 63 add map vol_vm1-kvm101_img2 (253:7): 0 1048576 linear /dev/vol_vm1/kvm101_img 61861504
To mount the newly mapped partitions:
# mount -t ext4 -o ro /dev/mapper/vol_vm1-kvm101_img1 /mnt/vm101
Once completed, simply unmount and unmap the image:
# umount /mnt/vm101 # kpartx -d /dev/vol_vm1/kvm101_img