1、准备windowxp的光盘.iso镜像文件,安装虚拟机管理器软件包:virt-manager、安装libvirt库(虚拟化的API)等相关的依赖软件包。很多软件包我也忘了,当时看别人的没记下来。
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 <domainID> ----->>进入虚拟机!!!
相关管理命令:
启动,停止虚拟机: 可以使用xm 命令来启动停止虚拟机启动虚拟机命令如下: xm create vm1 #其中vm1 为虚拟机的配置文件,位于/etc/xen/vm/vm1 xm create -c vm1 #如果需要启动控制台,则可以运行命令 xm list #可以列出所有的虚拟机 xm console <domid> #可以显示某虚拟机的控制台 xm reboot|shutdown <domid> #可以重起和关闭id 为domid 的虚拟机 xm destroy <domid> #可以销毁id 为domid 的虚拟机 xm console fc5 #从终端或控制台登录正在运行的虚拟操作系统 xm save <DomId> <File> # 存储正在运行的虚拟操作系统的状态 xm restore <File> # 唤醒虚拟操作系统 xm pause <DomId> #停止正在运行的虚拟操作系统 xm unpause <DomId> #激活停止的虚拟操作系统 xm mem-set <DomId> <Mem> #调整虚拟平台/虚拟操作系统的占用内存 xm shutdown 虚拟操作系统的Name或DomID #关闭被虚拟的系统 xm destroy <DomId> #立即停止虚拟的系统 (重要); xm vcpu-set <DomId> <VCPUs> #调整虚拟平台及虚拟操作系统的虚拟CPU个数 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网卡 ++修改宿主机的网卡IP ++XEN中安装windows操作系统后,出现登录屏幕却无法按ctrl+alt+delete解决办法 ++Domain-0的内存不自动回收的解决办法 附1: 安装时用到的配置
附2: 安装系统后,需要手工处理配置文件,加入相关参数,防止不停重启安装
附3: 一个windowsXP的配置(Full 虚拟化)
|