HK1BOX安装Armbian KVM虚拟机

Title
HK1BOX安装Armbian KVM虚拟机
Date
May 14, 2023
 
notion image
 

安装HK1BOX Armbian

Armbian镜像:
F大佬的Armbian_20.10_Aml-s9xxx_buster_5.4.108-flippy-56+o.img

刷入镜像之后更改uEnv.txt

选择适合hk1box的dtb文件,然后把uboot.usb命名为uboot.ext防止绿屏
如果从TF卡启动,把uboot.sd重命名为uboot.ext[我的hk1box没启动成功 😅]
LINUX=/zImage INITRD=/uInitrd # 用于 HK1 BoX (S905X3 网卡工作于 1000M) FDT=/dtb/amlogic/meson-sm1-hk1box-vontar-x3.dtb # 用于 HK1 BoX (S905X3 网卡工作于 1000M) 超频 #FDT=/dtb/amlogic/meson-sm1-hk1box-vontar-x3-oc.dtb APPEND=root=LABEL=ROOTFS rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1

开机改密码:

插入U盘,会出现绿屏,之后开始引导,之后更改root密码,密码要大于8位,两次输入ctrl+c,取消新建用户

安装kvm虚拟机管理器:

sudo apt-get update sudo apt-get install -y gconf2 qemu-system-arm qemu-utils qemu-efi ipxe-qemu libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager seabios vgabios gir1.2-spiceclientgtk-3.0 xauth sudo apt-get update && apt-get install -y gconf2 qemu-system-arm qemu-utils qemu-efi ipxe-qemu libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager seabios vgabios gir1.2-spiceclientgtk-3.0 xauth fonts-wqy-microhei

安装x11中文字体,否则出现乱码

可以使用MobaXterm自带的xshell server,如果x11连接不成功,就重新开个ssh
apt install -y fonts-wqy-microhei

安装虚拟机配置:

openwrt_packit/qemu-aarch64-readme.md at master · unifreq/openwrt_packit
基于内核的虚拟机 Kernel-based Virtual Machine(KVM)是一种内建于 Linux® 中的开源虚拟化技术。具体而言,KVM 可帮助您将 Linux 转变为虚拟机监控程序,使主机计算机能够运行多个隔离的虚拟环境,即虚拟客户机或虚拟机(VM)。KVM 是 Linux 的一部分,Linux 也是 KVM 的一部分,Linux 有的 KVM 全都有。KVM 的某些特点让它成为了企业的首选虚拟机监控程序,比如在安全性、存储、硬件支持、内存管理、实时迁移、性能和可扩展性、调度和资源控制,以及更低延迟,更高优先级等方面均具有企业级的可靠性。 对于性能过剩的盒子,可以先安装 Armbian 系统,再安装 KVM 虚拟机实现多系统使用。其中 OpenWrt 系统的编译可以使用本仓库的 mk_qemu-aarch64_img.sh 脚本进行制作,更多系统如 Debian、Ubuntu、OpenSUSE、ArchLinux、Centos、Gentoo、KyLin、UOS 等可在相关网站查阅安装与使用说明。 以 Armbian/Debian/ubuntu 为例(其它操作系统请查询对应的命令)。首先验证物理机是否支持 kvm 虚拟化,如果结果如下图,那 kvm 支持就没问题,否则一般是物理机的内核没开启kvm支持(需要重新换个支持kvm的内核),或者是物理机根本就不支持 kvm!按照 arm 的官方文档,cortex-a53 以上的 cpu 都是支持 kvm 的。 ls -l /dev/kvm dmesg |
openwrt_packit/qemu-aarch64-readme.md at master · unifreq/openwrt_packit
配置KVM虚拟机的截图:
把虚拟机镜像上传到/var/lib/libvirt/images/
notion image
notion image
安装成功:
notion image
notion image

桥接网路设置(踩坑!!)

桥接临时设置,重启后设置消失,通过brtcl设置网桥

