简体   繁体   English

使用 Apple 芯片(M1 芯片)在 MacOS 上虚拟化 Ubuntu Linux

[英]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 UTM

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多通道

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

  • PC name: <VM instance IP address> PC 名称: <VM instance IP address>
  • Friendly name: MyUbuntu友好名称:MyUbuntu

编辑电脑

Click Add User Account... :单击Add User Account...

  • Username: ubuntu用户名:ubuntu
  • Password: <your password>密码: <your password>
  • Friendly name: ubuntu友好名称:ubuntu

添加用户帐户

MyUbuntu click ... > Connect MyUbuntu点击... > Connect

连接

After entering the password enjoy Ubuntu Desktop:输入密码后享受Ubuntu桌面:

Ubuntu xrdp

To delete the VM instance run:要删除 VM 实例,请运行:

multipass delete MyUbuntu
multipass purge

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用 Apple M1 芯片将 Flutter 安装到 macOS Big Sur - Not able to Install Flutter To macOS Big Sur with Apple M1 Chip 无法在带有 Apple M1 芯片的 macOS 12.2.1 上安装 orjson 3.3.0 - Unable to install orjson 3.3.0 on macOS 12.2.1 with Apple M1 chip 在具有 M1 芯片(基于 ARM 的 Apple Silicon)的 Mac 上安装早期版本的 Python(3.8 之前)失败 - Installation of earlier versions of Python (prior to 3.8) fails on Mac with M1 Chip (ARM based Apple Silicon) 尝试在 Mac Apple Silicon M1 芯片上卸载自制软件时出现小错误 - Minor error when trying to uninstall home-brew on Mac Apple Silicon M1 chip 如何在 Apple Silicon (M1) 上运行 CocoaPods - How to run CocoaPods on Apple Silicon (M1) 对修改后的二进制文件进行协同设计(Apple Silicon/M1) - Codesigning modified binaries (Apple Silicon/M1) Apple Silicon M1 Pro 上的 MPI 和 OpenMP - MPI and OpenMP on Apple Silicon M1 Pro 在 Intel 机器上为不同的 macOS 版本构建 Apple Silicon M1 二进制文件 - Build Apple Silicon M1 binary on an Intel machine for different macOS versions macOS Apple M1 上的 TensorFlow - Tensorflow on macOS Apple M1 带有运行 macOS Big Sur 的 Apple M1 芯片的 iMac 上的 miniconda 安装问题 - miniconda installation issue on iMac with Apple M1 chip running macOS Big Sur
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM