Install and configure Xen On Debian

Source: Internet
Author: User

SUN will donate some depreciating servers to universities, laboratories, and research institutions in every incident. Our project team has just cheated on several free Sun Fire servers. Of course, it is also related to our long-term customers who are SUN (maybe Oracle now, our servers are basically SUN. Now, as long as the new machine comes in, it is virtualized before it can be mounted to the Cabinet. The technology is changing too fast. Remember that the operating system was first installed when we bought the machine a few years ago, hypervisor now replaces the operating system.

 

First, minimize the 64-bit Debian installation. The following installation steps and configuration process are based on Debian 5.04. For CentOS versions, see install and configure Xen on CentOS. For Ubuntu versions, see: install and configure Xen on Ubuntu. For the OpenSolaris version, see install and configure Xen on OpenSolaris.

Install Xen
Check the source list:

# Vi/etc/apt/sources. list

Deb http://http.us.debian.org/debian stable main contrib non-free
# Deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
Deb http://security.debian.org stable/updates main contrib non-free
Install Xen and related tools:

# Apt-get install xen-hypervisor-3.2-1-amd64
Xen-linux-system-2.6.26-1-xen-amd64 xen-utils-3.2-1
Xenstore-utils xenwatch xen-shell xen-tools
We need a lot of loop devices to mount file-based virtual machines, so we need to set the maximum number of loop devices:

# Vi/etc/modules

Loop max_loop = 64
After Xen is installed, the default network configuration of Xen On Debian uses network-dummy, which is a little different from that on CentOS, we need to change to bridge so that each virtual machine runs on the network like an independent machine:

# Vi/etc/xen/xend-config.sxp

# (Network-script network-dummy)
(Network-script network-bridge)
After the installation is successful, check whether the Xen kernel has been installed, and add dom0_mem = 256 M to the kernel to limit the Xen Dom0 memory to prevent dom0 from consuming the memory:

# Vi/boot/grub/menu. lst

...
Title Xen 3.2-1-amd64/Debian GNU/Linux, kernel 2.6.26-2-xen-amd64
Root (hd0, 0)
Kernel/xen-3.2-1-amd64.gz dom0_mem = 256 M
Module/vmlinuz-2.6.26-2-xen-amd64 root =/dev/mapper/vpsee-root ro console = tty0
Module/initrd. img-2.6.26-2-xen-amd64
...
After the system is restarted, check whether the Xen kernel is enabled and whether the Xen is started:

# Reboot

# Uname-r
2.6.26-2-xen-amd64

# Xm list
Name ID Mem VCPUs State Time (s)
Domain-0 0 256 2 r ----- 9.3
Create and install guest
If you think of the operating system of the running Xen kernel as the host, the operating system running on the host can be considered as the guest. Create a directory to store images, vm01.img, and vm02.img of all the guest operating systems. One guest corresponds to one image.

# Mkdir/vm

# Xen-create-image -- hostname = vm01 -- size = 10 Gb -- swap = 512 Mb -- ide
-- Ip = 172.16.39.121 -- netmask = 255.255.254.0 -- gateway = 172.16.38.1 -- force
-- Dir =/vm -- memory = 512 Mb -- arch = i386
-- Kernel =/boot/vmlinuz-2.6.26-2-xen-amd64
-- Debootstrap -- dist = etch -- mirror = http://ftp2.de.debian.org/debian/ -- password
You can adjust/etc/xen-tools/xen-tools.conf as needed

Go to guest
After the installation is successful, you need to add an Xen configuration file to the corresponding virtual machine so that Xen can start the virtual machine:

# Vi/etc/xen/vm01

Kernel =/boot/vmlinuz-2.6.26-2-xen-amd64
Ramdisk =/boot/initrd. img-2.6.26-2-xen-amd64
Memory = 512
Root =/dev/xvda2 ro
Disk = [
File:/vm/domains/vm01/swap. img, xvda1, w,
File:/vm/domains/vm01/disk. img, xvda2, w,
]
Name = vm01
Vif = [ip = 172.16.39.121, mac = 00: 16: 3E: C0: 21: DE]
On_poweroff = destroy
On_reboot = restart
On_crash = restart
After starting the Debian virtual machine, you can log on to it,

# Xm create vm01
# Xm console vm01
If you want to exit guest, press Ctrl +] to return to the host.

If you want to automatically start guest each time you start the host:

# Ln-s/etc/xen/vm01/etc/xen/auto
Lazy Approach
If you think it is too troublesome to install the guest operating system, you can go to the http://stacklet.com/download an installed image file, adjust the Xen guest configuration file, and then start the guest image under the host, here is a more detailed introduction.

Add swap
How to add swap to the guest system (domU) is described here

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.