Xen 安装 DomU(Ubuntu、CentOS)

Dom0 为 CentOS-5.6-x86_64,下面分两种主流的发行版本,分别为 Ubuntu 和 CentOS。

DomU 为 ubuntu

# mkdir /opt/xen/ubuntu-template
# cd /opt/xen/ubuntu-template
# wget http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-amd64/current/images/netboot/xen/initrd.gz
# wget http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-amd64/current/images/netboot/xen/vmlinuz
# dd if=/dev/zero of=ubuntu-10.04-x86_64.img bs=1M count=10240
# cat ubuntu.cfg


VM_PATH=os.getcwd()
VM_NAME=sys.argv[0]

kernel = '%s/vmlinuz'%VM_PATH
ramdisk = '%s/initrd.gz'%VM_PATH

maxmem = 4096
memory = 2048
vcpus = 1

#bootloader = "/usr/bin/pygrub"
disk = [
'tap:aio:%s/ubuntu-10.04-x86_64.img,xvda,w'%VM_PATH
]

on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"

vif = [ "mac=00:16:3e:05:01:02,bridge=xenbr0" ]

DomU 为 CentOS

# mkdir -p /opt/xen/centos-template
# cd /opt/xen/centos-template
# wget http://mirrors.163.com/centos/5/os/x86_64/images/xen/initrd.img
# wget http://mirrors.163.com/centos/5/os/x86_64/images/xen/vmlinuz
# dd if=/dev/zero of=centos-5.6-x86_64.img bs=1M count=10240
# cat centos.cfg

VM_PATH=os.getcwd()
VM_NAME=sys.argv[0]

kernel = '%s/vmlinuz'%VM_PATH
ramdisk = '%s/initrd.gz'%VM_PATH

maxmem = 1024
memory = 1024
vcpus = 1

#bootloader = "/usr/bin/pygrub"
disk = [
'tap:aio:%s/centos-5.6-x86_64.img,xvda,w'%VM_PATH
]

on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"

vif = [ "mac=00:16:3e:05:01:01,bridge=xenbr0" ]

可在 cfg 文件中加入 kickstart 的方式来简化安装:

extra = "text ks=http://ip/ks.cfg"

对于 RH 系,除了使用上述方式,最简单的可以通过一个交互式的工具 virt-install 来解决:

# virt-install  --prompt
按照提示一步一步往下即可。