root@amlogic:~# brctl addbr br0 root@amlogic:~# brctl show bridge name bridge id STP enabled interfaces br0 8000.000000000000 no root@amlogic:~# brctl addif br0 eth0 root@amlogic:~# brctl show bridge name bridge id STP enabled interfaces br0 8000.0200002b0901 no eth0 root@amlogic:~# brctl addbr br0 #添加网桥br0 root@amlogic:~# brctl addif br0 eth0 #设置br0和eth0进行桥接 root@amlogic:~# brctl show #查看网桥 bridge name bridge id STP enabled interfaces br0 8000.0200002b0901 no eth0 vnet0 root@amlogic:~# ip addr add 192.168.0.13/24 dev br0 #br0设置静态IP root@amlogic:~# ip link set up br0 #开启br0网桥 root@amlogic:~# route add default gw 192.168.0.1 #添加静态路由
当虚拟机成功启动之后,即可关闭virt-manager图形窗口,虚拟机仍然在后台运行。第一次运行需要修改虚拟机的ip地址,可以用virsh命令连接到虚拟机的console:
virsh console openwrt
之后就进入openwrt的shell提示符,就如同在 ssh 或 ttyd 里一样,非常方便! 退出 virsh console 请按 ctrl + ] 快捷键, 即按下ctrl,再按]键
设置虚拟机网络:
编辑/etc/config/network
notion image
notion image

网路测试:

notion image
notion image
内网和外网都能ping通,设置成功

桥接永久设置,修改配置文件:

root@amlogic:~# cat /etc/network/interfaces.d/br0 #br0网桥设置 auto br0 iface br0 inet dhcp #br0 dhcp设置 bridge_ports eth0 #桥接eth0网络 bridge_stp off #关闭stp bridge_waitport 0 bridge_fd 0 root@amlogic:~# root@amlogic:~# cat /etc/network/interfaces #设置eth0接口网路 source /etc/network/interfaces.d/* # Wired adapter #1 allow-hotplug eth0 no-auto-down eth0 iface eth0 inet manual #把eth0的设置从dhcp变为manual,不配置ip地址 #iface eth0 inet static root@amlogic:~# brctl show #查看桥接设置 bridge name bridge id STP enabled interfaces #br0已经桥接成功 br0 8000.0200002b0901 no eth0 root@amlogic:~# systemctl restart networking.service #重启网络 重启网络之后,ssh会断掉,重启之后,就会重新连接 有时需要使用nmtui设置dns,否则连接不到外网
设置之后的网络接口:
notion image
notion image
网络测速截图:
notion image
notion image

虚拟机开机自启:

virsh autostart vm_name vi /etc/default/libvirt-guests # set on boot action ON_BOOT=start # set on shutdown action ON_SHUTDOWN=shutdown

总结:

hk1box的s905x3为四核cpu,可以分成两份分配给虚拟机,最多也就只能同时运行一个虚拟机,如果是其他的arm芯片,可以开的更多吧,一开始hk1box的网络桥接配置有问题,无法连接上外网,踩了不少坑,终于设置成功了,s905x3的性能实在不怎么高,实用性不高,只能玩玩,arm架构的cpu除了苹果的M芯片,其他的桌面cpu的性能实在是不够看的,在加上生态少的可怜,当个电视盒子不错,其他的有点勉强 😅。
 
sudo apt install kde-plasma-desktop sudo add-apt-repository ppa:papirus/papirus sudo apt update sudo apt install qt5-style-kvantum qt5-style-kvantum-themes sudo dpkg-reconfigure locales
sudo apt install ./软件包名  来安装。因为 apt 可以自动安装依赖而 dpkg 不能
apt-get install sassc optipng inkscape libxml2-utils libglib2.0-dev
firfox install:
sudo apt install firefox-esr apt install snapd sudo apt install snapd sudo snap install core You can install the Chromium browser on Debian 11 “Bullseye” using Snap packages. sudo snap install chromium
语言问题
echo en_US.UTF-8 UTF-8 > /etc/locale.gen && locale-gen
lc_messages to default locale no such file or directory
设置gtk mac主题 git clone https://github.com/vinceliuice/Mojave-gtk-theme.git && git clone https://github.com/vinceliuice/McMojave-circle.git && git clone https://github.com/vinceliuice/WhiteSur-icon-theme.git apt-get install sassc optipng inkscape libxml2-utils libglib2.0-dev
ibaspell15 libass9 libasyncns0 libatkmm-1.6-1v5 libatomic1 libatopology2 libatspi2.0-0 libattr1 libaudio2 libaudit-common libaudit1 libavahi-client3 libavahi-common-data libavahi-common3 libavahi-core7 sudo apt-get --only-upgrade install ibaspell15 libass9 libasyncns0 libatkmm-1.6-1v5 libatomic1 libatopology2 libatspi2.0-0 libattr1 libaudio2 libaudit-common libaudit1 libavahi-client3 libavahi-common-data libavahi-common3 libavahi-core7
 
Built with Potion.so