Convert virtualbox virtual disk to available xen format

Source: Internet
Author: User

To solve this problem, use "Convert virtualbox to xen" to search for two articles:

Http://www.ioncannon.net/system-administration/80/how-to-transfer-linux-from-virtualbox-to-xen/

Method:
Vboxmanage internalcommands converttoraw mysimage. VDI/tmp/mysimage. img

Http://forums.virtualbox.org/viewtopic.php? F = 1 & t = 18560

Method:
Vboxmanage clonehd XYZ. vdi xyz. Raw -- format raw

Restart to a normal kernel (where a VirtualBox-3.12 is installed) and perform the following operations:
[WHB @ jcwkyl VM] $ vboxmanage clonehd/Vm/vm1.vdi/Vm/vm1_clone.img -- format raw
Virtualbox command line management interface version 3.0.12
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

0%... 10%... 20%... 30%... 40%... 50%... 60%... 70%... 80%... 90%... 100%
Clone hard disk created in format 'Raw'. UUID: cb782a52-0759-4450-8ea2-e584f35fc76e

[WHB @ jcwkyl VM] $ vboxmanage internalcommands converttoraw/Vm/vm1.vdi/Vm/vm1_convert.img
Virtualbox command line management interface version 3.0.12
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Converting image "/Vm/vm1.vdi" with size 8589934592 bytes (8192 MB) to raw...

Then uninstall virtualbox (for fear that it conflicts with the xen kernel) and restart it to the xen kernel. After verification, there is no problem with the above two methods. The only problem is that the generated file is too large, in the past, vm1.vdi was only 987 m, but the vm‑clone.img and vm‑convert.img generated by the above two methods were both 8.1G!

Attach your xen virtual machine configuration file:
#-*-Mode: Python ;-*-

#===================================================== ============================================

# Python configuration setup for 'xm create '.

# This script sets the parameters used when a domain is created using 'xm create '.

# You use a separate script for each domain you want to create, or

# You can set the parameters for the domain on the XM command line.

#===================================================== ============================================

 
Import OS, re

Arch = OS. uname () [4]

If Re. Search ('64', arch ):

Arch_libdir = 'lib64'

Else:

Arch_libdir = 'lib'

 
#----------------------------------------------------------------------------

# Kernel image file.

Kernel = "/usr/lib/xen/boot/hvmloader"

 
# The domain build function. hvm domain uses 'hvm '.

Builder = 'hvm'

 
# Initial memory allocation (in megabytes) for the new domain.

#

# Warning: creating a domain with insufficient memory may cause out

# Memory errors. The domain needs enough memory to boot Kernel

# And modules. allocating less than 32mbs is not recommended.

Memory = 256

 
# Shadow pagetable memory for the domain, in MB.

# Shoshould be at least 2kb per MB of domain memory, plus a few MB per vcpu.

Shadow_memory = 8

 
# A name for your domain. All domains must have different names.

Name = "VM1"

 
#128-bit UUID for the domain. The default behavior is to generate a new UUID

# On each call to 'xm create '.

# UUID = "06ed00fe-4152-4fc4-b5d8-11993ee4a8b9"

 
#-----------------------------------------------------------------------------

# The number of CPUs guest platform has, default = 1

# Vcpus = 1

 
# Enable/disable hvm guest PAE, default = 0 (disabled)

# PAE = 0

 
# Enable/disable hvm guest ACPI, default = 0 (disabled)

# ACPI = 0

 
# Enable/disable hvm guest APIC, default = 0 (disabled)

# APIC = 0

 
# List of which CPUs this domain is allowed to use, default xen picks

# CPUs = "" # Leave to xen to pick

# CPUs = "0" # All vcpus run on cpu0

# CPUs = "0-, ^ 1" # Run on CPUs

 
# Optionally define Mac and/or bridge for the network interfaces.

# Random Macs are assigned if not given.

# VIF = ['Type = ioemu, MAC = 00: 16: 3E: 00: 00: 11, bridge = xenbr0, model = ne2k_pci ']

# Type = ioemu specify the NIC is an ioemu device not netfront

VIF = ['Type = ioemu, bridge = xenbr0']

 
#----------------------------------------------------------------------------

# Define the disk devices you want the domain to have access to, and

# What you want them accessible.

# Each disk entry is of the form PHY: uname, Dev, Mode

# Where uname is the device, Dev is the device name the domain will see,

