How to Mount a Specific Partition of a Xen File-backed Virtual Disk

By: sandholm

August 25, 2007 5:02 am





By Tom Sandholm


How to mount a specific partition of a XEN file-backed virtual disk from the host OS.


  1. Locate the virtual-disk file and list it’s content using fdisk. For example:
beast2:/extra/xen/images/vm2 # fdisk -luC 530 ./hda

Disk ./hda: 0 MB, 0 bytes
255 heads, 63 sectors/track, 530 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes

Device Boot      Start         End      Blocks   Id  System
./hda1              63     1060289      530113+  82  Linux swap / Solaris
./hda2   *     1060290    11550734     5245222+  83  Linux
./hda3        11550735    16771859     2610562+  83  Linux
Partition 3 has different physical/logical endings:
     phys=(1023, 254, 63) logical=(1043, 254, 63)
beast2:/extra/xen/images/vm2 #


  1. Identify the particular partition you wish to mount. In this example I wish to mount ./hda1, which is my root partition. You will need to multiply the starting cylinder number times 512 to obtain the mount offset. For example, the hda1 partition is at cylinder address 1060290, so I will multiple 1060290 * 512, which yields, 542868480.


  1. Use the mount command with loopback and offset options to mount the virtual-disk partition, for example:
beast2:/extra/xen/images/vm2 # mount -o loop,offset=542868480 ./hda ./mnt
beast2:/extra/xen/images/vm2 # ls ./mnt
bin   dev  home  lost+found  mnt   mnt2  proc    root  srv      sys  usr
boot  etc  lib   media       mnt1  opt   remote  sbin  success  tmp  var
beast2:/extra/xen/images/vm2 #

Now you can see the content of my ./hda1 partition.


Using XEN on openSuSE 10.2, on an EMachines AMD +3000, with 2GB ram.

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.

Tags: ,
Categories: openSUSE, Technical Solutions, Virtualization

Disclaimer: As with everything else in the SUSE Blog, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.