domU 的建立

 

在 Debian Host 上建立 Debian domU

 

xen-create-image --hostname <hostname> --ip <ip> --vcpus 2 --memory=512mb --pygrub --dist <lenny|squeeze|maverick|whatever>

# wrapper around three distinct external tools
# xt-install-image
# xt-customize-image
# xt-create-xen-config

 

學習:

  • --manual
  • --help

 

有用選項:

  • --install-method=rinse                   // debootstrap, rinse, tar, copy ( --install-source=tarball.tar )
  • --arch=arch                                   // pass 入 debootstrap, rinse 用
  • --dist ???                                       // 支持的 OS 放在 /usr/lib/xen-tools/, 如果不是 Debian 系統, 那要配合 --install-method=rinse 使用
  • --passwd                                      // 設定 domU 的 root Password (另有 --password=passphrase)
  • --keep                                          // Don't delete our images if installation fails.

Net:

  • --ip=192.168.1.200
  • --netmask=255.255.255.0
  • --gateway=192.168.1.1
  • --nameserver=192.168.1.1

--ide                                                    //Use IDE names for virtual devices (i.e. hda not xvda)
--initrd=/path/to/initrd
--kernel=/path/to/kernel

 

# 會有以下建立

modprobe loop max_loop=255
Creating partition image: /xen/domains/debian6/swap.img
Creating swap on /xen/domains/debian6/swap.img
Creating partition image: /xen/domains/debian6/disk.img
Creating ext3 filesystem on /xen/domains/debian6/disk.img
Installation method: debootstrap
Running hooks


Installation Summary
---------------------
Hostname        :  debian6
Distribution    :  squeeze
IP-Address(es)  :  192.168.88.152
RSA Fingerprint :  d3:56:12:96:22:8d:9d:2b:8f:50:cc:02:15:31:b0:fe
Root Password   :  N/A


# 建立時會有 log file 在 /var/log/xen-tools/debian6.log

 

設定檔 /etc/xen/debian.cfg

kernel      = '/boot/vmlinuz-2.6.32-5-xen-amd64'                <-- Host 的 Kernel 來
ramdisk     = '/boot/initrd.img-2.6.32-5-xen-amd64'
vcpus       = '1'
memory      = '512'
root        = '/dev/xvda2 ro'
disk        = [
                  'file:/xen/domains/debian6/disk.img,xvda2,w',
                  'file:/xen/domains/debian6/swap.img,xvda1,w',
              ]
name        = 'debian6'
vif         = [ 'ip=192.168.88.152,mac=00:16:3E:6B:25:B7,bridge=vmbr0' ]
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

 

查看 image 的位置:

/xen/domains/debian6# ls

disk.img  swap.img

image 的格式:

file swap.img

swap.img: Linux/i386 swap file

file disk.img

disk.img: Linux rev 1.0 ext3 filesystem data

 

啟動 VM:

xm create /etc/xen/virtual_machine.cfg

 


 

RPM-based distribution.

Creating partition image: /xen/domains/centos5/swap.img
Done

Creating swap on /xen/domains/centos5/swap.img
Done

Creating partition image: /xen/domains/centos5/disk.img
Done

Creating ext3 filesystem on /xen/domains/centos5/disk.img
Done
Installation method: rinse

 

 

 

 

Remark 1

CentOS 5.6 在 Debian6 Xen Host 上的問題

............
Running hook 20-setup-yum
/usr/bin/python: error while loading shared libraries: libpython2.4.so.1.0:
cannot open shared object file: No such file or directory
hook 20-setup-yum: done.
............

 

在 mirror 上是找不到 libpython 的....

http://mirror.centos.org/centos/5/os/i386/CentOS/

原來它叫

python-libs

/etc/rinse/
centos-4.packages
centos-5.packages

 

Remark 2

rhel has dropped support for Xen in version 6

 

 


Boot

 

有 bootloader 就不用 kernel 及 ramdisk

bootloader = '/usr/lib/xen-default/bin/pygrub'

kernel      = '/boot/vmlinuz-2.6.32-5-xen-amd64'
ramdisk     = '/boot/initrd.img-2.6.32-5-xen-amd64'

 

--pygrub            DomU should be booted using pygrub

start Linux DomUs with the kernels that lie in the filesystem of the DomU instead of with a Kernel that lies in the filesystem of the Dom0

reads the standard Grub menu.lst to provide the xen create process with the required parameters and SXP stanzas.

 

 


 

Centos4

/etc/rinse/rinse.conf

[centos-4]
mirror       = http://vault.centos.org/4.9/os/i386/CentOS/RPMS/

[Harmless] Failed to find download link for libsysfs
[Harmless] Failed to find download link for mcstrans

text installation

mkdir -p /boot/domU/centos4.9/installer
cd /boot/domU/centos4.9/installer
wget http://vault.centos.org/4.9/os/i386/images/xen/vmlinuz
wget http://vault.centos.org/4.9/os/i386/images/xen/initrd.img

kickstart file

extra = "text ks=http://localserver/minimal-ks.cfg"

install
url --url http://mirror.centos.org/centos/5/os/i386
lang en_US.UTF-8
network --device eth0 --bootproto dhcp
# Bogus password, change to something sensible!
rootpw bogus
firewall --enabled --port=
authconfig --enableshadow --enablemd5
selinux --enforcing ??port=22:tcp
timezone --utc Europe/Amsterdam
bootloader --location=mbr --driveorder=xvda --append="console=xvc0"
reboot

# Partitioning
clearpart --all --initlabel --drives=xvda
part /boot --fstype ext3 --size=100 --ondisk=xvda
part pv.2 --size=0 --grow --ondisk=xvda
volgroup VolGroup00 --pesize=32768 pv.2
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=256 --grow --maxsize=512

%packages
@core

 

 

Welcome to CentOS

                   +---------+ Choose a Language +---------+
                   |                                       |
                   | What language would you like to use   |
                   | during the installation process?      |
                   |                                       |
                   |       Catalan                #        |
                   |       Chinese(Simplified)    #        |
                   |       Chinese(Traditional)   #        |
                   |       Croatian               #        |
                   |       Czech                  #        |
                   |       Danish                 #        |
                   |       Dutch                  #        |
                   |       English                #        |
                   |                                       |
                   |                +----+                 |
                   |                | OK |                 |
                   |                +----+                 |
                   |                                       |
                   |                                       |
                   +---------------------------------------+

  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

 

Post-install configuration

bootloader="/usr/bin/pygrub"

 


 

其他工具

# To erase a VM image
xen-delete-image VMs_name

 

 

 

 

Creative Commons license icon Creative Commons license icon