[英]Virtualizing Ubuntu Linux on MacOS with Apple silicon (M1 chip)
As of March 2022 VirtualBox supports only x86 and AMD64/Intel64 and doesn't support ARM-based systems like Apple M1.截至 2022 年 3 月,VirtualBox 仅支持 x86 和 AMD64/Intel64,不支持 Apple M1 等基于 ARM 的系统。
Parallels Desktop for Mac supports Apple M1 chip but requires you to buy a license. Parallels Desktop for Mac 支持 Apple M1 芯片,但需要您购买许可证。
Are there an open source solution for running Ubuntu Linux virtual machine on MacOS with Apple silicon (M1 chip)?是否有在 MacOS 上使用 Apple 芯片(M1 芯片)运行 Ubuntu Linux 虚拟机的开源解决方案?
UTM is a full featured open source virtual machine host for MacOS that supports Apple silicon (M1 chip) - https://mac.getutm.app/ UTM 是 MacOS 的全功能开源虚拟机主机,支持 Apple 芯片(M1 芯片)- https://mac.getutm.app/
Follow the instructions to install Ubuntu on UTM - https://mac.getutm.app/gallery/ubuntu-20-04按照说明在 UTM 上安装 Ubuntu - https://mac.getutm.app/gallery/ubuntu-20-04
In my experience there are a few issues with UTM and there is an easier way to run an Ubuntu VM on MacOS.根据我的经验,UTM 存在一些问题,并且有一种更简单的方法可以在 MacOS 上运行 Ubuntu VM。
Multipass allows launching and managing Ubuntu VMs with a few CLI commands - https://multipass.run/ Multipass 允许使用一些 CLI 命令启动和管理 Ubuntu VM - https://multipass.run/
Download Multipass for MacOS - https://multipass.run/download/macos下载适用于 MacOS 的 Multipass - https://multipass.run/download/macos
Run the installer to install Multipass.运行安装程序以安装 Multipass。
Verify the installation:验证安装:
multipass --help
Launch Ubuntu 20.04 LTS VM called MyUbuntu (2 CPUs, 3GB RAM, 10GB HDD):启动名为 MyUbuntu 的 Ubuntu 20.04 LTS VM(2 个 CPU,3GB RAM,10GB HDD):
multipass launch --cpus 2 --mem 3G --disk 10G --name MyUbuntu 20.04
Mount a home directory to share data between your host and the VM instance:挂载主目录以在主机和 VM 实例之间共享数据:
multipass mount $HOME MyUbuntu:Home
Open a shell prompt on a VM instance:在 VM 实例上打开 shell 提示符:
multipass sh MyUbuntu
Inside the VM shell you are logged as ubuntu
user with passwordless sudo
.在 VM shell 中,您使用无密码sudo
登录为ubuntu
用户。
Interact with the instance, for example list mounted home directory:与实例交互,例如列出挂载的主目录:
ls ~/Home/
If you want to have GUI, install Ubuntu Desktop and xrdp:如果您想拥有 GUI,请安装 Ubuntu Desktop 和 xrdp:
sudo apt update
sudo apt install ubuntu-desktop xrdp
Set password for user ubuntu
设置用户ubuntu
的密码
sudo passwd ubuntu
Reboot the VM instance:重启虚拟机实例:
sudo reboot
Wait for the VM to restart.等待虚拟机重新启动。
Find the IP address (IPv4) of the VM:查找 VM 的 IP 地址 (IPv4):
multipass ls
Name State IPv4 Image
MyUbuntu Running 192.168.xx.xx Ubuntu 20.04 LTS
Or find the IP address using jq
in a single command:或者在单个命令中使用jq
查找 IP 地址:
multipass ls --format json | jq ".list[0].ipv4[0]"
Install Microsoft Remote Desktop - https://apps.apple.com/us/app/microsoft-remote-desktop/id1295203466?mt=12安装 Microsoft 远程桌面 - https://apps.apple.com/us/app/microsoft-remote-desktop/id1295203466?mt=12
Open Microsoft Remote Desktop.打开微软远程桌面。
Click Add PC
:点击Add PC
:
<VM instance IP address>
PC 名称: <VM instance IP address>
Click Add User Account...
:单击Add User Account...
:
<your password>
密码: <your password>
MyUbuntu
click ...
> Connect
MyUbuntu
点击...
> Connect
After entering the password enjoy Ubuntu Desktop:输入密码后享受Ubuntu桌面:
To delete the VM instance run:要删除 VM 实例,请运行:
multipass delete MyUbuntu
multipass purge
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.