Convert KVM images to Virtual Box (VDI)

The steps to convert KVM images to VirtualBox’s VDI format, ensuring cross-platform compatibility and a smoother transition.

VirtualBox’s VDI (Virtual Disk Image) format comes with several advantages, making it a flexible choice for virtualization:

  1. Cross-Platform Compatibility: VDI images can run on Linux, macOS, or Windows, making them versatile and accessible.
  2. No Need for Virtualization-Enabled Processors: VirtualBox VDI images work even on machines without virtualization-enabled processors, ensuring broader compatibility.
  3. 32-Bit Machine Support: VDI images can be used on both 32-bit and 64-bit machines, providing compatibility across various hardware configurations.

Steps to Create a VirtualBox-Compatible Image

To convert a KVM image to a VirtualBox VDI image, follow these steps:

Step 1: Convert the Image Format

Start from your KVM-installed server and use the qemu-img tool to convert the KVM image (kvm-os.img) to a raw format (kvm-os-raw.img):

$ qemu-img convert kvm-os.img -O raw kvm-os-raw.img

Step 2: Copy the Image

Copy the raw image (kvm-os-raw.img) to your VirtualBox machine.

Step 3: Use VBoxManage to Convert

On your VirtualBox machine, use the VBoxManage tool to convert the raw image to a VDI format (vbox.vdi):

$ VBoxManage convertfromraw --format VDI kvm-os-raw.img vbox.vdi

This command will create a VirtualBox-compatible image. If needed, you can further optimize the image size with the following command:

$ VBoxManage modifyvdi /home/user/vbox.vdi compact

Ensure that you provide the absolute path to the VDI image.

Step 4: Create a Virtual Machine

With your VDI image ready, you can now create a new virtual machine in VirtualBox. Use the VDI image as the storage, boot the machine, and hope for a successful boot.

Fixing Kernel Panic and File System Not Found Issues

In some cases, even after creating a VDI image, you may encounter issues like a kernel panic or a file system not found error. To address this, follow these steps:

For Red Hat-based Systems:

Boot the virtual machine in rescue mode using a Red Hat installation CD:

> linux rescue

After booting, use the following commands to chroot into your system:

# chroot /mnt/sysimage

Backup the existing initrd image:

# cp /boot/initrd-2.6.xxx.img initrd-2.6-old

Create a new initrd image:

# mkinitrd -v /boot/initrd-new.img kernel-version

For example:

# mkinitrd -v /boot/initrd-new.img 2.6.18-194.8.1.el5

Edit the GRUB configuration and replace the initrd image name with the new one:

# cat /boot/grub/menu.lst

Reboot the machine and see if it boots successfully.

Â


Posted

in

,

by

Tags:

Comments

6 responses to “Convert KVM images to Virtual Box (VDI)”

  1. Fouad Avatar
    Fouad

    Thanks it worked
    I wanted to migrate to VBOX because KVM doesn’t support bridging with network manager enabled on Fedora and I use network manager on my laptop so I moved to VBOX and it worked perfectly with bridging mode and network manager enabled, Iam not sure why KVM make it harder some times.

    1. Arun N S Avatar

      KVM usually works with bridge interface, hope at some point network manager supports bridging, other wise just forget about the network manager and do the manual configuration 🙂

  2. […] (ohne GUI). ja laut suche soll das funktionieren siehe: http://www.jessieamorris.com/node/67 http://arunnsblog.com/2010/07/20/con…rtual-box-vdi/ http://www.krisbuytaert.be/blog/conv…kvm-virtualbox also ein schoenes kleines Linux ohne GUI […]

  3. Jonathan Price Avatar
    Jonathan Price

    Thanks Arun, I had the same issue and the same solution (mkinitrd), when migrating an Oracle VM OL5u8 PVM to VBox.

  4. Guest Avatar
    Guest

    Find 1 error 😉

    BAD COMMAND STRING:
    $ VBoxManage convertfromrow –format VDI kvm-os-raw.img vbox.vdi

    RIGHT COMMAND
    $ VBoxManage convertfromraw –format VDI kvm-os-raw.img vbox.vdi

    1. Arun N S Avatar

      Thanks Luca, I will update the blog.

Leave a Reply

Your email address will not be published. Required fields are marked *