Accessing xen guest image is very easy if the image is not lvm partitioned. But the main problem arise when the image is of lvm format and normal mount command cannot be used. Here I will show both the way. The first is when ext filesystem is used, and the second is when lvm is used.
To mount xen guest image (without lvm)
1. check the partition on the image
# fdisk -lu
The result will be something like this:
2. Mount using offset option
# mount -o loop,offset=106929152 /path/to/image /mnt
where 106929152=208846*512, 208846 is the start of the partition. Using this way, you only mount the second partition and not the whole image
3. You can now access your image at /mnt
To mount xen guest image (with lvm)
1. Check the partition on the image
# fdisk -lu /path/to/image
2. You have to install kpartx to handle lvm partiton
# yum install kpartx
3. Run kpartx on the image
# kpartx -av /path/to/image
4. Run vgscan to scan volume group available
# vgscan
5. Run vgchange to activate the volume group in the image
# vgchange -ay VolGroup00
6. Use lvs to see what is the name of your low volume group
# lvs
7. Mount the low volume group
# mount /dev/VolGroup00/LogVol01 /mnt
8. You can access your lvm image at the mounted directory which is /mnt
9. To unmount it, a few commands have to be executed (umount for unmounting, vgchange -an to deactivate volume group, kpartx -d to delete device map and losetup -d to delete loop device used)
# umount /mnt/
# vgchange -an VolGroup00
# kpartx -d /path/to/image
# losetup -d /dev/loop0
Hope this will be useful
Monday, February 11, 2008
Accessing data on xen lvm guest image
Labels:
Backup,
LVM,
virtualization,
xen
Subscribe to:
Post Comments (Atom)
18 comments:
thank you very much! worked for me
very useful...
Thanks for the tip
Thank you, it works well
Thank you very much! Short, easy and extremely useful for all XEN users!
Hm, doesn't really help if the outer and the inner LVM are called the same.
:(
Caela;
If outer and inner are with the same name, you have to rename either one of them That is the only way to do it, from my knowledge :)
Great post. I had been looking for this information for a very long time.
Thank you!
Many thanks for this! The -o offset=XXX was new to me. But be warned that mount may fail with confusing errors if you try this on a running vm. Be sure to shut down the guest before mounting the lvm partition in the host.
Thank you !!!
You saved me some time with this ... was recovering FTP server config :D
Thanks!
I was following your method so I could use the LVM Volume for a RAW VMDK for yuse with Virtualbox.
For me it did not create /dev/VolGroup00/LogVol01 but instead created /dev/disk/by-id/raid-VolGroup00-LogVol01-part1
Additionally this was an NTFS formatted volume but it mounted fine by using the alternate device.
thanks!
Perfect.
Thank you.
It works! Thanks a lot for this help. One quick question: when file system is mounted, the /proc file system of the VM is not visible. Is there any idea how to read information from the /proc file system? Or I need to dump the data of /proc inside the VM to read it from somewhere else? Thanks!
@Steve - The /proc fs is a pseudo-fs that only exists to make kernel configuration and running processes accessible as files. It is created at boot time so the directories under /proc don't exist in the static VM image.
Another good use for this is to be able to mount iSCSI targets on the server as read-only for backing up data stored there. I haven't tried mounting while the client is actively using the device.
on ubuntu:
mount: you must specify the filesystem type
sudo mount -t ext3 /dev/VolGroup/imgname /mnt
Thank you! Lifesaver!
Robert
Thank you! Lifesaver!
Robert
Post a Comment