在一台 Mac Mini mid 2011上安装Ubuntu20.04并配置KVM环境, 过程也适用于其他版本的Mac主机.
I5 2415, 内存8G*2, 硬盘 SSD 500G + HDD 500G. 1Gbps网口. USB比较寒碜只有2.0, 不过只用于跑服务也不需要挂载移动硬盘, USB慢点没关系.
USTC镜像 http://mirrors.ustc.edu.cn/ubuntu-cdimage/releases/20.04.4/release/
通过Ubuntu系统的Disk打开U盘, 然后restore disk image, 选中下载的iso
检查是否支持KVM
grep -E -c "vmx|svm" /proc/cpuinfo
# or
more /proc/cpuinfo |grep vmx
more /proc/cpuinfo |grep svm
# or
sudo apt install cpu-checker
kvm-ok
安装KVM
sudo apt install qemu qemu-kvm libvirt-daemon bridge-utils virtinst
如果使用图形界面, 可以加上virt-manager
检查
$ lsmod | grep -i kvm
kvm_intel 282624 0
kvm 663552 1 kvm_intel
检查
# 是否运行
systemctl status libvirtd
# 是否开机自启动
systemctl is-enabled libvirtd
# 虚机列表, 刚安装应该是空的
virsh list
添加用户组(貌似可以不需要)
sudo usermod -aG libvirt $USER
sudo usermod -aG kvm $USER
默认的网卡设置是这样的
more /etc/netplan/00-installer-config.yaml
===============
# This is the network config written by 'subiquity'
network:
ethernets:
enp2s0f0:
dhcp4: true
version: 2
===============
需要修改为这样格式的设置, 根据自己的网络情况修改
# This is the network config written by 'subiquity'
network:
ethernets:
enp2s0f0:
dhcp4: no
dhcp6: no
version: 2
bridges:
br0:
interfaces: [enp2s0f0]
addresses: [192.168.61.152/24]
gateway4: 192.168.61.1
nameservers:
addresses: [192.168.61.1, 8.8.8.8]
应用
sudo netplan apply
加双硬盘时费了点时间, 看了些网上的教程, 都是要把主板完整取出, 实际上并不需要. 只需要将下半边的塑料挡板, 风扇和内存取下, 就能将两块硬盘放进去.
查看温度时, 会发现有些温度不正常, 下面标出的那两个温度94.0°C和98.0°C, 这是因为换的第三方硬盘没有Apple专用的温度检测, 所以温度数字不对.
$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +46.0°C (high = +86.0°C, crit = +100.0°C)
Core 0: +46.0°C (high = +86.0°C, crit = +100.0°C)
Core 1: +41.0°C (high = +86.0°C, crit = +100.0°C)
applesmc-isa-0300
Adapter: ISA adapter
Exhaust : 1800 RPM (min = 1800 RPM, max = 5500 RPM)
TA0P: +35.2°C # AMBIENT_TEMPERATURE
TA0p: +35.2°C # AMBIENT1_TEMPERATURE
TA1P: +37.0°C
TA1p: +37.0°C
TC0C: +38.0°C # CPU_DIE_CORE_TEMPERATURE Digital, CPU 0 Core
TC0D: +43.0°C # CPU_DIODE_TEMPERATURE Analog
TC0E: +40.2°C
TC0F: +41.2°C
TC0G: +94.0°C <---
TC0J: +1.0°C
TC0P: +40.2°C # CPU_PROXIMITY_TEMPERATURE
TC0c: +38.0°C
TC0d: +43.0°C
TC0p: +40.2°C
TC1C: +38.0°C # Core 1
TC1c: +38.0°C
TCGC: +38.0°C # CPU_PECI_CORE_TEMPERATURE, PECI GPU
TCGc: +38.0°C # PECI_GFX_TEMPERATURE
TCPG: +98.0°C <---
TCSC: +38.0°C # PECI_SA_TEMPERATURE, PECI SA
TCSc: +38.0°C
TCTD: -0.2°C
TCXC: +38.0°C # PECI CPU
TCXc: +38.0°C
TI0P: +42.2°C
TI0p: +42.2°C
TI1P: +39.8°C
TI1p: +39.8°C
TM0P: +42.5°C # Memory Slot Proximity
TM0S: +42.2°C # Memory Slot 1
TM0p: +42.5°C
TMBS: +50.0°C
TP0P: +40.5°C
TP0p: +40.5°C
TPCD: +44.0°C # Platform Controller Hub Die
TW0P: +34.5°C # AirPort Proximity
TW0p: +34.5°C
Tp0C: +36.2°C