[CentOS-virt] Migrating from KVM to XEN - kernel panic

Pasi Kärkkäinen pasik at iki.fi
Tue Nov 10 08:20:35 UTC 2009

On Mon, Nov 09, 2009 at 10:55:48AM -0800, Christopher Hunt wrote:
>    Pasi,
>         Thanks very much for the tip.  That did give me some additional
>    information:
>    Scanning and configuring dmraid supported devices
>    Scanning logical volumes
>      Reading all physical volumes.  This may take a while...
>    Activating logical volumes
>      Volume group "virt01vg00" not found
>    Creating root device.
>    Mounting root filesystem.
>    mount: could not find filesystem '/dev/root'
>    Setting up other filesystems.
>    Setting up new root fs
>    setuproot: moving /dev failed: No such file or directory
>    no fstab.sys, mounting internal defaults
>    setuproot: error mounting /proc: No such file or directory
>    setuproot: error mounting /sys: No such file or directory
>    Switching to new root and running init.
>    unmounting old /dev
>    unmounting old /proc
>    unmounting old /sys
>    switchroot: mount failed: No such file or directory
>    Kernel panic - not syncing: Attempted to kill init!
>    This brings me back to suspecting the problem is in the different file
>    structures.  I'm still trying to wrap my head around the other replies in
>    this thread.

Uhmm.. yeah. Sounds like the initrd image is wrong (not correct when
running as Xen PV guest so it's not setting up the root device properly).

I recommend take a full backup of the KVM guest disk image, and then continue
with these steps.

The easiest way should be, when still running under KVM, to do this in
the guest:

- backup /etc/modprobe.conf: cp -a /etc/modprobe.conf /etc/modprobe.conf.backup.kvm
- edit /etc/modprobe.conf and remove scsi_hostadapter and eth0 lines
- add these lines:
alias eth0 xennet
alias scsi_hostadapter xenblk

Those changes will make mkinitrd include the correct drivers to initrd

Now let's continue in the guest:

- backup /etc/fstab: cp -a /etc/fstab /etc/fstab.backup.kvm
- edit /etc/fstab
- rename /dev/sd* to /dev/xvd* (sda1 becomes xvda1)

Xen paravirtual guest disks will be called /dev/xvd*

Now, install kernel-xen: yum install kernel-xen

After installation check /boot/grub/grub.conf and verify that 
kernel-xen is the default entry. Also verify the root path kernel
parameter is correct. Also check the initrd filename for
kernel-xen, since we'll re-create the initrd image.

Then create a backup of the kernel-xen initrd image:
cp -a /boot/initrd-2.6.18-version.img /boot/initrd-2.6.18-version-backup.img

Then re-create the kernel-xen initrd image, so we can verify it looks correct 
for a Xen guest:

mkinitrd -v -f /boot/initrd-2.6.18-version.img 2.6.18-version

>From the mkinitrd output verify that it includes xenblk and xennet
drivers (as specified in /etc/modprobe.conf).

After this shutdown the KVM guest, copy the disk image to Xen host,
create a Xen configuration file for the guest, and make it use pygrub
bootloader to load grub settings, kernel and initrd from the guest disk. 
and try starting it.. 

(if it still fails, I recommend unpacking the initrd image [1], and
reading the init script to see where it goes wrong).

Good luck :)

-- Pasi

[1] mkdir /tmp/foo && cd /tmp/foo && zcat /boot/initrd-foo.img | cpio -i -d 

>    On Sat, Nov 7, 2009 at 2:24 PM, Pasi Kärkkäinen <[1]pasik at iki.fi> wrote:
>      On Fri, Nov 06, 2009 at 11:49:41AM -0800, Christopher Hunt wrote:
>      >    First let me say that I'm not a sysadmin, but am simply wearing
>      that hat
>      >    this week so please excuse my ignorance.  I need to temporarily
>      move some
>      >    virtual servers from a CentOS-KVM platform to a CentOS-XEN platform
>      while
>      >    I do some upgrades to the CentOS box.  I've created a local LV, and
>      used
>      >    DD and SCP to transfer the block device from the VKM machine to the
>      XEN
>      >    machine.  For quite a while I struggled with the "Error: (2,
>      'Invalid
>      >    kernel', 'xc_dom_parse_elf_kernel: ELF image has no shstrtab\n')"
>      error
>      >    but thanks to Nick Couchman from
>      >
>       [1][2]http://lists.xensource.com/archives/html/xen-users/2008-03/msg00603.html,
>      >    I've passed that.  Now I'm stuck with a kernel panic situation.
>      >    Unfortunately the kernel panic error doesn't appear using "xm
>      console" and
>      >    flashes so quickly through "virt-viewer" that I can't get any
>      details.
>      >
>      Stop the guest and edit /etc/xen/<guest> cfgfile.
>      Remove (or comment out) the vfb line, and then restart the guest.
>      Now you get the full console output to "xm console".
>      -- Pasi
>      _______________________________________________
>      CentOS-virt mailing list
>      [3]CentOS-virt at centos.org
>      [4]http://lists.centos.org/mailman/listinfo/centos-virt
> References
>    Visible links
>    1. mailto:pasik at iki.fi
>    2. http://lists.xensource.com/archives/html/xen-users/2008-03/msg00603.html
>    3. mailto:CentOS-virt at centos.org
>    4. http://lists.centos.org/mailman/listinfo/centos-virt

> _______________________________________________
> CentOS-virt mailing list
> CentOS-virt at centos.org
> http://lists.centos.org/mailman/listinfo/centos-virt

More information about the CentOS-virt mailing list