Ubuntu uses xen-tools to install virtual machines (Ubuntu & CentOS)

Source: Internet
Author: User
In Ubuntu11.10, you can use apt-get to install xen-tools. The version is version 4.1: # apt-getinstall-yxen-tools because xen-tools is a semi-virtualization management tool of xen, therefore, you need to install the modified and semi-virtualized kernel. In ubuutu11.10, you only need to install the linux-image-3.0.0-1x-virtual's kernel through apt: # ap

In Ubuntu 11.10, you can use apt-get to install xen-tools. The version is 4.1:

# Apt-get install-y xen-tools

Because xen-tools is a semi-virtualization management tool of xen, you need to install the modified and semi-virtualized kernel. In ubuutu 11.10, you only need to install the linux-image-3.0.0-1x-virtual's kernel through apt:

# Apt-get install-y linux-image-3.0.0-12-virtual

After installation, the vmlinuz-3.0.0-12-virtual and initrd. img-3.0.0-13-virtual are found under/boot, which is the kernel to be used by the half-virtualized DomU.

Next, modify the xen-tools configuration file. The value in the configuration file only provides the default value when no option is specified during instance creation:

# Vi/etc/xen-tools/xen-tools.conf

You need to modify the following items:

[...]

Dir =/home/xen # location where the imgfile is stored

[...]

Lvm = vg0 # If you use the logical volume of lvm for storage, specify the volume group name.

[...]

# Specify the system version of the instance. xt-guess-suite-and-mirror -- suite returns the system version of the host.

Dist = 'xt-guess-suite-and-mirror -- core'

[...]

# Specify the CIDR Block of the Instance

Gateway = 192.168.0.1

Netmask = 255.255.255.0

Broadcast = 192.168.0.255

[...]

# Specify the kernel used by the instance. Here we use the previously installed semi-virtualized kernel.

Kernel =/boot/vmlinuz-3.0.0-12-virtual

Initrd =/boot/initrd. img-3.0.0-12-virtual

[...]

Serial_device = hvc0 # specify the console name. Use the default value.

Disk_device = xvda # specify the disk name of the instance. Use the default value.

[...]

# Specify the image source for the instance to be installed. xt-guess-suite-and-mirror -- mirror returns the image source of the host.

Mirrors = 'xt-guess-suite-and-mirror -- mirror'

[...]

After modifying the xen-tools.conf, you need to create the directory location where the imgfile is placed just now:

# Mkdir/home/xen

==================================== Create a ubuntu instance ==========

Xen-tools uses debootstrap to create ubuntu instances, which is used by default in the xen-tools.conf.

The latest ubuntu version supported by xen-tools is maverick by default, while oneiric is 11.10 (precise is currently 12.04). Therefore, we need to allow xen-tools to support the required version. Since all ubuntu versions are signed by karmic. d, we only need to create another symbolic connection:

# Cd/usr/lib/xen-tools/

# Ln-s karmic. d oneiric. d (for ubuntu 11.10)

Or

# Ln-s karmic. d presise. d (for ubuntu 12.04)

Then you can create an instance:

# Xen-create-image -- hostname = ubuntu.example.com -- size = 4G -- swap = 1G -- memory = 1G -- ip = 192.168.0.101 -- arch = amd64 -- role = udev

If you follow the xen-tools.conf you configured earlier, this command creates a virtual machine instance of the same version as the host system version.

Of course, you can also modify the system version, the installation source, or the disk type. You only need to add some options and parameters, such:

# Xen-create-image -- hostname = ubuntu.example.com -- size = 4G -- swap = 1G -- memory = 1G -- ip = 192.168.0.101 -- arch = amd64 -- role = udev -- scsi -- dist maverick -- mirror = http://mirrors.163.com/ubuntu

Note: Never forget -- role = udev

For specific parameters, see the man page of xen-create-image:

# Man xen-create-image

After the preceding command is executed, the instance creation process is displayed. You will be prompted to enter the password as the root account password of the VM instance. After creation, the imgfile is generated in the previously specified directory as the storage of the VM instance, And the. cfg file is generated under/etc/xen as the configuration file started by the VM instance.

Next, run the xm command to start the instance:

Xm create-c ubuntu.example.com. cfg

Successfully enters the instance system.

==================================== Create a CentOS instance ============== ==============

When xen-tools is used to create a CentOS instance, rinse is used.

Before creating a CentOS instance, install the following dependency packages:

# Apt-get install-y debootstrap libbeecrypt7 libc6-xen libconfig-inifiles-perl libcryct-perl libio-pty-perl libio-stty-perl librpm2 libterm-readline-gnu-perl libterm-size- perl libtext-template-perl reiserfsprogs rinse rpm screen vnstat

Some rpm packages will be downloaded and installed during rinse instance creation. The default package in the rinse configuration file may cause instance creation failure. Therefore, you need to add some packages:

# Vi/etc/rinse/centos-x.packages

[...]

# Add the following content at the end

Nss

Nspr

Python-iniparsel

Authconfig

In addition, you can change the installation source of CentOS instances. rinse uses a UK source by default, which is relatively slow.

# Vi/etc/rinse. conf

[...]

Mirror = http://mirrors.163.com/centos/6.2/ OS /i386/Packages

Mirror. amd64 = http://mirrors.163.com/centos/6.2/ OS /x86_64/Packages

Like ubuntu, xen-tools supports the latest CentOS version 5. x. If you need to install CentOS 6. x, you need to create a corresponding installation process. Regardless of which version of the installation process is similar, you can directly copy the installation process of 5.x.

# Cd/usr/lib/xen-tools/

# Cp-a centos-5.d centos-6.d

Next, you can create a CentOS instance. Because you have changed the installation method, you need to add the corresponding options and parameters to the command. At the same time, the -- role = udev parameter is not required:

# Xen-create-image -- hostname = centos.example.com -- size = 4G -- swap = 1G -- memory = 1G -- ip = 192.168.0.102 -- dist = centos-6 -- install-method = rinse -- arch = amd64

The creation process is similar to that of the ubuntu instance. After the instance is created, start the instance:

# Xm create-c centos.example.com. cfg

In this way, you can successfully log on to the CentOS Virtual Machine instance.

================================================================ ==================

1. An error occurs when you create a CentOS instance, probably because the image source cannot be read. In this case, you must replace the valid image source.

2. when a virtual machine is created and started, there may be no idle loop. The main reason is that only eight loops are loaded by default when the loop kernel module is loaded at startup, we can modify/etc/modules to specify the maximum number of loop loaded upon startup:

# Vi/etc/modules

[...]

Loop max_loop = 64

3. the xen-tools log file is in/var/log/xen-tools. The log file is named after the instance host name. You can monitor the log file during the creation process, you can also view the log file to troubleshoot the error.

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

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.