Install Ubuntu 18.04 server with kvm virtualization

Resource preparation##

First, you must configure the KVM environment. As explained in detail above, the disk configuration is similar to using the qemu-img create -f qcow2 ubuntu.qcow2 100G command to create a virtual disk. The system image can be downloaded from the official website:

Ubuntu official website: https://ubuntu.com/
Ubuntu Server 18.04 LTS download: https://ubuntu.com/download/server/thank-you?country=HK&version=18.04.3&architecture=amd64

Verify your download

# Run this command in your terminal in the directory the iso was downloaded to verify the SHA256 checksum:

$ echo "b9beac143e36226aa8a0b03fc1cbb5921cff80123866e718aaeba4edb81cfa63 *ubuntu-18.04.3-live-server-amd64.iso"| shasum -a 256--check

# You should get the following output:

ubuntu-18.04.3-live-server-amd64.iso: OK

The network configuration continues to use the default default nat method of KVM.

installation##

$ virt-install \
- - virt-type=kvm \
- - name=nextcloud \
- - hvm \
- - vcpus=2 \
- - memory=2048 \
- - cdrom=/srv/kvm/nextcloud/ubuntu-18.04.3-live-server-amd64.iso \
- - disk path=/srv/kvm/nextcloud/nextcloud.qcow2,size=500,format=qcow2 \
- - network bridge=br0 \
- - graphics vnc,password=kvmwin10,listen=::,port=5911 \
- - autostart \
- - force

After the installation is successful, use the VNC viewer on any device with a desktop switch that can access the Internet to enter YourIp:5911 and enter the password kvmwin10, you can enter the virtual machine, and then continue the installation.

Virsh basic commands##

virsh list --all           #View all virtual machines that are running and not running
virsh list                 #View the running virtual machine
virsh dumpxml vm-name      #View the kvm virtual machine configuration file
virsh start vm-name        #Start the kvm virtual machine
virsh shutdown vm-name     #Normal shutdown

virsh destroy vm-name      #Abnormal shutdown, forcibly shut down the virtual machine (equivalent to the physical machine directly unplug the power)
virsh undefine vm-name     #Delete the vm configuration file

ls /etc/libvirt/qemu
# View the delete result, Centos-6.The configuration file of 6 is deleted, but the disk file will not be deleted

virsh define file-name.xml #Define the virtual machine according to the configuration file
virsh suspend vm-name      #Suspend, terminate
virsh resumed vm-name      #Resume a suspended virtual machine
virsh autostart vm-name    #Boot from the vm
virsh console <Virtual machine name>   #Connect to the virtual machine

- Install common parameter description##

--Name specifies the name of the virtual machine
-Memory allocate memory size.
-Vcpus allocates the number of CPU cores, the maximum is the same as the number of physical machine CPU cores
-Disk specifies the virtual machine image, size specifies the allocation size unit as G.
-Network network type. The default is used here. Generally, bridge should be used.
--Accelerate accelerate
--Cdrom specifies the installation image iso
-Vnc enables VNC remote management, generally the installation system must be enabled.
-Vncport specifies the VNC monitoring port, the default port is 5900, and the port cannot be repeated.
-Vnclisten specifies the VNC binding IP, the default binding 127.0.0.1, change to 0 here.0.0.0。
–os-type=linux,windows
–os-variant=rhel6

- - name specifies the name of the virtual machine
- - ram virtual machine memory size, in MB
- - vcpus allocates the number of CPU cores, the maximum is the same as the number of CPU cores of the physical machine
–-vnc Enable VNC remote management, generally the installation system must be enabled.
–-vncport specifies the VNC monitoring port, the default port is 5900, and the port cannot be repeated.
–-vnclisten specifies the VNC binding IP, the default binding is 127.0.0.1, change to 0 here.0.0.0。
- - network Virtual machine network configuration
 # The sub-option, bridge=br0 specifies the name of the bridged network card.

–os-type=linux,windows
–os-variant=rhel7.2--disk specifies the disk storage location of the virtual machine
 # size, the initial disk size, in GB.

- - location Specifies the path of the installation media, such as the file path of the CD image.
- - graphics graphics display configuration
 # There may be a lot of interactive operations during a fresh installation of a virtual machine, such as setting the language, initializing the root password, and so on.
 # The function of the graphics option is to configure the graphical interactive mode, which can be linked using vnc (a remote desktop software).
 # We use the command line to install this column, so here we need to set it to none, but through--extra-The args option specifies terminal information,
 # Only in this way can the interactive information during the installation process be output to the current console.
- - extra-args set different additional options according to different installation methods

Ubuntu fixed ip

Since the installation of Ubuntu is for the service of a certain application, it needs external network access, and the use of Nat mapping port requires a fixed IP.

First, you need to determine the network interface to be configured. You can use the ifconfig command to list all connected network interfaces in the system.

$ ifconfig -a

Ubuntu set static IP address

$ sudo vim /etc/netplan/xxxx.ymal

Modify this file:

network:
 ethernets:
 ens33:
  addresses:-192.168.122.3/24
  dhcp4:false
  gateway4:192.168.122.1
  nameservers:
  addresses:-192.168.122.1
  search:[]
 version:2

Description:

# ens33:Network interface name
# dhcp4:Receive the dhcp attribute of the IPV4 interface
# dhcp6:Receive the dhcp attribute of the IPV6 interface
# addresses:Static address sequence of the interface
# gateway4:IPV4 address of the default gateway
# Nameservers:DNS server address in,Number division

hint

If you accidentally touch in vim, you can use u to undo an operation.

u Undo the operation of the previous step
Ctrl+r Restore the operation that was undone in the previous step

Save the file and exit. Then use the following netplan command to apply the most recent network changes.

$ sudo netplan apply

Now verify again all available network interfaces, the ens33 Ethernet interface should now be connected to the local network and have an IP address.

ifconfig -a

At this point, the installation of the Ubuntu virtual machine is complete, just enter VNC to continue the subsequent operations.

Easter eggs##

Debian 8
virt-install \
- - name debian8 \
- - ram 1024 \
- - disk path=./debian8.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant generic \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://ftp.nl.debian.org/debian/dists/jessie/main/installer-amd64/' \
- - extra-args 'console=ttyS0,115200n8 serial'
Debian 7
virt-install \
- - name debian7 \
- - ram 1024 \
- - disk path=./debian7.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant debian7 \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://ftp.nl.debian.org/debian/dists/jessie/main/installer-amd64/' \
- - extra-args 'console=ttyS0,115200n8 serial'
Debian 6
virt-install \
- - name debian6 \
- - ram 1024 \
- - disk path=./debian6.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant debian6 \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://ftp.nl.debian.org/debian/dists/squeeze/main/installer-amd64/' \
- - extra-args 'console=ttyS0,115200n8 serial'
CentOS 7
virt-install \
- - name centos7 \
- - ram 1024 \
- - disk path=./centos7.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant centos7 \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://mirror.i3d.net/pub/centos/7/os/x86_64/' \
- - extra-args 'console=ttyS0,115200n8 serial'
CentOS 6
virt-install \
- - name centos6 \
- - ram 1024 \
- - disk path=./centos6.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant centos6 \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://mirror.i3d.net/pub/centos/6/os/x86_64/' \
- - extra-args 'console=ttyS0,115200n8 serial'
CentOS 5
virt-install \
- - name centos5 \
- - ram 1024 \
- - disk path=./centos5.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant centos5 \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://mirror.i3d.net/pub/centos/5/os/x86_64/' \
- - extra-args 'console=ttyS0,115200n8 serial'
Ubuntu 14.04
virt-install \
- - name ubuntu1404 \
- - ram 1024 \
- - disk path=./ubuntu1404.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant generic \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/' \
- - extra-args 'console=ttyS0,115200n8 serial'
Ubuntu 12.04
virt-install \
- - name ubuntu1204 \
- - ram 1024 \
- - disk path=./ubuntu1204.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant ubuntu12.04 \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://archive.ubuntu.com/ubuntu/dists/precise/main/installer-amd64/' \
- - extra-args 'console=ttyS0,115200n8 serial'
Ubuntu 10.04
virt-install \
- - name ubuntu1004 \
- - ram 1024 \
- - disk path=./ubuntu1004.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant ubuntu10.04 \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-amd64/' \
- - extra-args 'console=ttyS0,115200n8 serial'
OpenSUSE 13
virt-install \
- - name opensuse13 \
- - ram 1024 \
- - disk path=./opensuse13.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant generic \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://download.opensuse.org/distribution/13.2/repo/oss/' \
- - extra-args 'console=ttyS0,115200n8 serial'
OpenSUSE 12
virt-install \
- - name opensuse12 \
- - ram 1024 \
- - disk path=./opensuse12.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant generic \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://download.opensuse.org/distribution/12.3/repo/oss/' \
- - extra-args 'console=ttyS0,115200n8 serial'
OpenSUSE 11
virt-install \
- - name opensuse11 \
- - ram 1024 \
- - disk path=./opensuse11.qcow2,size=8 \
- - vcpus 1 \
- - os-type linux \
- - os-variant generic \
- - network bridge=virbr0 \
- - graphics none \
- - console pty,target_type=serial \
- - location 'http://download.opensuse.org/distribution/11.4/repo/oss/' \
- - extra-args 'console=ttyS0,115200n8 serial'
Generic ISO
Download an ISO file and give the filename to the --cdrom= parameter. This is used instead of--location. A VNC console is available on localhost, port 5999for you to use.

