qemu教程_QEMU实例教程
qemu教程
Qemu is a very old virtualization technology used to virtualize system components and run operating systems on it. Before KVM and XEN QEMU was used heavily but it can not race with VMWARE or VIRTUAL PC. But with the KVM Qemu get superfast speed for computing by using hardware-based virtualization. QEMU acts as a hardware supplier and KVM is the CPU. KVM resides in Linux kernel and there is a little configuration for it. A virtualization configuration is made on the QEMU.
Qemu是一種非常古老的虛擬化技術(shù),用于虛擬化系統(tǒng)組件并在其上運行操??作系統(tǒng)。 在大量使用KVM和XEN QEMU之前,但它無法與VMWARE或VIRTUAL PC競爭。 但是借助KVM,Qemu可以通過使用基于硬件的虛擬化來獲得超快的計算速度。 QEMU充當硬件供應商,KVM是CPU。 KVM駐留在Linux內(nèi)核中,并且需要一些配置。 在QEMU上進行了虛擬化配置。
qemu-kvm或qemu或qemu-system-x86_64 (qemu-kvm or qemu or qemu-system-x86_64)
Qemu is a very old and big project which has different user bases and intersecting with different projects. Qemu is used in the Linux Kernel Virtualization project named KVM. So this project also provides Qemu with different command names but with more features. qemu-system-x86_64 is the binary or command for Qemu which is used to create 64-bit x86 VMs.
Qemu是一個非常古老而龐大的項目,它具有不同的用戶基礎,并且與不同的項目相交。 Qemu用于名為KVMLinux內(nèi)核虛擬化項目。 因此,該項目還為Qemu提供了不同的命令名稱,但具有更多功能。 qemu-system-x86_64是Qemu的二進制或命令,用于創(chuàng)建64位x86 VM。
安裝Qemu (Install Qemu)
We can install Qemu with the qemu package name for different distributions.
我們可以使用qemu軟件包名稱安裝Qemu,以用于不同的發(fā)行版。
為Ubuntu,Debian,Mint,Kali安裝Qemu (Install Qemu For Ubuntu, Debian, Mint, Kali)
We will use the following command.
我們將使用以下命令。
$ sudo apt install qemu Install Qemu For Ubuntu, Debian, Mint, Kali為Ubuntu,Debian,Mint,Kali安裝Qemu安裝Qemu For Fedora,CentOS,Red Hat (Install Qemu For Fedora, CentOS, Red Hat)
We will use both dnf and yum package managers according to distribution for rpm based install.
根據(jù)基于rpm的安裝,我們將根據(jù)分發(fā)使用dnf和yum軟件包管理器。
$ sudo dnf install qemuOR
要么
$ sudo yum install qemuqemu命令幫助 (qemu Command Help)
We can list short help information about the qemu like below by using -h option.
我們可以使用-h選項列出有關(guān)qemu簡短幫助信息,如下所示。
$ qemu-system-x86_64 -h Help幫幫我qemu命令語法(qemu Command Syntax)
Qemu syntax is the same as most of the Linux commands.
Qemu語法與大多數(shù)Linux命令相同。
qemu-system-x86_64 OPTIONS IMAGEOPTIONS are provided for VM options like Ram size, features, CPU, Graphics, etc.
OPTIONS提供了VM選項,如RAM大小,功能,CPU,顯卡等。
IMAGE is the file name of the disk for the VM.
IMAGE是VM磁盤的文件名。
下載云映像 (Download Cloud Images)
Popular Linux distributions like Fedora, CentOS, Debian, Ubuntu, RedHat provides virtual machine images in various formats like raw, qcow2, vmdk, etc. We will download the Fedora 25 cloud image from the following link which is provided by the Fedora Project. Download with wget like below.
流行Linux發(fā)行版(例如Fedora,CentOS,Debian,Ubuntu,RedHat)提供各種格式的虛擬機映像,例如raw,qcow2,vmdk等。我們將從以下Fedora項目提供的鏈接中下載Fedora 25云映像。 使用如下的wget下載。
$ wget http://www.nic.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/releases/30/Cloud/x86_64/images/Fedora-Cloud-Base-30-1.2.x86_64.qcow2 Download Cloud Images下載云映像設置Qemu VM的CPU和核心計數(shù)(Set CPU and Core Count for Qemu VM)
CPU is one of the most important parts of a system. We can set the CPU core count for the VM in Qemu. We will provide the -smp option which will enable multiple CPU cores with the core=2 value which will set the core count 2 in the given VM.
CPU是系統(tǒng)最重要的部分之一。 我們可以在Qemu中設置VM的CPU核心數(shù)。 我們將提供-smp選項,該選項將啟用具有core=2值的多個CPU內(nèi)核,這將在給定VM中設置內(nèi)核計數(shù)2。
$ qemu-system-x86_64 -smp cores=2從網(wǎng)絡啟動 (Boot From Network)
There are different ways to boot the VM system. Generally, images are used to boot but we can also boot from a network with the -boot order=nc option.
有多種啟動VM系統(tǒng)的方法。 通常,映像用于引導,但是我們也可以使用-boot -boot order=nc選項從網(wǎng)絡引導。
$ qemu-system-x86_64 -boot order=nc設置Qemu VM的RAM或內(nèi)存大小 (Set RAM or Memory Size For Qemu VM)
RAM is another important component of the VM. By default 128 MB RAM is set for the started VM. But we can also set the RAM size explicitly with the -m option which is the short form of the memory. We will also provide the size as MB where we will set 256 MB Ram in this example.
RAM是VM的另一個重要組件。 默認情況下,為啟動的VM設置128 MB RAM。 但是我們也可以使用-m選項顯式設置RAM的大小,這是內(nèi)存的簡稱。 我們還將以MB為單位提供大小,在此示例中,我們將設置256 MB Ram。
$ qemu-system-x86_64 -m 256 Set RAM or Memory Size設置RAM或內(nèi)存大小設置Qemu的VM名稱(Set VM Name For Qemu)
We have also the option to set a name for the VM. We can use the -name option and provide the VM name. The VM name will be displayed in the Window header of the Qemu. In this example, we will set the VM name as poftut.com.
我們還可以選擇為虛擬機設置名稱。 我們可以使用-name選項并提供VM名稱。 VM名稱將顯示在Qemu的Window標頭中。 在此示例中,我們將虛擬機名稱設置為poftut.com 。
$ qemu-system-x86_64 -name poftut.com為Qemu VM指定磁盤文件或映像 (Specify Disk File or Image For Qemu VM)
We can specify the disk/image file with the -drive option. This will provides us some ability to specify extra drivers related options. file is used to specify the file size. Also if is used to provide the driver or interface type for the disk.
我們可以使用-drive選項指定磁盤/映像文件。 這將使我們能夠指定額外的驅(qū)動程序相關(guān)選項。 file用于指定文件大小。 另外if用于提供磁盤的驅(qū)動程序或接口類型。
$ qemu-system-x86_64 -drive file=fedoraraw.qcow2,if=virtio禁用Qemu VM的GUI (Disable GUI for Qemu VM)
By default, the VM console will be provided as a GUI window. But we can also disable the console and only provide the terminal of the system with the -nographic option.
默認情況下,VM控制臺將作為GUI窗口提供。 但是我們也可以禁用控制臺,僅向系統(tǒng)終端提供-nographic選項。
$ qemu-system-x86_64 -nographic像virbr0一樣連接到虛擬交換機 (Connect To Virtual Switch Like virbr0)
By default started guests will be connected with no network and the only single interface will be attached. This is not a practical and useful feature for most of the situations. We can add a network interface and connect this interface into a bridge device that is running in a host operating system. In this example, we will connect our guest with a virtio type network interface into a virtual switch/bridge called virbr0?.
默認情況下,啟動的來賓系統(tǒng)將不連接網(wǎng)絡,并且僅連接單個接口。 在大多數(shù)情況下,這不是實用且有用的功能。 我們可以添加網(wǎng)絡接口,并將此接口連接到在主機操作系統(tǒng)中運行的橋接設備。 在此示例中,我們將通過virtio類型的網(wǎng)絡接口將客戶機連接到名為virbr0的虛擬交換機/橋中。
$ qemu-system-x86_64 -drive file=fedoraraw.qcow2,if=virtio -display none -net bridge,br=virbr0 -net nic,model=virtio對Qemu VM使用遠程磁盤映像 (Use Remote Disk Images For Qemu VM)
Generally, the best way to use VM disk images is locally but qemu also supports the remote disk images via network share with different protocols like SSH, etc. In this example, we will use a disk image named disk.img on the remote system via SSh by using file option.
通常,使用VM磁盤映像的最佳方法是在本地使用,但是qemu還通過與諸如SSH等不同協(xié)議的網(wǎng)絡共享來支持遠程磁盤映像。在本示例中,我們將通過以下disk.img在遠程系統(tǒng)上使用名為disk.img的磁盤映像:通過使用file選項的SSh。
$ qemu-system-x86_64 -drive file=ssh://[email?protected]/disk.img翻譯自: https://www.poftut.com/qemu-tutorial/
qemu教程
總結(jié)
以上是生活随笔為你收集整理的qemu教程_QEMU实例教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: maven下载依赖提示系统找不到指定路径
- 下一篇: 阿里云云计算专业考试线上视频培训课程(A