This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [xen-users] guest can't bootup when converting a physical machine to

To: Zhang Li <cindy.zhangli@xxxxxxxxx>
Subject: Re: [xen-users] guest can't bootup when converting a physical machine to an image
From: "Fajar A. Nugraha" <fajar@xxxxxxxxx>
Date: Sat, 26 Sep 2009 09:40:34 +0700
Cc: Xen User-List <xen-users@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 25 Sep 2009 19:41:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <790b14c90909250259u6a567d49u8c0e471df399c168@xxxxxxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
References: <790b14c90909250259u6a567d49u8c0e471df399c168@xxxxxxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, Sep 25, 2009 at 4:59 PM, Zhang Li <cindy.zhangli@xxxxxxxxx> wrote:
> Hi, all
> I am trying to convert an linux machine to an image. I use the
> following way to convert it:
> 1. resize2fs /dev/sda3 4G
> 2. dd if=/dev/sda3 of=./rhel_hvm.img  bs=512 count=8M
> 3. The image file has no MBR, then I add the mbr and partition.
>    I use `parted rhel_hvm.img` command,
>    1) mklabel msdos
>    2) mkpart primary ext3 0kB 4G (only one partition)
>   the mbr and the partition is created.
> But the problem is that kernel can't be loaded when grub is running.

I'm surprised you even got it to work. The "normal" way to do this:
- create a partition table first.
- dd to that partition, or create file system and copy the data. You
can use kpartx to mount partition inside an image.

When you create a partition you reserve the beginning of the disk (or
the image), usually 1 track worth (63 sectors on most modern disk or
images). You did the opposite, dd a partition to an image (not a
partition on that image) then create a partition table on it. My guess
is you pretty much destroy the file system information. Did you try
mounting the image afterwards?

> Then I boot the guest with another centos image,
> and rhel_hvm.img is used as slave disk  /dev/hdb.
> Then I use `grub-install /dev/hdb`, to reinstall the grub, and it is
> successfull.
> Then I boot the guest with rhel_hvm.img, but it still fails. Grub is
> stop with the line
> "Booting froom Hard Disk".
> Any ideas?

grub-install is somewhat tricky. What you did is install grub on MBR
of the SECOND disk that will load data from your FIRST disk (centos).
Generally not what you want.

Assuming your disk image is correct (i.e. it has the correct partition
table, correct file system, etc.), when installing grub to a second
disk (like when using external USB drive) I had to edit two files
first on current environment (the centos image in your setup):
- /boot/grub/device.map, pointing (hd0) to the new disk (sdb or hdb)
- /etc/mtab, changing partition of "/" (or "/boot") to the new disk
(e.g. from /dev/sda1 to /dev/sdb1)

Then do a grub-install /dev/sdb (or hdb) and it should work. Change
back the files afterwards.

I believe there's a better method to do this (using grub shell and
"setup" command), but if you want to use grub-install then you need
the hack above.


Xen-users mailing list

<Prev in Thread] Current Thread [Next in Thread>