+--------------------------------------------------------------------------------------------------------------------------------------------------------------
1. Create configuration file for this OS:
   xm create -c 虚拟操作系统的启动配置文件
 比如我们要启动被虚拟的操作系统Fedora Core 5.0,我们要写一个启动Fedora的配置文件,比如是fc5vm.cfg。然后就可以通过下面的命令来引导Fedora了;
  xm create -c fc5vm.cfg
2. Virtual machine's virtual disk can be mapped into a file or a partition, for a file, here is the example:(4G)
 dd if=/dev/zero of=/var/lib/xen/images/fedora50.img bs=1M count=4096
 dd if=/dev/zero of=/vm/redhat2.img bs=1M count=8192
 
3. Use virt-install to generate the specified OS configuration:(following is windows & linux example)
        virt-install -n redhat1 --file=/vm/redhat1.img --vnc -v -c /package/redhat/valhalla-i386-disc1.iso -r 1024 --vcpus=1
 virt-install -n redhat2 --file=/vm/redhat2.img --vnc -v -c /package/redhat/valhalla-i386-disc1.iso -r 1024 --vcpus=1
 virt-install       建立虚拟机的命令
 -n                 虚拟机的命名
 --file             虚拟机的磁盘文件
 --vnc              使用VNC终端连接方式
 -r                 虚拟机的内存容量
 --vcpus            虚拟机的CPU数量
 -v                 可视
 -c                 安装镜像的路径

4. user "xm list" to get the newly VM OS' ID and then use "xm destroy ID" to stop the specified VM.

5. Change the VM configuraiton file under /etc/xen directory (now is redhat73)
        Sample file can be seen in Xen-linux-cf.txt, or you can see example file under this directory.
 Mainly changed is acpi, apci (from 1 to 0), and VNC part, disk part to make sure the coming launching is smooth.

6. Use VNC tool to connect to the specified x-server.
   start the specified OS' installation step by step (just follow the orders)
   Or you can run "Virt-manager" in local machine for the specified VM host machine under its menu "Tools" on desktop.

+---------------------------------------------------------------------------------------------------------------------------------------------------
7. 如何切换光盘:
 xm block-attach
 xm block-detach
 ----------------------------------------------------------------------------------------------------------------------------------------------------
 Run Virtual Machine Manager.
 Select the virtual machine, then click Details.
 Click Hardware > Disk.
 Click CD-ROM.
 Specify the path to the physical CD reader, such as /dev/cdrom. If you are adding a virtual CD reader based on an ISO, specify the path to the ISO image file.
 Click OK to apply the changes.
 A new block device, such as /dev/xvdb, is added to the virtual machine.
 If the virtual machine is running Linux, complete the following:
 Open a terminal in the virtual machine and enter fdisk -l to verify that the device was properly added. You could also enter ls /sys/block to see all disks available to the virtual machine.
 The CD is recognized by the virtual machine as a virtual disk with a drive designation, for example,
 /dev/xvdb
 Enter the command to mount the CD or ISO image using its drive designation. For example, enter
 mount -o ro /dev/xvdb /cd1
 mounts the CD to a mount point named /cd1.
 The CD or ISO image file should be available to the virtual machine at the specified mount point.
 If the virtual machine is running Windows, reboot the virtual machine.
 Verify that the virtual CD reader appears in its My Computer section
 1.5.4 Adding Virtual CD Readers (Command Line Method)
 Make sure that the virtual machine is running and that the operating system has finished booting.
 Insert the CD into the physical CD reader or copy the ISO image to the host.
 In a terminal on the host, enter the appropriate command
 To set up an ISO image file, enter:
 xm block-attach vm_id file:/mycd.iso hdc:cdrom r
 where vm_id is the virtual machine ID, mycd.iso is the path to the ISO image file, and hdc is the drive designation presented to the virtual machine.
 If the virtual machine is paravirtual, replace the device designation with a vdb x device designation, such as
 xm block-attach vm_id file:/mycd.iso xvdb:cdrom r
 To set up a physical CD reader, enter:
 xm block-attach vm_id phy:/dev/cdrom hdc:cdrom r
 where vm_id is the virtual machine ID, dev/cdrom is the path to the physical CD reader, hdc is the physical drive designation to be presented to the virtual machine, and cdrom is the name you specify for the device.
 If the virtual machine is paravirtual, replace the hdc drive designation with a vdb x drive designation, such as:
 xm block-attach vm_id phy:/dev/cdrom xvdb:cdrom r
+--------------------------------------------------------------------------------------------------------------------------------------------------

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