All, I need to create some images that pygrub can boot (on FC6 & RHEL5). IIUC, that means that the image file must be a disk image complete with partition table. The trouble I''m running into is figuring out how to access the "partition" within the disk image file as a block device. This is necessary in order to format or mount the filesystems and run mkswap for the disk image''s swap partition. Here''s what I have so far. 1. Create the disk image file, ala "dd if=/dev/zero of=/var/lib/xen/images/someVM/sda bs=1k seek=4608k count=1" 2. Create partitions with fdisk (this requires setting the number of cylinders, but that''s easy). 3. losetup /dev/loop0 /var/lib/xen/images/someVM/sda At this point, I can run "fdisk -l /dev/loop0" and get: Disk /dev/loop0: 4831 MB, 4831839232 bytes 255 heads, 63 sectors/track, 587 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/loop0p1 1 523 4200966 83 Linux /dev/loop0p2 524 588 522112+ 82 Linux swap / Solaris However, there is no /dev/loop0p1 or /dev/loop0p2 devices and I''m not sure what to do to make those accessible. I need to be able to "mke2fs -j /dev/loop0p1" and "mkswap /dev/loop0p2" or equivalent. Then I need to mount /dev/loop0p1 to copy files to it. How can I access partitions inside a disk image as block devices? Should I be using something other than losetup here? -- Lamont Peterson <lamont@gurulabs.com> Senior Instructor Guru Labs, L.C. [ http://www.GuruLabs.com/ ] NOTE: All messages from this email address should be digitally signed with my 0xDC0DD409 GPG key. It is available on the pgp.mit.edu keyserver as well as other keyservers that sync with MIT''s.
On Tue, Mar 27, 2007 at 03:32:30PM -0600, Lamont Peterson wrote:> Device Boot Start End Blocks Id System > /dev/loop0p1 1 523 4200966 83 Linux > /dev/loop0p2 524 588 522112+ 82 Linux swap / > Solaris > > However, there is no /dev/loop0p1 or /dev/loop0p2 devices and I''m not sure > what to do to make those accessible. I need to be able > to "mke2fs -j /dev/loop0p1" and "mkswap /dev/loop0p2" or equivalent. Then I > need to mount /dev/loop0p1 to copy files to it. > > How can I access partitions inside a disk image as block devices? Should I be > using something other than losetup here?man losetup man mount ... option "offset" or you can try lomount (from the Xen package) that supports partitions more friendly. For more information (especially when you want to use LVM), see: http://fedoraproject.org/wiki/FedoraXenQuickstartFC6?highlight=%28Xen%29#head-9c5408e750e8184aece3efe822be0ef6dd1871cd Karel -- Karel Zak <kzak@redhat.com>
Run kpartx to create the devices - will be created in /dev/mapper kpartx -a /dev/loop0 On Tue, 2007-03-27 at 15:32 -0600, Lamont Peterson wrote:> All, > > I need to create some images that pygrub can boot (on FC6 & RHEL5). IIUC, > that means that the image file must be a disk image complete with partition > table. > > The trouble I''m running into is figuring out how to access the "partition" > within the disk image file as a block device. This is necessary in order to > format or mount the filesystems and run mkswap for the disk image''s swap > partition. > > Here''s what I have so far. > > 1. Create the disk image file, ala "dd if=/dev/zero > of=/var/lib/xen/images/someVM/sda bs=1k seek=4608k count=1" > > 2. Create partitions with fdisk (this requires setting the number of > cylinders, but that''s easy). > > 3. losetup /dev/loop0 /var/lib/xen/images/someVM/sda > > At this point, I can run "fdisk -l /dev/loop0" and get: > > Disk /dev/loop0: 4831 MB, 4831839232 bytes > 255 heads, 63 sectors/track, 587 cylinders > Units = cylinders of 16065 * 512 = 8225280 bytes > > Device Boot Start End Blocks Id System > /dev/loop0p1 1 523 4200966 83 Linux > /dev/loop0p2 524 588 522112+ 82 Linux swap / > Solaris > > However, there is no /dev/loop0p1 or /dev/loop0p2 devices and I''m not sure > what to do to make those accessible. I need to be able > to "mke2fs -j /dev/loop0p1" and "mkswap /dev/loop0p2" or equivalent. Then I > need to mount /dev/loop0p1 to copy files to it. > > How can I access partitions inside a disk image as block devices? Should I be > using something other than losetup here? > -- > Fedora-xen mailing list > Fedora-xen@redhat.com > https://www.redhat.com/mailman/listinfo/fedora-xen
On Tuesday 27 March 2007 03:42pm, Karel Zak wrote: [snip]> > How can I access partitions inside a disk image as block devices? Should > > I be using something other than losetup here? > > man losetup > man mount > > ... option "offset"Yeah, the moment I sent the original post, I realized I could try using offsets with losetup. Unfortunately, it''s not quite working. I think the problem is that the -s switch won''t work with the RHEL5 or FC6 loopback drivers and without it, running: # losetup -o512 /dev/loop1 /some/image/file ... is creating /dev/loop1 to span from the beginning of partition 1 to the end of the image file, which includes the space for partitions 2 and up. The -s switch needs to be used here to make this loopback device the right size. The note, "This option may not be supported on some older kernels and/or loop drivers," appears in the losetup(8) man page with the -s information. I don''t think these would be considered "older kernels" but the losetup command is not able to work when I try to use -s.> or you can try lomount (from the Xen package) that supports > partitions more friendly. For more information (especially when you > want to use LVM), see:That''s good to know about. Of course, that will only work once there is a filesystem on the partition inside the image file. I still have the problem of being able to run mke2fs and format *just* the partition within the image.> > http://fedoraproject.org/wiki/FedoraXenQuickstartFC6?highlight=%28Xen%29#he >ad-9c5408e750e8184aece3efe822be0ef6dd1871cdThanks. -- Lamont Peterson <lamont@gurulabs.com> Senior Instructor Guru Labs, L.C. [ http://www.GuruLabs.com/ ] NOTE: All messages from this email address should be digitally signed with my 0xDC0DD409 GPG key. It is available on the pgp.mit.edu keyserver as well as other keyservers that sync with MIT''s.
On Tuesday 27 March 2007 03:58pm, Andrew Cathrow wrote:> Run kpartx to create the devices - will be created in /dev/mapperHmm. I''d run into something that mentioned the use of kpartx (I think is was in some openSUSE 10.2 Xen documentation), but looking at it''s man page, it didn''t look like the right tool to create the devices.> kpartx -a /dev/loop0So, I''m supposed to: 1. Create the image file. 2. Run "losetup /dev/loop0 /whatever/path/to/the/imagefile" 3. Run "fdisk /dev/loop0" to create the partitions. 4. Run "kpartx -a /dev/loop0" which will create /dev/mapper/* devices for the partitions on /dev/loop0. Have I got that right?> On Tue, 2007-03-27 at 15:32 -0600, Lamont Peterson wrote: > > All, > > > > I need to create some images that pygrub can boot (on FC6 & RHEL5). > > IIUC, that means that the image file must be a disk image complete with > > partition table. > > > > The trouble I''m running into is figuring out how to access the > > "partition" within the disk image file as a block device. This is > > necessary in order to format or mount the filesystems and run mkswap for > > the disk image''s swap partition. > > > > Here''s what I have so far. > > > > 1. Create the disk image file, ala "dd if=/dev/zero > > of=/var/lib/xen/images/someVM/sda bs=1k seek=4608k count=1" > > > > 2. Create partitions with fdisk (this requires setting the number of > > cylinders, but that''s easy). > > > > 3. losetup /dev/loop0 /var/lib/xen/images/someVM/sda > > > > At this point, I can run "fdisk -l /dev/loop0" and get: > > > > Disk /dev/loop0: 4831 MB, 4831839232 bytes > > 255 heads, 63 sectors/track, 587 cylinders > > Units = cylinders of 16065 * 512 = 8225280 bytes > > > > Device Boot Start End Blocks Id System > > /dev/loop0p1 1 523 4200966 83 Linux > > /dev/loop0p2 524 588 522112+ 82 Linux swap / > > Solaris > > > > However, there is no /dev/loop0p1 or /dev/loop0p2 devices and I''m not > > sure what to do to make those accessible. I need to be able > > to "mke2fs -j /dev/loop0p1" and "mkswap /dev/loop0p2" or equivalent. > > Then I need to mount /dev/loop0p1 to copy files to it. > > > > How can I access partitions inside a disk image as block devices? Should > > I be using something other than losetup here? > > -- > > Fedora-xen mailing list > > Fedora-xen@redhat.com > > https://www.redhat.com/mailman/listinfo/fedora-xen-- Lamont Peterson <lamont@gurulabs.com> Senior Instructor Guru Labs, L.C. [ http://www.GuruLabs.com/ ] NOTE: All messages from this email address should be digitally signed with my 0xDC0DD409 GPG key. It is available on the pgp.mit.edu keyserver as well as other keyservers that sync with MIT''s.
Yep, It''s referenced in the quickstart http://fedoraproject.org/wiki/FedoraXenQuickstartFC6 On Tue, 2007-03-27 at 17:27 -0600, Lamont Peterson wrote:> On Tuesday 27 March 2007 03:58pm, Andrew Cathrow wrote: > > Run kpartx to create the devices - will be created in /dev/mapper > > Hmm. I''d run into something that mentioned the use of kpartx (I think is was > in some openSUSE 10.2 Xen documentation), but looking at it''s man page, it > didn''t look like the right tool to create the devices. > > > kpartx -a /dev/loop0 > > So, I''m supposed to: > > 1. Create the image file. > 2. Run "losetup /dev/loop0 /whatever/path/to/the/imagefile" > 3. Run "fdisk /dev/loop0" to create the partitions. > 4. Run "kpartx -a /dev/loop0" which will create /dev/mapper/* devices for the > partitions on /dev/loop0. > > Have I got that right? > > > On Tue, 2007-03-27 at 15:32 -0600, Lamont Peterson wrote: > > > All, > > > > > > I need to create some images that pygrub can boot (on FC6 & RHEL5). > > > IIUC, that means that the image file must be a disk image complete with > > > partition table. > > > > > > The trouble I''m running into is figuring out how to access the > > > "partition" within the disk image file as a block device. This is > > > necessary in order to format or mount the filesystems and run mkswap for > > > the disk image''s swap partition. > > > > > > Here''s what I have so far. > > > > > > 1. Create the disk image file, ala "dd if=/dev/zero > > > of=/var/lib/xen/images/someVM/sda bs=1k seek=4608k count=1" > > > > > > 2. Create partitions with fdisk (this requires setting the number of > > > cylinders, but that''s easy). > > > > > > 3. losetup /dev/loop0 /var/lib/xen/images/someVM/sda > > > > > > At this point, I can run "fdisk -l /dev/loop0" and get: > > > > > > Disk /dev/loop0: 4831 MB, 4831839232 bytes > > > 255 heads, 63 sectors/track, 587 cylinders > > > Units = cylinders of 16065 * 512 = 8225280 bytes > > > > > > Device Boot Start End Blocks Id System > > > /dev/loop0p1 1 523 4200966 83 Linux > > > /dev/loop0p2 524 588 522112+ 82 Linux swap / > > > Solaris > > > > > > However, there is no /dev/loop0p1 or /dev/loop0p2 devices and I''m not > > > sure what to do to make those accessible. I need to be able > > > to "mke2fs -j /dev/loop0p1" and "mkswap /dev/loop0p2" or equivalent. > > > Then I need to mount /dev/loop0p1 to copy files to it. > > > > > > How can I access partitions inside a disk image as block devices? Should > > > I be using something other than losetup here? > > > -- > > > Fedora-xen mailing list > > > Fedora-xen@redhat.com > > > https://www.redhat.com/mailman/listinfo/fedora-xen > > -- > Fedora-xen mailing list > Fedora-xen@redhat.com > https://www.redhat.com/mailman/listinfo/fedora-xenAndrew Cathrow Red Hat, Inc. (678) 733 0452 - Mobile (404) 437 6178 - Home Office acathrow@redhat.com
On Tuesday 27 March 2007 06:52pm, Andrew Cathrow wrote:> Yep, > > It''s referenced in the quickstart > > http://fedoraproject.org/wiki/FedoraXenQuickstartFC6Doh, I read through that part and didn''t register the section that combined losetup & kpartx. At this point, the RHEL5 guests (I''m working on that distro first) won''t boot. Here''s what I''m getting: ----- Going to boot Red Hat Enterprise Linux Server (2.6.18-8.el5xen) kernel: /boot/vmlinuz-2.6.18-8.el5xen initrd: /boot/initrd-2.6.18-8.el5xen.img Started domain guru1 rtc: IRQ 8 is not free. rtc: IRQ 8 is not free. i8042.c: No controller found. Red Hat nash version 5.1.19.6 starting mount: could not find filesystem ''/dev/root'' setuproot: moving /dev failed: No such file or directory setuproot: error mounting /proc: No such file or directory setuproot: error mounting /sys: No such file or directory switchroot: mount failed: No such file or directory Kernel panic - not syncing: Attempted to kill init! ----- BTW, the GRUB config was edited to specify /dev/xvda1 as the root partition on the kernel command line. After modifying the initrd image in the guest to not load some drivers, to load the xenblk.ko driver, add the xenblk.ko driver and change the device ID in the resume mkrootdev command, I get this: ----- Going to boot Red Hat Enterprise Linux Server (2.6.18-8.el5xen) kernel: /boot/vmlinuz-2.6.18-8.el5xen initrd: /boot/initrd-2.6.18-8.el5xen.img Started domain guru1 rtc: IRQ 8 is not free. rtc: IRQ 8 is not free. i8042.c: No controller found. Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ----- Here is (part of) what the "init" nash script in the initrd looks like after my edits: ----- echo Setting up hotplug. hotplug echo Creating block device nodes. mkblkdevs echo "Loading uhci-hcd.ko module" insmod /lib/uhci-hcd.ko echo "Loading ohci-hcd.ko module" insmod /lib/ohci-hcd.ko echo "Loading ehci-hcd.ko module" insmod /lib/ehci-hcd.ko mount -t usbfs /proc/bus/usb /proc/bus/usb echo "Loading jbd.ko module" insmod /lib/jbd.ko echo "Loading ext3.ko module" insmod /lib/ext3.ko echo "Loading xenblk.ko module" insmod /lib/xenblk.ko mkblkdevs resume /dev/xvda2 echo Creating root device. mkrootdev -t ext3 -o defaults,ro xvda1 echo Mounting root filesystem. mount /sysroot echo Setting up other filesystems. setuproot ----- What do I need to do to create (or edit) a working initrd for the guest? -- Lamont Peterson <lamont@gurulabs.com> Senior Instructor Guru Labs, L.C. [ http://www.GuruLabs.com/ ] NOTE: All messages from this email address should be digitally signed with my 0xDC0DD409 GPG key. It is available on the pgp.mit.edu keyserver as well as other keyservers that sync with MIT''s.
Apologies for self replying. On Friday 30 March 2007 12:50pm, Lamont Peterson wrote: [snip]> ----- > Going to boot Red Hat Enterprise Linux Server (2.6.18-8.el5xen) > kernel: /boot/vmlinuz-2.6.18-8.el5xen > initrd: /boot/initrd-2.6.18-8.el5xen.img > Started domain guru1 > rtc: IRQ 8 is not free. > rtc: IRQ 8 is not free. > i8042.c: No controller found. > Kernel panic - not syncing: VFS: Unable to mount root fs on > unknown-block(0,0) > -----[snip] OK. With more research, I''ve identified that the disk device isn''t visible in the guest, and that''s what''s causing the error at boot time. Here''s the disk line from the guest config: disk = [ ''tap:aio:/var/lib/xen/images/machinename-xvda,xvda,w'' ] I was able to get virt-install to create a working guest after turning off SELinux. I''ll turn it back on later and try to find the policy problem, but it must be dontaudit''ed as I''m not seeing any audit messages for startup, though I do see one when it crashes and tries to write a fail log entry. Comparing the differences in the initrd image inside the working guest disk image and the one inside the images I''m creating, I''m not seeing any significant different. Both list the same drivers and the same parameters to things like the "mkrootdev" command. The list of files in the initrd image is identical except for a couple of extra drivers in lib/ on my image''s initrd (that are not being loaded). The xvda device is not showing up in the guests, so I get a kernel panic during boot. The same thing was happening trying to use virt-inatll/virt-manager, preventing those installations from working (couldn''t get past the partitioning screen without any disks). I''ve checked file permissions, SELinux contexts, etc. Everything looks good. The only obvious difference between my guest config and the one created by virt-install is that mine do not have uuid lines. Any ideas? -- Lamont Peterson <lamont@gurulabs.com> Senior Instructor Guru Labs, L.C. [ http://www.GuruLabs.com/ ] NOTE: All messages from this email address should be digitally signed with my 0xDC0DD409 GPG key. It is available on the pgp.mit.edu keyserver as well as other keyservers that sync with MIT''s.