xen使用命令行创建新虚拟机

时间:2014-04-05 09:46:34

标签: linux centos virtual-machine virtualization xen

我想使用xen virt-install命令

创建(CentOS)虚拟机

我正在使用kickstart并将其放入http://192.168.1.8/centos/kickstart.cfg中 并将Centos 6.5放入http://192.168.1.8/centos/os/ enter image description here

使用

[root@CentOS ~]# dd if=/dev/zero of=/var/lib/xen/images/vserver.img bs=1M count=4000

[root@CentOS ~]# virt-install -p -n vserver -r 512 -f /var/lib/xen/images/vserver.img -l http://192.168.1.8/centos/os -x ks=http://192.168.1.8/centos/kickstart.cfg -w bridge:xenbr0 --vcpus=1

结果

Starting install... ERROR Could not find an installable distribution at 'http://192.168.1.8/centos/os' The location must be the root directory of an install tree. Domain installation does not appear to have been successful. If it was, you can restart your domain by running: virsh --connect xen:/// start vserver otherwise, please restart your installation.

1 个答案:

答案 0 :(得分:2)

需要.treeinfo文件,

vi /var/www/html/centos/os/.treeinfo

并添加以下行:

[general]
family = CentOS
timestamp = 1341518023.56
variant = 
totaldiscs = 1
version = 6.5
discnum = 1
packagedir = 
arch = i386

[images-i386]

initrd = images/pxeboot/initrd.img

[images-xen]

initrd = isolinux/initrd.img
kernel = isolinux/vmlinuz

[stage2]
mainimage = images/install.img

不要直接从浏览器复制,先用键盘书写或先将其复制到文本文件中,以便删除任何特殊字符。

最终给予Apache文件所有权:

chown -R apache:apache /var/www/html/*

在virt-install命令中,将CentOS(URL)添加为字符串 并使用--bridge=xenbr0代替bridge:xenbr0

[root@CentOS ~]# virt-install -p -n vserver -r 512 -f /var/lib/xen/images/vserver.img  -l "http://192.168.1.8/centos/os" -x -w --bridge=xenbr0 --vcpus=1

P.S:如果您使用64位版本到x86_64

,请更改拱门字段