[clug] LVM Partion Access
Scott Ferguson
scott.ferguson.clug at gmail.com
Wed Sep 14 23:19:47 MDT 2011
On 14/09/11 14:21, Brett Worth wrote:
> Hello All!
>
> From time to time I have mounted a virtual machine's disk image file on
> the host server. There are three scenarios:
>
> 1. The image file contains just a filesystem
> mount -o loop IMAGEFILE /mnt
>
> 2. The image has a partition table
> kpartx -av IMAGEFILE
> mount /dev/mapper/loop0pN /mnt
>
> 3. The image has a partition table and one of the partitions has been
> given to LVM.
> kpartx -av IMAGEFILE
> (magic commands)
> mount /dev/mapper/MyNewVolGroup-LogVol00 /mnt
>
> Can someone tell me what goes in the brackets? I have a feeling it will
> need to be imported into the host server's LVM config which means it
> would then have to be exported again before the VM can use it.
>
> Anyone?
>
> Brett
fdisk -lu $LOOP
but there are several other approaches....
/data/kvm# file IMAGEFILE
note down the start sector
/data/kvm# losetup -v -o $[BLOCKSIZE*START_SECTOR] /dev/loop0 IMAGEFILE
/data/kvm# lvm pvscan
alternatively:-
losetup $LOOP IMAGE MOUNT
kpartx -av $LOOP
fdisk -lu $LOOP
mount ${LOOP}p1 /tmp/part1
ls /tmp/part1
LVM?
lvdisplay -c
(find /dev/mapper)
mount /dev/mapper/$LV /tmp/lv
ls /tmp/lv
Cheers
More information about the linux
mailing list