Xen環境の導入とdebootstrapによるDomain-Uの構築

Xenの導入

Xen関連パッケージの導入とブリッジネットワークを有効にする。

$ sudo aptitude install xen-linux-system-2.6.26-2-xen-amd64 xen-tools bridge-utils
$ diff /etc/xen/xend-config.sxp.org /etc/xen/xend-config.sxp
123c123
< # (network-script network-bridge)
---
> (network-script network-bridge)
139c139
< (network-script network-dummy)
---
> # (network-script network-dummy)

OSを再起動する。*1
OS起動後、xendデーモンが起動していることを確認する。

$ ps aux | grep xend
root      2566  0.0  0.1  95072  9360 ?        S    15:54   0:00 python /usr/lib/xen-3.2-1/bin/xend start
root      2570  0.0  0.1 221368 13972 ?        Sl   15:54   0:01 python /usr/lib/xen-3.2-1/bin/xend start
$ sudo sysv-rc-conf --list xend
xend         0:off	1:off	2:on	3:on	4:on	5:on	6:off
$ sudo sysv-rc-conf --list xendomains
xendomains   0:off	1:off	2:on	3:on	4:on	5:on	6:off

Domain-Uの構築

debootstrapを使って、Domain-UにLenny環境を構築する。
設定ファイルの作成。*2

##
# /etc/xen-tools/xen-tools.conf
##
#
# This is the global configuration file for the scripts included
# within the xen-tools package.
#
# For more details please see:
#
# http://xen-tools.org/
#
##

dir = /home/xen
install-method = debootstrap
size = 10Gb # Disk image size.
memory = 512Mb # Memory size
swap = 512Mb # Swap size
fs = ext3 # use the EXT3 filesystem for the disk image.
dist = lenny # Default distribution to install.
image = sparse # Specify sparse vs. full disk images.
dhcp = 1
kernel = /boot/vmlinuz-`uname -r`
initrd = /boot/initrd.img-`uname -r`
arch=amd64
mirror = http://ftp.jp.debian.org/debian/

Domain-Uの作成。

$ sudo xen-create-image --hostname vmdebian01 --passwd
General Information
--------------------
Hostname       :  vmdebian01
Distribution   :  lenny
Partitions     :  swap            512Mb (swap)
                  /               10Gb  (ext3)
Image type     :  sparse
Memory size    :  512Mb
Kernel path    :  /boot/vmlinuz-2.6.26-2-xen-amd64
Initrd path    :  /boot/initrd.img-2.6.26-2-xen-amd64

Networking Information
----------------------
IP Address     : DHCP [MAC: 00:16:3E:2D:A7:BD]


Creating partition image: /home/xen/domains/vmdebian01/swap.img
Done

Creating swap on /home/xen/domains/vmdebian01/swap.img
Done

Creating partition image: /home/xen/domains/vmdebian01/disk.img
Done

Creating ext3 filesystem on /home/xen/domains/vmdebian01/disk.img
Done
Installation method: debootstrap
Done

Running hooks
Done

No role scripts were specified.  Skipping

Creating Xen configuration file
Done
Setting up root password   # rootパスワードの設定
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
All done


Logfile produced at:
	 /var/log/xen-tools/vmdebian01.log

Domain-Uの起動

"xm create"コマンドでDomain-Uが起動できますが、私の環境では"Starting periodic command scheduler: crond."で起動が止まってしまいコンソールが表示されなかったので、cfgファイルに設定を追加しました。

##
# /etc/xen/vmdebian01.cfg
# 以下の設定を追加
##
extra = 'xencons=tty'

$ sudo xm create -c vmdebian01.cfg


Home - Xen Project
Computer Laboratory - Xen virtual machine monitor

*1:この時点で"/boot/grub/menu.lst"が更新されていて、次回から"Xen 3.2-1-amd64 / Debian GNU/Linux, kernel 2.6.26-2-xen-amd64"がデフォルトで起動するようになっている。

*2:今回は、Domain-U環境へDHCPIPアドレスを付与します。