# And mode is R for read-only, W for read-write.

 
# Disk = ['phy: hda1, hda1, R']

# Disk = ['file:/var/images/min-el3-i386.img, hda, W', ', HDC: CDROM, R']

Disk = ['file:/Vm/vmbench convert.img, ioemu: hda, W', 'phy:/dev/CDROM, HDC: CDROM, R']

 
#----------------------------------------------------------------------------

# Configure the behaviour when a domain exits. There are three 'reasons'

# For a domain to stop: poweroff, reboot, and crash. For each of these you

# May specify:

#

# "Destroy", meaning that the domain is cleaned up as normal;

# "Restart", meaning that a new domain is started in place of the old

# One;

# "Preserve", meaning that no clean-up is done until the domain is

# Manually destroyed (using XM destroy, for example); or

# "RENAME-Restart", meaning that the old domain is not cleaned up, but is

# Renamed and a new domain started in its place.

#

# The default is

#

# On_poweroff = 'deststroy'

# On_reboot = 'restart'

# On_crash = 'restart'

#

# For backwards compatibility we also support the deprecated option restart

#

# Restart = 'onreboot' means on_poweroff = 'deststroy'

# On_reboot = 'restart'

# On_crash = 'deststroy'

#

# Restart = 'Gateway' means on_poweroff = 'restart'

# On_reboot = 'restart'

# On_crash = 'restart'

#

# Restart = 'never 'means on_poweroff = 'deststroy'

# On_reboot = 'deststroy'

# On_crash = 'deststroy'

 
# On_poweroff = 'deststroy'

# On_reboot = 'restart'

# On_crash = 'restart'

On_poweroff = 'deststroy'

On_reboot = 'deststroy'

On_crash = 'deststroy'

#===================================================== ============================================

 
# New stuff

Device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

 
#-----------------------------------------------------------------------------

# Boot on floppy (A), hard disk (C) or CD-ROM (d)

# Default: hard disk, CD-Rom, floppy

# Boot = "CDA"

Boot = 'C'

 
#-----------------------------------------------------------------------------

# Write to temporary files instead of disk image files

# Snapshot = 1

 
#----------------------------------------------------------------------------

# Enable SDL library for graphics, default = 0

SDL = 1

 
#----------------------------------------------------------------------------

# Enable VNC library for graphics, default = 1

VNC = 0

 
#----------------------------------------------------------------------------

# Address that shoshould be listened on for the VNC Server If VNC is set.

# Default is to use 'vnc-Listen' setting from/etc/xen/xend-config.sxp

# Vnclisten = "127.0.0.1"

 
#----------------------------------------------------------------------------

# Set VNC display number, default = domid

# Vncdisplay = 1

 
#----------------------------------------------------------------------------

# Try to find an unused port for the VNC Server, default = 1

# Vncunused = 1

 
#----------------------------------------------------------------------------

# Enable spawning vncviewer for domain's console

# (Only valid when VNC = 1), default = 0

# Vncconsole = 0

 
#----------------------------------------------------------------------------

# Set password for domain's VNC Console

# Default is depents on vncpasswd in xend-config.sxp

Vncpasswd =''

 
#----------------------------------------------------------------------------

# No graphics, use serial port

# Nographic = 0

 
#----------------------------------------------------------------------------

# Enable stdvga, default = 0 (use Cirrus Logic Device Model)

Stdvga = 0

 
#-----------------------------------------------------------------------------

# Serial Port re-direct to Pty deivce,/dev/pts/n

# Then XM console or minicom can connect

Serial = 'PTY'

 
 
#-----------------------------------------------------------------------------

# Enable sound card support, [sb16 | es1370 | all |...,...], default none

# Soundhw = 'sb16'

 
 
#-----------------------------------------------------------------------------

# Set the real time clock to local time [default = 0 I. e. Set to UTC]

# Localtime = 1

 
 
#-----------------------------------------------------------------------------

# Start in full screen

# Full-screen = 1

 
 
#-----------------------------------------------------------------------------

# Enable USB support (specific devices specified at runtime through

# Monitor window)

# USB = 1

 
# Enable USB mouse support (only enable one of the following, 'mouse'

# Ps/2 Protocol Relative mouse, 'tablet'

# Absolute mouse)

# Usbdevice = 'mouse'

# Usbdevice = 'tablet'

 
#-----------------------------------------------------------------------------

# Set keyboard layout, default is en-US keyboard.

# Keymap = 'ja'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.