备忘录:在alpine上安装kvm
原文: https://wiki.alpinelinux.org/wiki/KVM
KVM is an open source virtualization solution in a kernel module. KVM can virtualize x86, PowerPC, and S390 guests.
Contents
[hide]Installing KVM
It is possible to install just qemu and libvirt for local management
sudo apk add qemu-system-x86_64 libvirt
but most users will probably want to manage it via a GUI with virt-manager (remotely or not).
sudo apk add libvirt-daemon dbus polkit
If you want to use other disk image formats than raw, you need qemu-img
sudo apk add qemu-img
Enable the KVM kernel module
sudo modprobe kvm-intel
or
sudo modprobe kvm-amd
Service start on boot
Set libvirtd and dbus to start on startup
sudo rc-update add libvirtd sudo rc-update add dbus
Networking
by defaults kvm use bridge to nat vm, if you want network with the default configuration, you need to load the tun module
sudo modprobe tun
but if you prefer bridging kvm over your ethernet interface, you need to make a bridge
Groups and user
Add your user to the follwing groups so you can mange the vms
sudo addgroup user libvirt
PolicyKit for Remote User
In order to use libvirtd to remotely control KVM over ssh PolicyKit needs a .pkla informing it that this is allowed. Write the following file to /etc/polkit-1/localauthority/50-local.d/50-libvirt-ssh-remote-access-policy.pkla
[Remote libvirt SSH access] Identity=unix-group:libvirt Action=org.libvirt.unix.manage ResultAny=yes ResultInactive=yes ResultActive=yes
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)