Home Page

Contact Me

MAC OS X

Linux

Linux Servers Fedora Core 4

Linux Servers - CentOS

Linux Servers Fedora Core 5

Linux Servers Fedora Core 7

Linux Servers Fedora 8

OpenWRT

NSLU2

LinuxCluster

Hardware Hacking Projects

Speaker Building Projects

Electronics Projects

Other Sites





Linux /

Status/History

  • NOT DONE

Introduction

I've been recently working with Xen 3.0 and Fedora Core 5 and disk images have become a part of linux life. Now I'm not talking about an image file that is a single partition. I'm talking about a disk image that represents a hard drive with an MBR and multiple partition in it.

Mounting a Xen 3.0 Disk Image

We need to start by mounting the image file to a loop back device.
>iosetup /dev/loop0 /xen/yourimage.img
Replace /xen/yourimage.img with the path to your image file. Now lets use fdisk to see the partions on the disk image.
> fdisk -ul /dev/loop0
Fdisk showed that my image file had 2 partitions. One was a linux partition and the other was a linux lvm partition. Let's mount the linux partition.
> mkdir /mnt/diskimg_p1
> lomount -diskimage /dev/loop0 -partition 1 /mnt/diskimg_p1
This partition turned out to be /boot. You can unmount it just as easy.
> umount /mnt/diskimg_p1
Now unmount the disk image
> losetup -d /dev/loop0

Here's another way to mount the partitions. We will use losetup with offsets. So start with the following:
> losetup /dev/loop0 /xen/yourimage.img > fdisk -ul /dev/loop0
Which gives:

 
Disk /dev/loop0: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders, total 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1   *          63      208844      104391   83  Linux
/dev/loop0p2          208845     8385929     4088542+  8e  Linux

Now the important part is the start blocks. Your start blocks will look differently. My starts are 63 and 208845. The sector size if 512. So do 63*512 and 208845*512. That will give you the offset numbers to use in loset. For my setup I do the following.
> losetup -o 32256 /dev/loop1 /dev/loop0
> losetup -o 106928640 /dev/loop2 /dev/loop0
> mkdir /mnt/p1
> mkdir /mnt/p2
> mount /dev/loop1 /mnt/p1
> mount /dev/loop2 /mnt/p2
Nou you have the partitions mounted.

Now lets unmount and cleanup.
> umount /mnt/p1
> umount /mnt/p2
> rmdir /mnt/p1
> rmdir /mnt/p2
> losetup -d /dev/loop1
> losetup -d /dev/loop2
> losetup -d /dev/loop0


Google
 
Theme by Richard Camp
(C) Copyright 1996-2007 by Richard Camp All rights reserved