Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install kvm under ubuntu16.04

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to install kvm under ubuntu16.04, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

1 check CPU virtualization support

Egrep 'svm | vmx' / proc/cpuinfo

Output indicates that cpu supports virtualization. Open inter-VT in BIOS.

2 Host Bridge Settin

Bridge does not support NetworkManager, so make sure that NetworkManager is turned off before doing the following

Cat / etc/NetworkManager/NetworkManager.conf

[main]

Plugins=ifupdown,keyfile,ofono

Dns=dnsmasq

[ifupdown]

Managed=false

Configure managed=false

Systemctl stop NetworkManager.service

Configure Brid

Install bridge-utils

Sudo apt-get install bridge-utils

Create a bridge

Brctl addbr br0

Brctl addif br0 eno1

Ifconfig eno1 0.0.0.0

Ifconfig br0 192.168.100.20/24

Add default Gateway

Route add-net 0.0.0.0 netmask 0.0.0.0 gw 192.168.100.1

To take effect permanently, configure as follows

Cat / etc/network/interfaces

# interfaces (5) file used by ifup (8) and ifdown (8)

Auto lo

Iface lo inet loopback

Auto br0

Iface br0 inet static

Bridge_ports eno1

Address 192.168.100.20

Netmask 255.255.255.0

Gateway 192.168.100.1

Bridge_stp off

Bridge_fd 0

Dns-nameservers 8.8.8.8

After restarting the network, view the network

Ifconfig

Br0 Link encap:Ethernet HWaddr 1c:b7:2c:aa:3d:89

Inet addr:192.168.100.20 Bcast:192.168.100.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:2007114 errors:0 dropped:3179 overruns:0 frame:0

TX packets:2547163 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:14447174274 (14.4 GB) TX bytes:11544824281 (11.5 GB)

Eno1 Link encap:Ethernet HWaddr 1c:b7:2c:aa:3d:89

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:11663933 errors:0 dropped:8384 overruns:0 frame:0

TX packets:2472983 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:16484732144 (16.4 GB) TX bytes:237579422 (237.5 MB)

Interrupt:20 Memory:f7f00000-f7f20000

Lo Link encap:Local Loopback

Inet addr:127.0.0.1 Mask:255.0.0.0

UP LOOPBACK RUNNING MTU:65536 Metric:1

RX packets:5895380 errors:0 dropped:0 overruns:0 frame:0

TX packets:5895380 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:9039764297 (9.0 GB) TX bytes:9039764297 (9.0 GB)

Virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00

Inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0

UP BROADCAST MULTICAST MTU:1500 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:0 (0.0B) TX bytes:0 (0.0B)

The above description sets the ok for the bridge

2 install the software package

Apt install kvm qemu qemu-kvm

Check whether kvm is installed by kvm-ok

Kvm-ok

INFO: / dev/kvm exists

KVM acceleration can be used

This means that it has been installed.

Apt install virtinst python-libvirt virt-viewer virt-manager (Management tool)

Apt install bridge-utils (Bridge Management)

3 create a virtual disk

Qemu-img create-f qcow2 / vm/kvm/instance-1.img 20g

Create a 20-gigabyte virtual disk named instance-001 and formatted as qcow2

4 install GuestOS

This article uses non-interactive text for installation, so do something about it

4.1 Mount iso image

Sudo mount / home/wangpei/iso/CentOS-7-x86_64-DVD-1708.iso / mnt/os-o loop

4.2 build ftp to allow anonymous login, and anonymous users' home directory points to / mnt

Apt instal vsftp

The vsftpd configuration is as follows:

Anonymous_enable=YES

Anon_root=/mnt

4.3 create a ks.cfg file under / mnt as follows:

Bootloader-location=mbr-driveorder=vda-append= "console=ttyS0 crashkernel=auto"

Clearpart-all-initlabel

Install

Url-- url= ftp://192.168.100.20/os

Lang en_US.UTF-8

Keyboard us

Network-onboot yes-device eth0-bootproto static-ip 192.168.100.115-netmask 255.255.255.0-gateway 192.168.100.1-ipv6 auto-nameserver 8.8.8.8

Rootpw-- iscrypted $6 $1Y6QA0TPid69iYMp$ygY0OFrw06w1oHuOC8D666fO5E9NNUMvCZuL7Uewcq8/Kz5RikrwJ9yOdouSQbTbeEIpzugqllTlSpIBVboQk0

# firewall-service=ssh

Firewall-disabled

Authconfig-enableshadow-passalgo=sha512

Selinux-disabled

Timezone-utc Asia/Shanghai

# zerombr

Autopart

Repo-name= "CentOS"-baseurl= ftp://192.168.100.20/os-cost=100

% packages

@ core

Net-tools

Vim

% end

Reboot

5 create a virtual machine

Sudo virt-install

-- connect qemu:///system

-- virt-type kvm

-- name instance-1

-- metadata description= "192.168.100.115"

-- ram 2048

-- vcpus 2

-- disk "/ vm/kvm/instance-1.img"

-- location ftp://192.168.100.20/os

-extra-arg= "ks= ftp://192.168.100.20/ks.cfg"

-- nographic

-x console=ttyS0

-- force

Wait until localhost login: it means the installation is ready.

Use virsh list-- all to view virtual machine instances

Virsh list-all

Id Name State

57 centos7 running

71 instance-1 running

78 instance-2 running

80 instance-3 running

84 instance-4 running

87 ubuntu16.04 running

97 instance-5 running

99 instance-6 running

The above is all the contents of the article "how to install kvm under ubuntu16.04". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report