How can i mount a Partition of a VM-LVM

Jan 9, 2012
282
1
18
Hi,

i have installed a Ubuntu-VM on a LVM.

When the VM is running

fdisk -l /dev/Raid-VG/vm-103-disk-1
shows

Device Boot Start End Blocks Id System
/dev/Raid-VG/vm-103-disk-1p1 * 1 2497 20051968 83 Linux
/dev/Raid-VG/vm-103-disk-1p2 2497 2611 916481 5 Extended
/dev/Raid-VG/vm-103-disk-1p5 2497 2611 916480 82 Linux swap / Solaris
But when the VM is off, the fdisk-command shows nothing.

Is it possible to mount the partitions of "/dev/Raid-VG/vm-103-disk-1p1" from the host?


Alex
 

e100

Active Member
Nov 6, 2010
1,235
24
38
Columbus, Ohio
ulbuilder.wordpress.com
You need to use a utility named kpartx

Install it:
Code:
apt-get install kpartx
Run it:
Code:
kpartx -a /dev/Raid-VG/vm-103-disk-1
See new mappings:
Code:
ls /dev/mapper/
Mount the first partition:
Code:
mount /dev/mapper/Raid-VG-vm--103--disk--1p1 /mnt
Unmount:
Code:
umount /mnt
Undo what kpartx did and return system to normal:
Code:
kpartx -d /dev/Raid-VG/vm-103-disk-1
 

Faye

Member
Jan 2, 2012
39
0
6
This is excellent. Any idea how to install grub on a VM image created this way? My goal is to use the same tar ball for VMs as containers. I struggled a lot and failed. There's probably a simple answer.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!