Install KVM on Ubuntu 20

本文指导读者检查CPU和主板是否支持KVM,安装KVM及虚拟机,通过VNC连接CentOS和Ubuntu 18.04实例,演示了如何使用virsh连接虚拟机,重点介绍了在Windows上配置VNC的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. Check if CPU support KVM

cpuinfo show's 12 times of vmx|svm, it means CPU supports KVM

2. Check if board support KVM acceleration

 

 3. Install KVM 

4. Check daemon and network

5. Install virtual machine

 Firstly you need to get an image of OS. here is centOS7 as example.

6. Connet this virtual machine by VNC viewer

My VNC viewer is on my windows laptop. The VNC server is ip:port -- 'xx.xx.xx.xx:5911'

Here is VNC viewer window.

Select virtual disk to install as circled by red line.

After install, you need to reboot it.

7. Start the virtual machine

then you can use VNC viewer to connect to it again. 

8. Install Ubuntu18.04 KVM

Use Virtual Machine Manager could easily install a new virtual machine.

Firstly you could download Ubuntu18.04 image(ISO format).

Then open Virtual Machine Manager:

 Click '1' and you can see '2' pop out. And you select '3' and forward. 

Then you will need to select you downloaded ISO image and follow the instructions by Virtual Machine Manager. It's very easy.

 

The only thing you need be careful is, after Ubuntu18.04 installed, it requires reboot the system. And after you click the reboot, the system will notify you to remove the ISO image(CD room). So you need to remove the ISO image and then keep reboot.

9.Use virsh console connect the virtual machine

Firstly enable ttyS0 from virtual machine as following:

Then connect the virtual machine from host by virsh console:

 

 

### 设置和使用 KVM on Ubuntu Server #### 安装必要的软件包 为了在Ubuntu服务器上安装KVM,需要先更新系统的软件包列表并安装一些依赖项。可以运行以下命令来完成这一步骤[^3]: ```bash sudo apt-get update && sudo apt-get upgrade -y sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager -y ``` #### 配置网络桥接 为了让虚拟机能够访问外部网络,在宿主机上创建一个网桥是非常有帮助的。编辑`/etc/netplan/*.yaml`文件(具体名称可能不同),添加或修改如下内容以定义一个新的网桥接口br0: ```yaml network: version: 2 ethernets: enp3s0: dhcp4: no bridges: br0: interfaces: [enp3s0] dhcp4: yes parameters: stp: true forward-delay: 4 ``` 保存更改后执行`netplan apply`使新的配置生效。 #### 创建和管理虚拟机 通过图形界面工具Virt-Manager或者命令行工具virsh都可以方便地管理和启动新虚拟机实例。对于远程连接到服务器的情况来说,推荐使用SSH隧道配合VNC viewer的方式来进行图形化操作;而对于自动化脚本编写,则更适合采用后者。 如果想确认当前已有的虚拟机状态以及获取有关特定来宾的信息,比如FreeBSD VM 的 VNC 连接详情,可利用下面这条指令实现: ```bash $ sudo virsh list --all $ sudo virsh dumpxml freebsd | grep vnc ``` #### 启动服务并加入开机自启 确保libvirtd守护进程正在运行,并将其设置为随系统引导自动加载: ```bash sudo systemctl start libvirtd.service sudo systemctl enable libvirtd.service ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值