SST Lab Dokuwiki Header header picture

ユーザ用ツール

サイト用ツール


linux:kvm_install

KVMのインストール

Step 1: 仮想化機能の有無の確認

$ egrep -c '(vmx|svm)' /proc/cpuinfo
12
$ sudo apt install cpu-checker
$ sudo kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
$ 

Step 2: パッケージのインストール

$ sudo apt install -y qemu 
$ sudo apt install -y qemu-kvm 
$ sudo apt install -y libvirt-daemon 
$ sudo apt install -y libvirt-clients 
$ sudo apt install -y bridge-utils 
$ sudo apt install -y virt-manager
$ virsh list
 Id   Name   State
--------------------
 
$ qemu-img
qemu-img: Not enough arguments
Try 'qemu-img --help' for more information
$ kvm
Unable to init server: Could not connect: Connection refused
Could not access KVM kernel module: Permission denied
qemu-system-x86_64: failed to initialize KVM: Permission denied
$ 
$ sudo systemctl status libvirtd
● libvirtd.service - Virtualization daemon
     Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor pres>
     Active: active (running) since Wed 2021-02-24 02:09:55 UTC; 4min 5s ago
TriggeredBy: ● libvirtd.socket
             ● libvirtd-admin.socket
             ● libvirtd-ro.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
   Main PID: 7856 (libvirtd)
      Tasks: 19 (limit: 32768)
     Memory: 19.3M
     CGroup: /system.slice/libvirtd.service
             ├─7856 /usr/sbin/libvirtd
             ├─8267 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defa>
             └─8268 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defa>
 
Feb 24 02:09:56 sstw dnsmasq[8267]: compile time options: IPv6 GNU-getopt DBus >
Feb 24 02:09:56 sstw dnsmasq-dhcp[8267]: DHCP, IP range 192.168.122.2 -- 192.16>
Feb 24 02:09:56 sstw dnsmasq-dhcp[8267]: DHCP, sockets bound exclusively to int>
Feb 24 02:09:56 sstw dnsmasq[8267]: reading /etc/resolv.conf
Feb 24 02:09:56 sstw dnsmasq[8267]: using nameserver 127.0.0.53#53
Feb 24 02:09:56 sstw dnsmasq[8267]: read /etc/hosts - 7 addresses
Feb 24 02:09:56 sstw dnsmasq[8267]: read /var/lib/libvirt/dnsmasq/default.addnh>
Feb 24 02:09:56 sstw dnsmasq-dhcp[8267]: read /var/lib/libvirt/dnsmasq/default.>
Feb 24 02:09:56 sstw dnsmasq[8267]: reading /etc/resolv.conf
Feb 24 02:09:56 sstw dnsmasq[8267]: using nameserver 127.0.0.53#53
$ 
$ lsmod | grep -i kvm
kvm_intel             282624  0
kvm                   663552  1 kvm_intel
$ 

Step 3: ブリッジの作成

$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp3s0:
      addresses:
      - 192.168.10.4/24
      gateway4: 192.168.10.254
      nameservers:
        addresses:
        - 192.168.10.1
        search:
        - ee.ous.ac.jp
  version: 2
$ 
$ sudo cp 00-installer-config.yaml 00-installer-config.yaml.org
$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
# Added br0 and moved entries from enp3s0 to br0
network:
  ethernets:
    enp3s0:
      dhcp4: no
      dhcp6: no
  version: 2
  bridges:
    br0:
      interfaces:
      - enp3s0
      addresses:
      - 192.168.10.4/24
      gateway4: 192.168.10.254
      nameservers:
        addresses:
        - 192.168.10.1
        search:
        - ee.ous.ac.jp
$
$ sudo netplan apply
$ sudo networkctl status 
●          State: routable                        
         Address: 192.168.122.1 on virbr0         
                  192.168.10.4 on br0             
                  fe80::84fe:94ff:fede:181f on br0
         Gateway: 192.168.10.254 on br0           
             DNS: 192.168.10.1                    
  Search Domains: ee.ous.ac.jp                    
 
Feb 24 04:06:09 sstw systemd[1]: systemd-networkd.service: Succeeded.
Feb 24 04:06:09 sstw systemd[1]: Starting Network Service...
Feb 24 04:06:09 sstw systemd-networkd[8895]: br0: netdev ready
Feb 24 04:06:09 sstw systemd-networkd[8895]: enp3s0: Gained IPv6LL
Feb 24 04:06:09 sstw systemd-networkd[8895]: Enumeration completed
Feb 24 04:06:09 sstw systemd[1]: Started Network Service.
Feb 24 04:06:09 sstw systemd-networkd[8895]: br0: IPv6 successfully enabled
Feb 24 04:06:09 sstw systemd-networkd[8895]: br0: Link UP
Feb 24 04:06:09 sstw systemd-networkd[8895]: br0: Gained carrier
Feb 24 04:06:10 sstw systemd-networkd[8895]: br0: Gained IPv6LL
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
    link/ether 2c:f0:5d:b4:fc:9d brd ff:ff:ff:ff:ff:ff
3: wlo1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 8c:55:4a:9a:49:fd brd ff:ff:ff:ff:ff:ff
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:df:4b:30 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:df:4b:30 brd ff:ff:ff:ff:ff:ff
6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 2c:f0:5d:b4:fc:9d brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.4/24 brd 192.168.10.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::84fe:94ff:fede:181f/64 scope link 
       valid_lft forever preferred_lft forever
$ sudo networkctl status br0
● 6: br0                                                                 
               Link File: /usr/lib/systemd/network/99-default.link       
            Network File: /run/systemd/network/10-netplan-br0.network    
                    Type: bridge                                         
                   State: routable (configured)
                  Driver: bridge                                         
              HW Address: 2c:f0:5d:b4:fc:9d (Micro-Star INTL CO., LTD.)  
                     MTU: 1500 (min: 68, max: 65535)                     
           Forward Delay: 15s                                            
              Hello Time: 2s                                             
                 Max Age: 20s                                            
             Ageing Time: 5min                                           
                Priority: 32768                                          
                     STP: no                                             
  Multicast IGMP Version: 2                                              
    Queue Length (Tx/Rx): 1/1                                            
                 Address: 192.168.10.4                                   
                          fe80::84fe:94ff:fede:181f                      
                 Gateway: 192.168.10.254                                 
                     DNS: 192.168.10.1                                   
          Search Domains: ee.ous.ac.jp                                   
 
Feb 24 04:06:09 sstw systemd-udevd[8897]: br0: Could not generate persistent MA>
Feb 24 04:06:09 sstw systemd-networkd[8895]: br0: netdev ready
Feb 24 04:06:09 sstw systemd-networkd[8895]: br0: IPv6 successfully enabled
Feb 24 04:06:09 sstw systemd-networkd[8895]: br0: Link UP
Feb 24 04:06:09 sstw systemd-networkd[8895]: br0: Gained carrier
Feb 24 04:06:10 sstw systemd-networkd[8895]: br0: Gained IPv6LL
$
linux/kvm_install.txt · 最終更新: 2022/08/23 13:34 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki