https://docs.01.org/clearlinux/latest/get-started/virtual-machine-install/kvm.html#install-qemu-kvm ====== 初始安裝 ====== 1,下載 -clear-34500-kvm.img.xz -OVMF.fd -OVMF_CODE.fd -OVMF_VARS.fd -start_qemu.sh \\ 2,unxz clear-34500-kvm.img.xz \\ 3,chmod u+x start_qemu.sh \\ 4,./start_qemu.sh clear-34500-kvm.img \\ 5,改好 ssh, X11forwarding. # systemctl edit sshd.socket [Socket] ListenStream= ListenStream=22 # systemctl daemon-reload # systemctl restart sshd.socket # vi /etc/ssh/sshd_config PermitRootLogin yes AllowTcpForwarding yes X11UseLocalhost yes X11DisplayOffset 10 X11Forwarding yes subsystem sftp /usr/libexec/sftp-server 在 host 可以看到 qemu 的 clearOS 的 sshd listen on 10022: 05-11 21:07 [root@kiosk430 ~]# netstat -anlpt |grep qemu tcp 0 0 0.0.0.0:10022 0.0.0.0:* LISTEN 458036/qemu-system- tcp 0 0 0.0.0.0:12375 0.0.0.0:* LISTEN 458036/qemu-system- 在 start-qemu.sh 中定義了 port 轉接: -netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}2375-:2375 \ 在 host 可以用 10022 連接 kvm 的 :22 [feuer@kiosk430 ClearOS]$ ssh -p 10022 root@127.0.0.1 在 vm 中使用 "poweroff" 將系統關機。\\ ---- ====== 圖形界面 ====== 修改 start_qemu.sh qemu-system-x86_64 \ -enable-kvm \ {UEFI_BIOS} \ -smp sockets=1,cpus=4,cores=2 -cpu host \ -m 4096 \ -vga qxl \ -nographic \ -spice port=5924,disable-ticketing \ -usb \ -device usb-tablet,bus=usb-bus.0 \ -drive file="$IMAGE",if=virtio,aio=threads,format=raw \ -netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}2375-:2375 \ -device virtio-net-pci,netdev=mynet0 \ -debugcon file:debug.log -global isa-debugcon.iobase=0x402 $@ 重新下載開機檔案: rm -v OVMF*.fd curl -O https://cdn.download.clearlinux.org/image/OVMF.fd curl -O https://cdn.download.clearlinux.org/image/OVMF_CODE.fd curl -O https://cdn.download.clearlinux.org/image/OVMF_VARS.fd 擴充 vm 硬碟空間: [feuer@kiosk430 ClearOS]$ qemu-img resize -f raw clear-34500-kvm.img +10G Image resized. 啟動 vm: ./start_qemu_spice.sh clear-34500-kvm.img 在 host 執行 "ip a" 可以看到 vm 的 ip: 6: virbr0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:25:d0:b7 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 執行 remote-viewer spice 來進入 vm : [feuer@kiosk430 ClearOS]$ remote-viewer spice://192.168.122.1:5924 ===== Resize the last partition of the virtual disk ===== 登入,在 vm 中執行:"swupd bundle-add storage-utils" {{:2021-05-11_22-20-55_的螢幕擷圖.png?direct&400|}} {{:2021-05-11_22-31-12_的螢幕擷圖.png?direct&400|}} {{:2021-05-11_22-33-53_的螢幕擷圖.png?direct&400|}} ===== Install GDM ===== 執行 "swupd bundle-add desktop-autostart" {{:2021-05-11_22-47-45_的螢幕擷圖.png?direct&400|}} 在 vm 中執行 "reboot" ,就會開啟 gdm 登入。 ----