centos7 使用virt-install安装虚拟机

2025-09-25 02:00:58

1、首先查看你的服务器的cpu是否支持虚拟化。

#egrep "svm|vmx" /proc/cpuinfo |uniq 

centos7 使用virt-install安装虚拟机

2、有输出信息说明支持虚拟化。

然后安装libvitd

#yum  -y install libvirt

安装完成后,查看是否安装成功。

#yum list installed  libvirt

centos7 使用virt-install安装虚拟机

3、安装qemu-kvm

#yum -y  install  qemu-kvm

安装完成后,查看是否安装成功。

centos7 使用virt-install安装虚拟机

4、启动libvitd服务

#systemctl  enable  libvirtd

#systemctl  start   libvirtd

centos7 使用virt-install安装虚拟机

5、查看libvirt 状态。

#systemctl status  libvirtd

启动成功。

centos7 使用virt-install安装虚拟机

6、执行命令安装虚拟机。

virt-install --connect qemu:///system -n $name -r $mem --vcpus=$cores --disk path=/root/img/$name.img,cache=writeback,size=$size -c /root/iso/CentOS-7-x86_64-Minimal-1511.iso --vnc --vnclisten=0.0.0.0  --vncport=$port --noautoconsole --os-type linux --accelerate  --network bridge=bridge -d

其中$name 是你的虚拟机名称

$mem 是内存大小

$cores 是cpu设置

$name.img 是镜像名字

$size 是系统盘大小

$port是vnc端口

设置为你自己的就可以了。

bridge是桥接网卡名字。

-d是debug输出信息。

centos7 使用virt-install安装虚拟机

7、创建完成直接可以使用vnc链接,进行安装了。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