Hi Folks,
I search for a way to mount the .img files virt-install creates for Xen VMs. Using fdisk -lu I found it contains to 2 partitions:
# fdisk -lu /var/lib/xen/images/BaseCentos.img last_lba(): I don't know how to handle files with mode 81ed Sie müssen angeben Zylinder. Sie können dies im Zusatzfunktionsmenü tun.
Platte /var/lib/xen/images/BaseCentos.img: 0 MByte, 0 Byte 255 heads, 63 sectors/track, 0 cylinders, zusammen 0 Sektoren Einheiten = Sektoren von 1 × 512 = 512 Bytes
Gerät boot. Anfang Ende Blöcke Id System /var/lib/xen/images/BaseCentos.img1 * 63 208844
104391 83 Linux
/var/lib/xen/images/BaseCentos.img2 208845 8177084
3984120 8e Linux LVM
And I can mount the first partition with no problem using the offset (start) from the partition table:
mount -o loop,offset=$((63*512) /PATH/TO/IMAGE.img /MOUNTPOINT
But I cannot mount the second partition using the offset of it:
mount -o loop,offset=$((208845*512)) /PATH/TO/IMAGE.img /MOUNTPOINT mount: you have to specify the file system type
Even using ext3, ext2 does not work. I do not think the offset is incorrect - I venture it is because the second partition is LVM (8e).
Did anybody out there succeed in mounting an LVM partition out of an image file?
Any hint or help is appreciated.
Dirk
Dirk H. Schulz wrote: <snip>- I venture it is because the second partition is LVM (8e).
Did anybody out there succeed in mounting an LVM partition out of an image file?
That's why kpartx (for lvm) and lomount exist ;-) Don't forget after you've used kpartx -a to use lvscan to discover your lv and vgchange ...
Hi Fabian,
--On 7. August 2008 16:22:36 +0200 Fabian Arrotin fabian.arrotin@arrfab.net wrote:
Dirk H. Schulz wrote: <snip>- I venture it is because the second partition is LVM (8e).
Did anybody out there succeed in mounting an LVM partition out of an image file?
That's why kpartx (for lvm) and lomount exist ;-) Don't forget after you've used kpartx -a to use lvscan to discover your lv and vgchange ...
- snip -
I had hoped for some other way because there is an open bug in kpartx on recent CentOS which leads to
failed to stat() /var/lib/xen/images/BaseCentos.img
Seems to work only with rather small img files.
Do you have any other idea?
Dirk
Dirk H. Schulz wrote on Thu, 07 Aug 2008 16:46:47 +0200:
Do you have any other idea?
Do you want to regularly access it that way or do you just need to access the files onetime? I do not like this xvda stuff at all. So I created a basic setup with virt-install and copied all content off (I don't know what I used, I assume cp or rsync or so). I used these files for a new VM based on ext3 formatted disks (you can either use files or LV). Can be done within 15 minutes or so. I tweaked that a bit to my liking and now use it as a template for new VMs. As the disks are ext3 I can now easily access the drives by mounting that LV.
Kai
Hi Kai,
--On 7. August 2008 20:31:22 +0200 Kai Schaetzl maillists@conactive.com wrote:
Dirk H. Schulz wrote on Thu, 07 Aug 2008 16:46:47 +0200:
Do you have any other idea?
Do you want to regularly access it that way or do you just need to access the files onetime? I do not like this xvda stuff at all. So I created a basic setup with virt-install
You are talking about a basic vm installation to a partition instead of an image file?
and copied all content off (I don't know what I used, I assume cp or rsync or so). I used these files for a new VM based on ext3 formatted disks (you can either use files or LV). Can be done within 15 minutes or so. I tweaked that a bit to my liking and now use it as a template for new VMs. As the disks are ext3 I can now easily access the drives by mounting that LV.
I should have done that. I always did it when I compiled xen on my own using Debian. Now I tried to use the easy way the RedHat tools suggest, but more and more I come to regret it. If they work at all you one way or the other do not like the outcome.
Dirk
Dirk H. Schulz wrote on Fri, 08 Aug 2008 07:13:01 +0200:
You are talking about a basic vm installation to a partition instead of an image file?
That doesn't make a difference. Whether you virt-install to file or partition you end up with xvda'd disks.
If they work at all you one way or the other do not like the outcome.
Well, they do work quite well. I did a lot of installs with virt-install and kickstart. A pleasure. If you don't mind ending up with xvda it's a good way. Depends on your needs. I need customized installations for webhosting that have quite a few additional programs installed and preconfigured and going with template disks is the much easier way then. And then it pays to be able to access the disks anytime with a simple mount.
Kai
Hi Kai,
--On 8. August 2008 10:31:18 +0200 Kai Schaetzl maillists@conactive.com wrote:
- snip -
If you don't mind ending up with xvda it's a good way.
What is the problem with xvda? And what is the alternative?
Dirk
Dirk H. Schulz wrote on Fri, 08 Aug 2008 14:54:20 +0200:
What is the problem with xvda? And what is the alternative?
Didn't we just discuss that? xvda doesn't allow you simple mounting of the disk from the host, be it file or LV.
Kai
Kai,
I am sorry, but I simply do not understand at the moment. I thought xvda is the method the disks are mounted into the VM - you sound like it being the format of the disk itself.
Please explain.
Dirk
--On 8. August 2008 20:31:15 +0200 Kai Schaetzl maillists@conactive.com wrote:
Dirk H. Schulz wrote on Fri, 08 Aug 2008 14:54:20 +0200:
What is the problem with xvda? And what is the alternative?
Didn't we just discuss that? xvda doesn't allow you simple mounting of the disk from the host, be it file or LV.
Kai
-- Kai Schätzl, Berlin, Germany Get your web at Conactive Internet Services: http://www.conactive.com
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
-------------------------------------------------------------- Dirk H. Schulz IT Systems Service Wiesenweg 12, 85567 Grafing Tel. 0 80 92/86 25 68 Fax. 0 80 92/86 25 72 -------------------------------------------------------------- Technik vom Feinsten - und das nötige Tuning