Create and start an xen VM

Source: Internet
Author: User

Create and start an xen VM

Semi-Virtualization

Get sample image
Download and decompress the package at jailtime.org (note that the default root password is password)
# Tar jxvf centos.5-0.20070424.img.tar.bz2
Centos.5-0.img
Centos.5-0. xen2.cfg
Centos.5-0. xen3.cfg
Centos. Swap

You can download it at http://www.rpath.com/rbuilder.

Create a configuration file
Refer to centos.5-0. xen2.cfg and centos.5-0. xen3.cfg. The content is:
Kernel = "/boot/vmlinuz-2.6.18-xen"
Ramdisk = "/boot/initrd-2.6.18-xen.img"
Memory = 256
Name = "centos.5-0"
DHCP = "DHCP"
VIF = ['']
Disk = ['Tap: AIO:/home/xen/centos.5-0.img, xvda1, W ',
'Tap: AIO:/home/xen/centos. Swap, xvda2, W']
Root = "/dev/xvda1 ro"

Integrating loadable kernel modules into your root filesystem
$ Uname-R
2.6.18-xen
$ Su
Password :*********
# Mkdir-P/mnt/img
# Mount-o loop centos.5-0.img/mnt/img
# Cd/mnt/img/lib/modules
# Cp-r/lib/modules/'uname-R '.
# Ls
2.6.18-xen

Modify other configuration files
# Cat/mnt/img/etc/fstab
/Dev/xvda1/ext3 defaults 1 1
/Dev/xvda2 none swap SW 0 0
None/dev/PTS devpts gid = 5, mode = 620 0 0
None/dev/SHM tmpfs defaults 0 0
None/proc defaults 0 0
None/sys sysfs defaults 0 0

# Cat/mnt/img/etc/sysconfig/network-scripts/ifcfg-eth0
Type = Ethernet
Device = eth0
Bootproto = DHCP
Onboot = Yes

# Cat/mnt/img/etc/Network/interfaces
Auto Lo
Iface lo Inet loopback
Auto eth0
Iface eth0 Inet DHCP

# Cd/
# Sync
# Umount/mnt/img

Creating initial RAM disks and filesystems for your Kernel
# Yaird -- output initrd-2.6.18-xen.img 2.6.18-xen
# Mkinitramfs-O initrd-2.6.18-xen.img 2.6.18-xen
# Mkinitrd-O initrd-2.6.18-xen.img 2.6.18-xen

Start a VM

# XM create centos.5-0. xen3.cfg-C

# XM list
Name id mem (MIB) vcpus state time (s)
Domain-0 0 1752 2 R ----- 56978.8
Foresight 46 384 1-B ---- 1180.1
Opensuse 17 256 1-B ---- 2114.4
Ubuntu 34 256 1-B ---- 591.7
Centos.5-0 45 256 1-B ---- 302.9
Freespire-hvm 49 256 1-B ---- 63.2


Terminal connected to the Virtual Machine
# XM console 45 &


Fully virtualized hvm

A simple freespire. cfg:
Import OS, re
Arch = OS. uname () [4]
If Re. Search ('64', arch ):
Arch_libdir = 'lib64'
Else:
Arch_libdir = 'lib'
Kernel = "/usr/lib/xen/boot/hvmloader"
Builder = 'hvm'
Memory = 256
Shadow_memory = 8
Name = "FS-IMG-HV"
ACPI = 1
APIC = 1
VIF = ['Type = ioemu, bridge = xenbr0'
Disk = ['Tap: AIO:/home/xen/hvm/freespire1013.img, hda, W ',
'Phy:/dev/hda, HDC: CDROM, R']
Device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
Boot = "DC"
Serial = 'PTY'
USB = 1
Usbdevice = 'tablet'
The created virtual machine can be connected through VNC. The VNC port that you connect to is 127.0.0.1: 5900 + domainid
$ Vncviewer 127.0.0.1: 5931

SDL Configuration:
SDL = 1
VNC = 0

Start a VM
# XM create freespire. cfg-C

Automatically Start Domains

Put the configuration file in the/etc/xen/auto/directory.

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.