How to Mount a REAL disk/lvm as a virtual machine disk

nicolasdiogo

Member
Mar 16, 2010
92
0
6
hi,

i am using KVM and i would like to know if there is a way of mounting a REAL disk or a LVM in a KVM machine?

if anyone has a link to documentation on this, it would be much appreciated.

Thanks,


Nicolas
 
hi tom,

once again thanks,

i have checked the mentioned posts and have decided to amend my configuration file by adding a new line such as:

Code:
ide1: /dev/mapper/lvm_grp_disk00-share00

so when i try to mount it on the guest (ubuntu) i can not find any valid disk table (which is correct)

so would it be possible to mount lvm on a guest???

many thanks

Nicolas
 
here is how the disk is seem by the guest:
Code:
# fdisk -l

Disk /dev/sda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000afffb

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          31      248976   83  Linux
/dev/sda2              32        1566    12329887+   5  Extended
/dev/sda5              32        1566    12329856   8e  Linux LVM

Disk /dev/sdb: 960.0 GB, 960004882432 bytes
255 heads, 63 sectors/track, 116713 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
as you can see the scans do not help at all..
Code:
# lvscan
  ACTIVE            '/dev/lvm_grp_disk00/root00' [10.74 GB] inherit
  ACTIVE            '/dev/lvm_grp_disk00/swap00' [1.02 GB] inherit
# pvscan
  PV /dev/sda5   VG lvm_grp_disk00   lvm2 [11.76 GB / 0    free]
  Total: 1 [11.76 GB] / in use: 1 [11.76 GB] / in no VG: 0 [0   ]
# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "lvm_grp_disk00" using metadata type lvm2

thanks
 
Code:
ide1: /dev/mapper/lvm_grp_disk00-share00

so when i try to mount it on the guest (ubuntu) i can not find any valid disk table (which is correct)

So it works perfectly - what is the problem?

so would it be possible to mount lvm on a guest???

You can mount it if you create a partion and and filsystem on the device.
 
hi dietmar,

as i said it is working correctly - i am considering if i have used it correctly.

by mounting a lvm volume the new device (from guest's perspective) does not have a disk partition.
but from the host supporting the guest, this lvm volume is already formatted and contains data.

thus i wondered if there was some way of mounting this (see fdisk -l output posted prior) disk using
-o loop
in such a way to reuse/preserve existing data?

is this clear now.
 
Code:
mount -text3 /dev/sdb /mnt/
mount: wrong fs type, bad option, bad superblock on /dev/sdb,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
 
sorry for delay

on host, i can mount it just fine..

on guest the log gives

Code:
[209311.383798] EXT3-fs: sdb: couldn't mount because of unsupported optional features (240).
[211302.399820] EXT3-fs: sdb: couldn't mount because of unsupported optional features (240).
after trying to mount it twice.

does that help?

i have also tried to understand this article, which seems to be related:
http://www.aczoom.com/cms/software/resize-nested-lvm-inside-kvm-machines

and mentions this tool:
http://robert.penz.name/73/kpartx-a-tool-for-mounting-partitions-within-an-image-file/

am i on the right track here?
 
Last edited:
Code:
[209311.383798] EXT3-fs: sdb: couldn't mount because of unsupported optional features (240).
[211302.399820] EXT3-fs: sdb: couldn't mount because of unsupported optional features (240).

Maybe you should use a newer kernel in the guest?
 
thanks Dietmar,

but i think i have latest one already and it is not working either; it is a ubuntu LTS 8.04 (hardy)

Code:
Linux mybox.lan 2.6.24-27-server #1 SMP Fri Mar 12 01:23:09 UTC 2010 x86_64 GNU/Linux
so from your comment i would guess that i need to have yet a newer version for it work.
is that correct?

thanks,
 
[/code]so from your comment i would guess that i need to have yet a newer version for it work.
is that correct?

I just try to understand that error message: "couldn't mount because of unsupported optional features"

Obviously, on the system you created that filesystem there was a newer version of the filesystem driver/tools? But you can already mount it on the host, so maybe that can't be the problem.
 
i really hate to dig up an old thread. This conversation has helped but i have one question.
If i mount a ext file system from the host to the guest and write data to it from the guest and later decide to remove the disk and read it from another machine (not virtualized) will this work The thinking is i would like to mount a usb disk to a vm for it to do data backups to. pictures docs ect. in the event that my vm or host fails i would like to be able to plug it into another machine and just read the files.
I think this should work but i just wanted to hear it from the experts. thanks
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, 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 yours easily in our online shop.

Buy now!