Article

sandholm's picture
article
Reads:

6286

Score:
1.5
1.5
2
 
Comments:

0

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

Author Info

25 August 2007 - 4:02am
Submitted by: sandholm

(View Disclaimer)

By Tom Sandholm

Problem:

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

Solution:

  1. Locate the virtual-disk file and list it's content using fdisk. For example:
  2. 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 #
  3. 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.
  4. Use the mount command with loopback and offset options to mount the virtual-disk partition, for example:
  5. 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.

Environment:

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


Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (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.




User Comments

© 2012 Novell