设为首页 收藏本站
查看: 2009|回复: 0

[经验分享] 在Xen下安装Linux虚拟机全过程

[复制链接]

尚未签到

发表于 2016-1-9 15:58:43 | 显示全部楼层 |阅读模式
  +--------------------------------------------------------------------------------------------------------------------------------------------------------------
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
+--------------------------------------------------------------------------------------------------------------------------------------------------

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-162295-1-1.html 上篇帖子: Xen Dom0 下判断 DomU 的磁盘使用率 下篇帖子: How does Xen's Guest Domain wake up..?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表