An example for FreeBSD 10. First download the ISO:

wget http://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/10.1/FreeBSD-10.1-RELEASE-amd64-dvd1.iso
Then start virt-install:

 virt-install \
- - name freebsd10 \
- - ram 1024 \
- - disk path=./freebsd10.qcow2,size=8 \
- - vcpus 1 \
- - os-type generic \
- - os-variant generic \
- - network bridge=virbr0 \
- - graphics vnc,port=5999 \
- - console pty,target_type=serial \
- - cdrom ./FreeBSD-10.1-RELEASE-amd64-dvd1.iso \
You need to start up a VNC client to do the installation.

references##

Author: Frytea
Title: kvm virtualization installation Ubuntu 18.04 server
Link: https://blog.frytea.com/archives/262/
Copyright: This work by TL-Song is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Recommended Posts

Install Ubuntu 18.04 server with kvm virtualization
ubuntu install nginx server
Install OpenSSL 1.0.2 on Ubuntu Server 14.04
Install Chef server workstation on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
Install Oracle 11gR2 on Ubuntu Server 12.4.0
Install Gnome and VNC on Ubuntu Server
How to install Bacula Server on Ubuntu 14.04
Install Ubuntu with Parallels Desktop under Mac
Install jetty in Ubuntu 18.04 Server, non-apt version
Ubuntu install ftp server and possible problems
How to install Zabbix on Ubuntu 16.04 Server
ubuntu18.04 install python2
ubuntu18.04 install docker
Ubuntu install guide
ubuntu install nodejs
ubuntu 16 install asp.net
ubuntu install leanote
ubuntu install Jenkins
docker install ubuntu
ubuntu install elasticsearch
Centos6.3 install KVM
ubuntu16.0.1 install pagoda
ubuntu18.04 install python
ubuntu 18.04 install teamviewer
ubuntu install sendmail
How to install Prometheus with Docker on Ubuntu 14.04
How to install Squid proxy server on Ubuntu 18.04
How to install python in ubuntu server environment
Install apache+PHP under Ubuntu
install vscode on ubuntu18
Install node.js under Ubuntu
Install mysql-pytho in Ubuntu
ubuntu install zsh terminal
Install Redis on Ubuntu
Install R4 on ubuntu20
Install nvtop on Ubuntu 18.04
Install postgresql-10 on Ubuntu 18.04
Install python3.6 under Ubuntu 16.04
Install docker on Ubuntu
Ubuntu18.04 install opencv 3.2.0 solution
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Install Docker on ubuntu18.04
Experience Ubuntu system CVM with free Tencent Cloud server
Install nodejs10 on Ubuntu16
Install mysql on Ubuntu 14.04
Ubuntu16.04 install Mongodb tutorial
Install Django on ubuntu
Install Pytorch+CUDA on Ubuntu 16.04
2018-09-11 Install arduino under Ubuntu
Install Python3 on Ubuntu 14.04
Ubuntu18.04 install Asterisk16.10 + FreePBX15.0
ubuntu16.04 install node.js, npm
Getting started with Ubuntu
Install rJava on Ubuntu18
Install JDK10+ on Ubuntu
pcduino ubuntu install os
Install JDK in Ubuntu19.10