前言

換了人生中第一台macbook,但是卻是arm架構的,很多軟體還不是很支援,試了用qemu裝vm也試了rdp port-forwaring 回去,但前者不知道為什麼很耗電而後者很吃網路的狀況,最後!我找到了我的救星那就是Lima!

Lima-VM

是一個可以使用qemu模擬x86的開源軟體且非常輕量

Lima Github Repo

安裝方法

使用brew安裝

1
brew install lima

撰寫config檔案(yaml格式)

這邊直接上我的配置,新增檔案 ubuntu-22_04.yaml

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
# if using specific environment, add `arch` here to specify the architecture
arch: "x86_64"

# ubuntu-22.04.yaml example from lima official (here is all the same as the official example)
images:
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20221214/ubuntu-22.04-server-cloudimg-amd64.img"
arch: "x86_64"
digest: "sha256:b9a5a216901c34742ffe662b691db114269aaa25c90eb77f3ef4dd4f818e78a3"
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20221214/ubuntu-22.04-server-cloudimg-arm64.img"
arch: "aarch64"
digest: "sha256:b27163374c834c770e8db023fb21205529cea494257bf5ba866b8b1ae5969164"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
arch: "aarch64"

# mount the host's $HOME directory to the guest's /home/ubuntu
# if need writable, add `writable: true` under the mount
mounts:
- location: "~"
- location: "/tmp/lima"
writable: true

啟動Lima與配置

1
limactl start ubuntu-22_04.yaml --name ubuntu-22_04-amd64

看到 INFO[xxxx] READY. Run lima to open the shell 就代表成功了

進入shell

1
limactl shell ubuntu-22_04-amd64