带有libvirt/svirt的启动QEMU KVM,但不使用命令行中的virt-andstall工具

发布于 2025-02-11 19:20:02 字数 86 浏览 0 评论 0原文

任何人都可以帮助我如何使用libvirt/svirt启动qemu kvm,但不使用命令行中的virt-install工具。

或使用Virsh工具

Can anyone help me on how to boot QEMU KVM with libvirt/sVirt but without using virt-install tool in command line.

or using virsh tool

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心的憧憬 2025-02-18 19:20:02

为了使用Virt-Antall,您需要安装以下内容:

yum install qemu-kvm qemu-img libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils tigervnc-server

然后,您可以启动守护程序:

systemctl start libvirtd

现在,下载要安装的操作系统,然后将其复制到下面显示的文件夹:

cp CentOS-7-x86_64-Everything-1708.iso /var/lib/libvirt/images/

最后,运行Virt-And-Astall。以下是脚本应该是什么样子的示例:

os="--os-type=linux --os-
variant=centos7.0"
location="--location=/var/lib/libvirt/images/CentOS-7-x86_64-Everything-1708.iso"
cpu="--vcpus 2"
ram="--ram 2048"
name="centos7"
disk="--disk /dev/mapper/centos_192- root,size=40"
type="--virt-type qemu"
network="--network network=default"
graphics="--graphics none"

virt-install $os $network $disk $location $cpu $ram $type $disk $graphics --name=$name

运行virt-install后,验证VM使用virsh运行:

virsh list
Id Name State
----------------------------------------------------
4 centos7 running

virt-install-onstall命令行选项

以下是一些命令行选项,但是这不是一个广泛的列表,因此我鼓励您进行一些研究,以充分利用此工具。

os="--os-type=linux --os-variant=centos7.0" --  

其中一些命令具有主要选项以及子选项。例如,如果键入OS-Type = Linux,则需要进一步指定-os-variant = Centos7.0。您可以通过键入Osinfo-Query OS来获取Virt-Antall支持的OS列表。

location="--location=/var/lib/libvirt/images/CentOS-7-x86_64-Everything-1708.iso" 

这是您复制包含要安装的操作系统的ISO映像文件的地方。

cpu="--vcpus 2"

CPU命令行选项使您可以指定分配给VM的VCPU的数量。在此示例中,我正在分配两个VCPU。

ram="--ram 2048" 

RAM命令行选项使您可以指定分配给VM的内存量。在此示例中,我分配了2,048 MB-或2 GB。

name="centos7" 

名称命令行选项使您可以为VM分配名称。在此示例中,我正在命名VM CentOS7。

disk="--disk /dev/mapper/centos_192-root,size=40" 

这是将VM安装的地方,并以Gogabytes的形式分配大小。这必须是磁盘分区,而不是安装点。键入DF -H列出磁盘分区。

type="--virt-type qemu" 

类型命令行使您可以选择要安装的VM类型。您可以使用KVM,QEMU,XEN或KQEMU。键入Virsh功能以列出所有选项。在此示例中,我正在使用QEMU。

network="--network network=default"

使用网络=默认设置使用默认桥设备设置桥梁网络。这是最简单的方法,但是还有其他选择。

graphics="--graphics none" 

图形命令行选项指定不应创建图形VNC或SPICE接口。将其用于启动安装,或者如果要使用TTYS0串行连接。

In order to use virt-install, you need to install the following:

yum install qemu-kvm qemu-img libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils tigervnc-server

Then, you can start the daemon:

systemctl start libvirtd

Now, download the OS you want to install, and then copy it to the folder shown below:

cp CentOS-7-x86_64-Everything-1708.iso /var/lib/libvirt/images/

Finally, run virt-install. Here is an example of what the script should look like:

os="--os-type=linux --os-
variant=centos7.0"
location="--location=/var/lib/libvirt/images/CentOS-7-x86_64-Everything-1708.iso"
cpu="--vcpus 2"
ram="--ram 2048"
name="centos7"
disk="--disk /dev/mapper/centos_192- root,size=40"
type="--virt-type qemu"
network="--network network=default"
graphics="--graphics none"

virt-install $os $network $disk $location $cpu $ram $type $disk $graphics --name=$name

After running virt-install, verify that the VM is running using virsh:

virsh list
Id Name State
----------------------------------------------------
4 centos7 running

Virt-install command-line options

Below are some command-line options, but this isn't an extensive list, so I encourage you to do some research in order to fully take advantage of this tool.

os="--os-type=linux --os-variant=centos7.0" --  

Some of these commands have main options, as well as sub options. For example, if you type os-type=linux, then you need to further specify --os-variant=centos7.0. You can get a list of OSes that virt-install supports by typing osinfo-query os.

location="--location=/var/lib/libvirt/images/CentOS-7-x86_64-Everything-1708.iso" 

This is where you've copied the ISO image file containing the OS you want to install.

cpu="--vcpus 2"

The CPU command-line option enables you to specify the number of vCPUs assigned to the VM. In this example, I'm assigning two vCPUs.

ram="--ram 2048" 

The RAM command-line option enables you to specify the amount of memory assigned to the VM. In this example, I'm assigning 2,048 MBs -- or 2 GBs.

name="centos7" 

The name command-line option enables you to assign a name to the VM. In this example, I'm naming the VM centos7.

disk="--disk /dev/mapper/centos_192-root,size=40" 

This is where the VM will be installed and the size, in gigabytes, to be allocated. This must be a disk partition and not a mount point. Type df -h to list disk partitions.

type="--virt-type qemu" 

The type command-line enables you to choose the type of VM you want to install. You can use KVM, QEMU, Xen or KQEMU. Type virsh capabilities to list all of the options. In this example, I'm using QEMU.

network="--network network=default"

Use network=default to set up bridge networking using the default bridge device. This is the easiest method, but there are other options.

graphics="--graphics none" 

The graphics command-line option specifies that no graphical VNC or SPICE interface should be created. Use this for a kickstart installation or if you want to use a ttyS0 serial connection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文