2,054 瀏覽數

ARM KVM (Ubuntu)

測試環境為 Ubuntu 16.04 ARM 處理器平台.

看了一下 KVM 官方網站的確有寫到支援 ARM 處理器,所以來試試看.
http://www.linux-kvm.org/page/Processor_support

ARM:
Virtualization support for ARM was initially added to ARMv7-A processors starting with Cortex-A15 and including Cortex-A7 and Cortex-A17.
ARMv8-A processors include support for virtualization.
Refer to http://www.arm.com/products/processors/cortex-a/ for more information.

關於 KVM 可以先參考一下.

KVM 只負責虛擬化的部份 HVM (hardware-assisted virtualization), VMM (Hypervisor) 的工作,至於模擬硬體裝置就交給了 QEMU.

先確定你的核心已經有支援 KVM

root@ubuntu:~# dmesg | grep -i kvm
KVM [1]: Hyp mode initialized successfully

KVM 不一定是使用模組的方式,也可能是採用核心的方式,檢查一下你的核心 config 檔案看是哪一種方式.

root@ubuntu:~# cat /boot/config-4.4.0-34-generic
root@ubuntu:~# lsmod | grep kvm

KVM 有些模擬需要 CPU 是支援,可以透過下面指令來觀察.

root@ubuntu:~# apt-get install cpu-checker
root@ubuntu:~# kvm-ok
INFO: /dev/kvm exists
KVM acceleration can NOT be used

所需套件為:

root@ubuntu:~# apt-get install qemu-kvm libvirt-bin virtinst virt-manager bridge-utils
  • qemu-kvm
    QEMU emulator
  • virtinst
    Command line tool to create virtual machines.
  • libvirt-bin
    Provides libvirtd daemon that manages virtual machines and controls hypervisor.
  • virt-manager
    GUI tool to create virtual machines.

libvirt 服務需要 start (立即) 與 enable (開機)

root@ubuntu:~# systemctl start libvirtd
root@ubuntu:~# systemctl enable libvirtd

我的 Ubuntu ARM 桌面起不來所以是透過 #SSH -X IP 將圖形介面轉移到另外一台 Linux 有桌面系統上.

root@ubuntu:~# apt-get install openssh-server

執行 virt-manager 需要有 root 的權限但 Ubuntu 限制 root 登入,所以需要修改一下 /etc/ssh/sshd_config

root@ubuntu:~# vim /etc/ssh/sshd_config
#PermitRootLogin prohibit-password
PermitRootLogin yes
root@ubuntu:~# systemctl restart sshd
root@ubuntu:~# ssh -X 172.16.0.100

如果遇到 SSH 錯誤訊息,需安裝 libglu1-mesa 套件.

couldn't open libgl.so.1 libgl.so.1 cannot open shared object file no such file or directory
root@ubuntu:~#apt-get install libglu1-mesa 

ARM KVM (IP:172.16.0.100)

 
[root@localhost ~]# virt-manager &

套件安裝完後執行 #virt-manager 遇到的第一個問題,只剩下 Import existing disk image 能用.

Connection: QEMU/KVM

Warning: Failed to setup UEFI for AArch64: Did not find any uefi binary path for arch 'aarch64'
Install options are limited

Choose how you would like to install the operating system
Local install media (ISO image or CDROM)
Network Install (HTTP, FTP, or NFS)
Network Boot (PXE)
Import existing disk image

arm_kvm01

應該是這些開機選項都是要有支援 EFI 的開機方式,但 QEMU 安裝完並沒有設定,需要自行設定.我們需要安裝套件 qemu-system-arm 與 qemu-efi .

root@ubuntu:~# apt-get install qemu-system-arm qemu-efi

接下來編輯 qemu.conf 的後面.

root@ubuntu:~# vim /etc/libvirt/qemu.conf
nvram = [
   "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd"
]

注意 [ ] 裡面不能有注解 #

重啟 libvirt 服務就可以了.

root@ubuntu:~# systemctl restart libvirtd
root@ubuntu:~# systemctl status libvirtd

並確認 libvirtd 的狀態是 Active: active (running)

雖然在安裝虛擬機器時列了很多種作業系統不過在 ARM KVM 下也只能模擬 ARM , Aarch64 ,也就該作業系統必須支援該種處理器才能使用.
支援哪一種平台 Machine type ,可以透過指令 #qemu-system-aarxh64 , #qemu-system-arm 來確認.

[root@localhost ~]# qemu-system-aarxh64 -machine help 
Supported machines are:
akita                Sharp SL-C1000 (Akita) PDA (PXA270)
borzoi               Sharp SL-C3100 (Borzoi) PDA (PXA270)
canon-a1100          Canon PowerShot A1100 IS
cheetah              Palm Tungsten|E aka. Cheetah PDA (OMAP310)
collie               Sharp SL-5500 (Collie) PDA (SA-1110)
connex               Gumstix Connex (PXA255)
cubieboard           cubietech cubieboard
highbank             Calxeda Highbank (ECX-1000)
imx25-pdk            ARM i.MX25 PDK board (ARM926)
integratorcp         ARM Integrator/CP (ARM926EJ-S)
kzm                  ARM KZM Emulation Baseboard (ARM1136)
lm3s6965evb          Stellaris LM3S6965EVB
lm3s811evb           Stellaris LM3S811EVB
mainstone            Mainstone II (PXA27x)
midway               Calxeda Midway (ECX-2000)
musicpal             Marvell 88w8618 / MusicPal (ARM926EJ-S)
n800                 Nokia N800 tablet aka. RX-34 (OMAP2420)
n810                 Nokia N810 tablet aka. RX-44 (OMAP2420)
netduino2            Netduino 2 Machine
none                 empty machine
nuri                 Samsung NURI board (Exynos4210)
realview-eb          ARM RealView Emulation Baseboard (ARM926EJ-S)
realview-eb-mpcore   ARM RealView Emulation Baseboard (ARM11MPCore)
realview-pb-a8       ARM RealView Platform Baseboard for Cortex-A8
realview-pbx-a9      ARM RealView Platform Baseboard Explore for Cortex-A9
smdkc210             Samsung SMDKC210 board (Exynos4210)
spitz                Sharp SL-C3000 (Spitz) PDA (PXA270)
sx1                  Siemens SX1 (OMAP310) V2
sx1-v1               Siemens SX1 (OMAP310) V1
terrier              Sharp SL-C3200 (Terrier) PDA (PXA270)
tosa                 Sharp SL-6000 (Tosa) PDA (PXA255)
verdex               Gumstix Verdex (PXA270)
versatileab          ARM Versatile/AB (ARM926EJ-S)
versatilepb          ARM Versatile/PB (ARM926EJ-S)
vexpress-a15         ARM Versatile Express for Cortex-A15
vexpress-a9          ARM Versatile Express for Cortex-A9
virt                 ARM Virtual Machine
xilinx-zynq-a9       Xilinx Zynq Platform Baseboard for Cortex-A9
z2                   Zipit Z2 (PXA27x)

現在就可以來安裝有支援 ARM 處理器的作業系統了.
arm_kvm02

網友的想法

  1. 自動參照通知: ARM KVM (CentOS) – Benjr.tw

發表迴響