<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.12.3">
</HEAD>
<BODY>
Run kpartx to create the devices - will be created in /dev/mapper<BR>
<BR>
kpartx -a /dev/loop0<BR>
<BR>
<BR>
On Tue, 2007-03-27 at 15:32 -0600, Lamont Peterson wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">All,</FONT>

<FONT COLOR="#000000">I need to create some images that pygrub can boot (on FC6 & RHEL5).  IIUC, </FONT>
<FONT COLOR="#000000">that means that the image file must be a disk image complete with partition </FONT>
<FONT COLOR="#000000">table.</FONT>

<FONT COLOR="#000000">The trouble I'm running into is figuring out how to access the "partition" </FONT>
<FONT COLOR="#000000">within the disk image file as a block device.  This is necessary in order to </FONT>
<FONT COLOR="#000000">format or mount the filesystems and run mkswap for the disk image's swap </FONT>
<FONT COLOR="#000000">partition.</FONT>

<FONT COLOR="#000000">Here's what I have so far.</FONT>

<FONT COLOR="#000000">1.  Create the disk image file, ala "dd if=/dev/zero </FONT>
<FONT COLOR="#000000">of=/var/lib/xen/images/someVM/sda bs=1k seek=4608k count=1"</FONT>

<FONT COLOR="#000000">2.  Create partitions with fdisk (this requires setting the number of </FONT>
<FONT COLOR="#000000">cylinders, but that's easy).</FONT>

<FONT COLOR="#000000">3.  losetup /dev/loop0 /var/lib/xen/images/someVM/sda</FONT>

<FONT COLOR="#000000">At this point, I can run "fdisk -l /dev/loop0" and get:</FONT>

<FONT COLOR="#000000">Disk /dev/loop0: 4831 MB, 4831839232 bytes</FONT>
<FONT COLOR="#000000">255 heads, 63 sectors/track, 587 cylinders</FONT>
<FONT COLOR="#000000">Units = cylinders of 16065 * 512 = 8225280 bytes</FONT>

<FONT COLOR="#000000">      Device Boot      Start         End      Blocks   Id  System</FONT>
<FONT COLOR="#000000">/dev/loop0p1               1         523     4200966   83  Linux</FONT>
<FONT COLOR="#000000">/dev/loop0p2             524         588      522112+  82  Linux swap / </FONT>
<FONT COLOR="#000000">Solaris</FONT>

<FONT COLOR="#000000">However, there is no /dev/loop0p1 or /dev/loop0p2 devices and I'm not sure </FONT>
<FONT COLOR="#000000">what to do to make those accessible.  I need to be able </FONT>
<FONT COLOR="#000000">to "mke2fs -j /dev/loop0p1" and "mkswap /dev/loop0p2" or equivalent.  Then I </FONT>
<FONT COLOR="#000000">need to mount /dev/loop0p1 to copy files to it.</FONT>

<FONT COLOR="#000000">How can I access partitions inside a disk image as block devices?  Should I be </FONT>
<FONT COLOR="#000000">using something other than losetup here?</FONT>
<FONT COLOR="#000000">--</FONT>
<FONT COLOR="#000000">Fedora-xen mailing list</FONT>
<FONT COLOR="#000000"><A HREF="mailto:Fedora-xen@redhat.com">Fedora-xen@redhat.com</A></FONT>
<FONT COLOR="#000000"><A HREF="https://www.redhat.com/mailman/listinfo/fedora-xen">https://www.redhat.com/mailman/listinfo/fedora-xen</A></FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>