2、mkdir domain
mkdir domain/winxp
3、创建虚拟机的磁盘镜像文件,作为winxp的文件系统挂载点:大小为8G
dd if=/dev/zero of=/home/cym/domain/winxp/winxp.img bs=1k seek=8000
count=1
4、将winxp的镜像文件放到虚拟机磁盘镜像文件的同一目录下;
5、cp /etc/xen/xmexample.hvm /home/cym/domain/winxp/
mv /home/cym/domain/winxp/xmexample.hvm
/home/cym/domain/winxp/winxp.cfg
6、写配置文件winxp.cfg
memory = 512
name="winxp"
vcpus=2
#vif
disk=['file:/home/cym/domain/winxp/winxp.img,ioemu:hda,w','file:/home/cym/domain/winxp/WindowsXPSP3.iso,hdc:cdrom,r']
boot="d"
7、运行配置文件,创建虚拟机:xm create winxp.cfg
8、sudo vncviewer 进入winxp的安装界面。
9、打开虚拟机管理软件,查看
/************************************************
*************************************************
半虚拟化GuestOS制作步骤
1、mkdir vLinux
sudo dd if=dev/zero of=/home/cym/vlinux/Ubuntu8.04.img bs=1M
seek=8000 count=1
2、mkfs.ext3 vLinux/Ubuntu8.04.img
@@@@@@@@@@@以上是创建半虚拟机的虚拟磁盘镜像文件并把其格式化为ext3文件格式;@@@@@@@@@
3、sudo mkdir /mnt/vLinux
sudo mount -o loop /home/cym/domain/vLinux/Ubuntu8.04.img
/mnt/vLinux
4、cp -ax /{root,dev,var,etc,usr,bin,sbin,lib} /mnt/vLinux
mkdir /mnt/vLinux/{proc,sys,home,tmp}
5、修改/mnt/vLinux/etc/fstab
echo "/dev/sda8 / ext3 defaults 1 1" > /mnt/vLinux/etc/fstab
//sda8是根目录/
6、sudo umount /mnt/vLinux
7、sudo cp /etc/xen/xmexample2
/home/cym/domain/vLinux/Ubuntu8.04.cfg
sudo gedit Ubuntu8.04.cfg 清除里面的内容写入以下信息:
**************************
******
kernel = "/boot/vmlinuz-2.6.18.8-xen"
ramdisk = "/boot/vmlinuz-2.6.18.8-xen.img"
name = "Ubuntu8.04"
memory=512
disk = [ 'file:/home/cym/domain/vLinux/ubuntu8.04.img,sda8,w']
vcpus=2
root = "/dev/sda8 ro"
vif = [ '' ]
ip ="192.168.24.154"
netmask ="255.255.255.0"
getway=""
*******
************************
8、运行半虚拟化配置文件启动Ubuntu8.04
sudo xm create /home/cym/vLinux/ubuntu8.04.cfg
xm console
启动,停止虚拟机:
可以使用xm 命令来启动停止虚拟机启动虚拟机命令如下:
xm create vm1 #其中vm1
为虚拟机的配置文件,位于/etc/xen/vm/vm1
xm create -c vm1 #如果需要启动控制台,则可以运行命令
xm list #可以列出所有的虚拟机
xm console
xm reboot|shutdown
xm destroy
xm console fc5 #从终端或控制台登录正在运行的虚拟操作系统
xm save
xm restore
xm pause
xm unpause
xm mem-set
xm shutdown 虚拟操作系统的Name或DomID #关闭被虚拟的系统
xm destroy
xm vcpu-set
xm top 或 xentop # 查看虚拟系统运行的状态
xm save VM1 VM1.chk # stop the domain and save
its current state into a file called VM1.chk
xm restore VM1.chk #resume execution of this
domain
其它
++如果??想要在系统开机时就自动启动某个 domain-U 的话,可以将该设定档指定连结到这个目录中。
举例来说,如果??要在开机后立即使用 /etc/xen/xmexample.hvm 设定档来启动某个 domain-U ,
那可以这样做:
cd /etc/xen/auto
ln -s ../xmexample.hvm .
最后保证xendomains是开机自动启动即可
++ 列出所以的vif与bridage 对应关系
xen ~ # brctl show
++修改启动顺序
boot=”cda” # boot on floppy (a), hard disk (c) or CD-ROM (d)
++相关配置文件说明
disk = [ 'file:/opt/xen/kcwin2k3_2/disk1.img,hda,w',
'file:/opt/xen/kcwin2k3_2/disk2.img,hdb,w',
'file:/iso/win2k3.iso,hdc:cdrom,r', ] 虚拟机的第1和第2块虚拟磁盘,
指定了虚拟机的CDROM,目标其实是宿主机上的一张Win2k3安装ISO镜像的路径,然后r代表只读
serial = “pty” # enable serial console
#cpus = “0-3,5,^1″ # run on cpus 0,2,3,5
++网络相关
brctl show #桥链状态
network-bridge start bridge=xenbr1 netdev=eth1 vifnum=1
#新增一个桥连口xenbr1,以本机eth1为源网卡
++新增一个网桥xenbr1,并使用eth1网卡
http://blog.zhangjianfeng.com/article/744
++修改宿主机的网卡IP
/usr/share/doc/packages/xen/README.SuSE 中这么一段说明
Configuring network interfaces when using Xen bridging:
Due to the renaming of network interfaces by the network-bridge
script
(e.g. eth0 to peth0), network interfaces should not be configured
or restarted
while they are enslaved to a Xen bridge. Before configuring a
network
interface enslaved to a Xen bridge, shutdown all VMs using the
interface.
Then use the network-bridge script to remove the Xen bridge and to
restore the
network interface back to normal (put peth0 back to eth0). For
example, to
remove the Xen bridge and restore eth0 back to normal do the
following:
/etc/xen/scripts/network-bridge stop netdev=eth0
With the Xen bridge removed and eth0 put back to normal, eth0 can
then be
configured or restarted. Once the configuration is complete, Xen
bridging can
be started back up again (creating the Xen bridge and renaming eth0
to peth0)
by doing the following:
/etc/xen/scripts/network-bridge start netdev=eth0
The VMs can then be started again.
++XEN中安装windows操作系统后,出现登录屏幕却无法按ctrl+alt+delete解决办法
- hit crtl-alt-2 (the two-key on top of you normal keyboard, not on
the
numeric keypad)
- type this literally (without the quotes): “sendkey
ctrl-alt-delete”
- hit ctrl-alt-1 to get back to the vm
*此问题在xen3.2中已经可以用过管理菜单控制
++Domain-0的内存不自动回收的解决办法
xen子机Domain-U关机后,Domain-0并不会自动回收内存,需要手工用命令回收
xm mem-set Domain-0 2048
附1: 安装时用到的配置
more /etc/xen/vm/mgr1_install
ostype=”sles10″
name=”mgr1″
memory=512
vcpus=1
uuid=”29d6679c-7cd8-e731-c9e7-47b4276296da”
#on_crash=”destroy”
on_poweroff=”destroy”
#on_reboot=”destroy”
localtime=0
builder=”linux”
kernel=”/tmp/kernel.UjQch1″
ramdisk=”/tmp/install-initrd.ndmsAh”
extra=”TERM=xterm install=http://192.169.0.155/iso/ ”
disk=[ 'file:/zhangjianfeng/data/xen/images/mgr1/disk0,xvda,w',
]
vif=[ 'mac=00:16:3e:00:00:01', ]
vfb=["type=vnc,vncunused=1"]
附2: 安装系统后,需要手工处理配置文件,加入相关参数,防止不停重启安装
ostype=”sles10″
name=”mgr1″
#memory=512
memory=768
vcpus=2
uuid=”29d6679c-7cd8-e731-c9e7-47b4276296da”
on_crash=”restart”
on_poweroff=”destroy”
on_reboot=”restart”
localtime=0
builder=”linux”
#kernel=”/tmp/kernel.UjQch1″
#ramdisk=”/tmp/install-initrd.ndmsAh”
kernel = “/boot/vmlinuz-xen”
ramdisk = “/boot/initrd-xen”
extra=”TERM=xterm install=http://192.169.0.155/iso/ ”
disk=[ 'file:/zhangjianfeng/data/xen/images/mgr1/disk0,xvda,w',
'phy:/dev/cdrom,xvdb,r',
'file:/zhangjianfeng/iso/sles10.1.iso,xvdc,r', ]
#vif=[ 'mac=00:16:3e:00:00:01', ]
vif=[ 'mac=00:16:3e:00:00:01,bridge=xenbr0',
'mac=00:16:3e:00:00:02,bridge=xenbr1' ]
vfb=["type=vnc,vncunused=1"]
#bootloader = “/usr/lib/xen/boot/domUloader.py”
#bootentry = “xvda2:/boot/vmlinuz-xen,/boot/initrd-xen”
root = “/dev/xvda2″
boot=”cda”
##为安装好的虚拟机配置新的kernel和ramdisk配置
附3: 一个windowsXP的配置(Full 虚拟化)
ostype=”windowsxp”
name=”windowsxp”
memory=1024
#memory=512
vcpus=1
uuid=”c759db4d-c15d-23f4-84ed-5c53d4fd1472″
#on_crash=”destroy”
#on_poweroff=”destroy”
#on_reboot=”destroy”
on_crash=”restart”
on_poweroff=”destroy”
on_reboot=”restart”
localtime=1
builder=”hvm”
device_model=”/usr/lib/xen/bin/qemu-dm”
kernel=”/usr/lib/xen/boot/hvmloader”
boot=”dc”
disk=[ 'file:/zhangjianfeng/data/xen/images/windowsxp/disk0,hda,w',
'file:/media/system/windows/xp-en/1.iso,hdc:cdrom,r', ]
#disk=[
'file:/zhangjianfeng/data/xen/images/windowsxp/disk0,hda,w',
'file:/zhangjianfeng/iso/WXPVOL_EN.ISO,hdc:cdrom,r', ]
vif=[ 'mac=00:16:3e:0a:ef:c0,model=rtl8139,type=ioemu', ]
vnc=1
vncunused=1
apic=0
acpi=1
pae=1
usb=1
usbdevice=’tablet’
usbdevice = ‘host:Generic:058F0O1111B1′
serial=”pty”
audio = 1 #开启声卡
soundhw=’all’ #开启声卡