Xen creation of PVM and hvm

Source: Internet
Author: User

These are the basic steps of installing domu with xen-tools in ubuntu13.04 64bit in xen4.3

You can also use virt-manager which has an UI, but there may be some bugs between xen and virt-manager.

 

Install a bridge:

Before xen4.1, xen will automatically create xenbr0.in xen4.3, things are different, we need to create xenbr0 by hands.

The steps are for the situation where your computer is using DHCP. For static IP setting, the bridge may not crrect.

First, install a tool named brctl:

Sudo apt-Get install bridge-utils

Sudo brctl (this will show the help info. Then you can see how to use commands like 'addbr' or 'addif ')

Sudo brctl show (this is to see your current status)

Then change file "ETC/Network/interfaces" to this:

auto loiface lo inet loopbackauto xenbr0iface xenbr0 inet dhcp   bridge_ports eth0auto eth0iface eth0 inet manual

Then turn xenbr0 up:

Sudo IFUP xenbr0

Then in ifconfig you shoshould see the status of xenbr0 is "up"

Sudo ifconfig xenbr0

OK, reboot to get things work

 

Install PV domu:

Sudo apt-Get install xen-Tools

Sudo xen-create-image -- hostname = yourhostname -- Dist = lucid -- dir =/home/zmj/xenfile (change it to your own) -- mirror = http://cn.archive.ubuntu.com/ubuntu -- Role = udev -- verbose -- pygrub -- DHCP -- passwd

PS: the hostname is the VM's name

This xen-create-image command will automatically create *. CFG fill in/etc/xen/and create "domains/yourhostname/disk. IMG and swap. IMG "under your Dir (in this example"/home/zmj/xenfile ")

If these files, I. e. "domains/yourhostname/disk. IMG and swap. IMG "already exist in your Dir, then the command will fail. you have three choices: 1.use -- force in the command to rewrite the files 2. delete the files by hands 3. change your hostname to something else

The "yourhostname" are suggested to be short, better within 10 chars. There is a case that we cannot get things done until we give a short name to the -- hostname.

This command will take a relative long time because it needs to download something via HTTP.

With *. cfg file you can create Vm with 'xm create '. of course you can write *. CFG by yourself as long as the settings in your *. cfg file are correct, which wocould be much more difficult.

By the way, in/etc/xen there are some example. cfg which you can refer.

You can find your IMG file at the -- Dir you specified at the command, I. e./home/zmj/xenfile. You can mount this IMG to see what is inside :)

The -- passwd option is important. With this, it will ask you for the pasword of your domu at the end of this command's running. Otherwise, you'll not be able to loginUnless you mount the whole domu IMG and edit/etc/shadow file. or you can set passwd = 1 in/etc/xen-tools/xen-tools.conf, which makes the command always asking a password.

You can use -- LVM instead of -- dir. More info, plz refer to http://manpages.ubuntu.com/manpages/precise/man8/xen-create-image.8.html

Sudo XL create/etc/xen/yourhostname. cfg (PLZ teach yourself if dont know how to use XL)

It will throw an error if Bridge xenbr0 is missing. Or you can modify the. cfg file.

Do this command you may see this

[email protected]:Æ sud0 xl create /etc/xen/ubuntu.cfg  xend is runnlng, wh1ch may cause unpredlctable results when us1ng th1s xl command.  Please shut down xend before cont1nu1ng. 

At this time, you can do this command:

Sudo service xend stop

PS: xend is not required for the current command XL. xend is required for the previous XM.

Sudo XL list

You shall see your domu after this command.

Sudo XL console yourhostname

Use this command to go inside the domu with username = root and Password = yourpasswd

Press "Ctrl +]" will get you out of the VM console.

 

Install hvm domu:

The installation of hvm is much easier than that of a PV.

Put a *. ISO file at some directory which is the OS you are going to build, for example win7.iso

Use this command to create an empty *. IMG file, which will act like the hard disk Of Your VM.

Dd If =/dev/Zero of = xxx. img bs = 1024 K seek = 6144 COUNT = 0

Write a *. cfg file like this:

kernel = "/usr/local/lib/xen/boot/hvmloader"builder=‘hvm‘memory = 2048vcpus=4shadow_memory = 64name = "u8s"vif = [ ‘mac=00:16:3E:63:34:21, bridge=xenbr0‘ ]disk = [ ‘file:/home/zmj/img/ubuntu8s.img,hda,w‘, ‘file:/home/zmj/iso/ubuntu8s.iso,hdc:cdrom,r‘ ]boot="dc"vnc = 1sdl = 0vncconsole=1xen_platform_pci=0acpi = 1apic = 1device_model = ‘/usr/local/lib/xen/bin/qemu-dm‘ stdvga=0 serial=‘pty‘ usbdevice=‘tablet‘

The *. IMG path and the *. ISO path shall be correct. The kelnel path and the device_model path shall be correct.

Use this command to start the installation

Sudo XL create *. cfg

After the installation, change "BC" to "C" in the *. cfg file. "BC" means boot from Cd, while "C" means boot from hard disk.

Run this command again and you'll find the VM running

Sudo XL create *. cfg

Use this command to see the VM list

Sudo XL list

Use this command to open the VM.

Sudo XL vncviewer domu

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.