官术网_书友最值得收藏!

How it works...

How to start a virtual machine with QEMU/KVM depends greatly on the type of image and how the partitions are structured inside that image.

We used two different image types with different partitioning schemes to demonstrate this concept.

In step 1, we used the qemu-system-x86_64 command to emulate a x86_64 CPU architecture, specifically we passed the -cpu Nehalem flag, emulating the Nehalem CPU model. We passed the IP address of our host as a parameter to the -vnc flag. This starts a VNC server in the VM so that we can later use a VNC client to connect to the QEMU instance. We specified the amount of memory to be allocated to the instance, in this case, 1GB with the -m flag. We instructed QEMU that we are going to use a raw image with the format=raw option and the name and location of the actual image with the file=debian.img parameter.

Recall that this raw image contains two partitions with the second partition containing the root filesystem where the bootloader is located. This is very important to remember because we need to specify from what partition index the guest OS should load. We do that with the index=2 flag. Finally, we pass the -daemonize parameter to background the QEMU process.

In step 4, we started another QEMU instance, this time using the qcow2 CentOS image we downloaded earlier. We did not have to specify from what partition we need to boot from this this time because most prebuilt images use the first partition, or only have one partition. We also used the -hda flag instead of the -drive parameter, just to demonstrate that both options can be used with the same result. The -hda flag tells QEMU the first disk for the instance should be loaded from the filename that follows it.

主站蜘蛛池模板: 陆良县| 温州市| 团风县| 策勒县| 台中县| 德化县| 马边| 从江县| 闵行区| 吴旗县| 葫芦岛市| 白朗县| 新巴尔虎左旗| 淳化县| 大方县| 科尔| 嘉善县| 宁明县| 科技| 柘荣县| 资源县| 磴口县| 汤原县| 吉安市| 招远市| 柘城县| 类乌齐县| 清水河县| 泸水县| 思茅市| 渭源县| 准格尔旗| 藁城市| 乌拉特后旗| 舞钢市| 始兴县| 公主岭市| 盘山县| 循化| 大埔区| 蒙自县|