在Xen下安装Linux虚拟机全过程

+--------------------------------------------------------------------------------------------------------------------------------------------------------------
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
+--------------------------------------------------------------------------------------------------------------------------------------------------

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值