Lima 初体验
Mr.Lee 2025-01-08 16:03:18 LinuxVMLima
Lima 初体验
# 安装 Lima
# 安装
❯ brew install lima
# 我本地环境是 aarch64 所以需要 安装 qemu 模拟 x86_64
❯ brew install qemu
# 检查
❯ qemu-system-x86_64 --version
QEMU emulator version 9.2.0
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
下载系统镜像的文件地址:
~/Library/Caches/lima/download/
启动虚拟机的文件地址:
~/.lima/
# 配置网络
文件路径:
~/.lima/_config/networks.yaml
# Path to socket_vmnet executable. Because socket_vmnet is invoked via sudo it should be
# installed where only root can modify/replace it. This means also none of the
# parent directories can be writable by the user.
#
# The varRun directory also must not be writable by the user because it will
# include the socket_vmnet pid file. Those will be terminated via sudo, so replacing
# the pid file would allow killing of arbitrary privileged processes. varRun
# however MUST be writable by the daemon user.
#
# None of the paths segments may be symlinks, why it has to be /private/var
# instead of /var etc.
paths:
# socketVMNet requires Lima >= 0.12 .
socketVMNet: "/opt/socket_vmnet/bin/socket_vmnet"
varRun: /private/var/run/lima
sudoers: /private/etc/sudoers.d/lima
group: everyone
networks:
user-v2:
mode: user-v2
gateway: 192.168.104.1
netmask: 255.255.255.0
# user-v2 network is experimental network mode which supports all functionalities of default usernet network and also allows vm -> vm communication.
# Doesn't support configuration of custom gateway; hardcoded to 192.168.5.0/24
shared:
mode: shared
gateway: 192.168.105.1
dhcpEnd: 192.168.105.254
netmask: 255.255.255.0
bridged:
mode: bridged
interface: en0
# bridged mode doesn't have a gateway; dhcp is managed by outside network
host:
mode: host
gateway: 10.20.0.1
dhcpEnd: 10.20.255.254
netmask: 255.255.0.0
mova:
mode: user-v2
gateway: 10.30.0.9
dhcpEnd: 10.30.255.254
netmask: 255.255.0.0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
mova
为自定义配置(自用的B级网络)
# 配置机器
os: Linux
vmType: "qemu"
# arch: "aarch64"
# arch: "x86_64"
images:
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
arch: "aarch64"
cpus: 4
memory: 4GiB
disk: 20GiB
networks:
- lima: mova
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 启动机器
❯ limactl create --name=master --arch=aarch64 ubuntu.yaml
❯ limactl start master
❯ limactl create --name=agent --arch=x86_64 ubuntu.yaml
❯ limactl start agent
1
2
3
4
2
3
4
在启动命令中指定, 实例名和CPU架构, 会更灵活一点
验证是否正确安装
# 官方模版
❯ limactl start --list-templates
almalinux-8
almalinux-9
almalinux
alpine-iso
alpine
apptainer-rootful
apptainer
archlinux
buildkit
centos-stream-10
centos-stream-9
centos-stream
debian-11
debian-12
debian
default
docker-rootful
docker
experimental/alsa
experimental/gentoo
experimental/opensuse-tumbleweed
experimental/rke2
experimental/u7s
experimental/vnc
experimental/wsl2
faasd
fedora
k3s
k8s
opensuse-leap
opensuse
oraclelinux-8
oraclelinux-9
oraclelinux
podman-rootful
podman
rocky-8
rocky-9
rocky
ubuntu-20.04
ubuntu-22.04
ubuntu-24.04
ubuntu-24.10
ubuntu-lts
ubuntu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
k8s 可以有呀