generated from cotes2020/chirpy-starter
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add post 2023-07-30-vms on m2 pro.md
Having virtual machines on Apple M2 Pro
- Loading branch information
Showing
2 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
--- | ||
title: Having virtual machines on Apple M2 Pro | ||
date: 2023-07-30 18:10:00 +/-0000 | ||
categories: [Virtualization, Fusion] | ||
tags: [devops] # TAG names should always be lowercase | ||
--- | ||
# Software development on virtual machines | ||
Software development (SD) requires virtual machines. First, writing applications in languages like Java makes them run on different operating systems (OSes). As it is always a **must** to test your code, it needs to be run on different OSes. The quickest and IMHO best way to do this is to have virtual machines. | ||
|
||
Second, fixing software issues sometimes required a certain OS or a certain desktop environment or additional software, that e.g. shows the bug. To set up the required environment, a virtual machine (VM) is ideal. | ||
|
||
What kind of host (that contains the virtual machines) you use, depends on the computer and OS you are working on. In my case, it's a Mac. There are different hosts available for the Mac. I prefer **VMware Fusion**, as I consider it to be the cleanest solution from a SD perspective. | ||
|
||
Installing a VM on Fusion is straight forward: | ||
- download the OS ISO and attach it to the VM CD drive | ||
- adjust the settings for the virtual hardware of the VM | ||
- power up the VM | ||
|
||
# Moving from x64 to arm64 | ||
Since the new **Apple Silicon** platform was released, I followed the development, as more and more guest OSes got compatible to ARM. | ||
A host on ARM requires the VM OS to be ARM as well. | ||
|
||
Windows for ARM is available meanwhile with a set of software, that makes it usable. But what about Linux distributions? | ||
VMware published a document, called _["The Unofficial Fusion 13 for Apple Silicon Companion Guide"](https://communities.vmware.com/t5/VMware-Fusion-Documents/The-Unofficial-Fusion-13-for-Apple-Silicon-Companion-Guide/ta-p/2939907)_, that describes, what does work on ARM now and what does not. Reading the guide disappointed me at first, as is states: | ||
```txt | ||
The Fusion Community is reporting that the Arch Linux ARM port has not been successfully | ||
installed on Fusion 13 on Apple Silicon. Unlike the Intel versions of Arch, the ARMv8 supported | ||
platforms and images for the Arch ARM port are either single-board computers (Raspberry | ||
Pi/ARM development boards) or Chromebooks. The installation images assume the hardware | ||
contains devices that are not provided by Fusion’s virtual hardware. For example, most of the | ||
supported boards have MicroSD cards, which Fusion 13 does not provide. | ||
``` | ||
That's bad, as Arch Linux is my favorite Linux distro. | ||
|
||
I acquired a brand-new Apple M2 Pro macBook, so it was time to get things working. Let's go!! | ||
|
||
![img-description](/assets/m2.png){: width="288" height="397" } | ||
_About this Mac_ | ||
|
||
# KUbuntu ARM | ||
Ubuntu (ARM) should be supported ootb. The Companion Guide lists the following arm64 releases as known to work on Fusion 13 (page 28): | ||
- 20.04.5 LTS (Focal Fossa) | ||
- 22.04.2 LTS (Jammy Jellyfish) | ||
- 22.10 (Kinetic Kudu) | ||
- 23.04 (Lunar Lobster) | ||
- 23.10 (Mantic Minotaur) | ||
|
||
Unfortunately, there is no "ready to go" ISO download for Ubuntu ARM with a pre-installed desktop environment. Instead, you'll have to find and download [Ubuntu Server for ARM](https://ubuntu.com/download/server/arm) on Ubuntus web pages, download that and modify your installation. | ||
|
||
## Required modifications for KUbuntu 23.04 | ||
This turns **Ubuntu Server** into an **Ubuntu Desktop**, as we know it. Reference: Companion Guide, page 30: | ||
|
||
### Install a desktop environment | ||
```shell | ||
sudo aptitutde install tasksel | ||
sudo tasksel | ||
``` | ||
Here you can select a desktop environment of your choice. I've chosen **KDE**. | ||
```shell | ||
sudo aptitutde install open-vm-tools-desktop | ||
sudo snap install snap-store | ||
``` | ||
### Change networking management to `NetworkManager` and update the boot files to reflect the changes | ||
```shell | ||
sudo systemctl disable systemd-networkd.service | ||
sudo systemctl mask systemd-networkd.service | ||
sudo systemctl stop systemd-networkd.service | ||
``` | ||
Make a back-up of the `/etc/netplan/*.yaml` files and configure the networking settings: | ||
```shell | ||
cd /etc/netplan | ||
sudo vi 00-installer-config.yaml | ||
``` | ||
Content of `00-installer-config.yaml` needs to be limited to: | ||
```yaml | ||
network: | ||
version: 2 | ||
renderer: NetworkManager | ||
``` | ||
Finish the modifications: | ||
|
||
```shell | ||
sudo netplan generate | ||
sudo systemctl unmask NetworkManager | ||
sudo systemctl enable NetworkManager | ||
sudo systemctl start NetworkManager | ||
sudo update-initramfs -u -k all | ||
sudo systemctl reboot | ||
``` | ||
|
||
You are done! | ||
|
||
# Arch Linux ARM | ||
As we've completed level 1, let's move on to level 2! | ||
|
||
The start is similar to Ubuntu above. We need to download a certain ISO. Luckily, the [Archboot Project](https://archboot.com/) provides one which is build with Arch Linux ARM. | ||
|
||
When booted, hitting ENTER starts an installation wizard, that is self-explanatory. Using the wizard has a couple of advantages, e.g. it installs and configures **Secure Boot** MOK support | ||
with Microsoft certificates supported by fedora's signed shim. This certainly saves a lot of time compared to doing this manually. | ||
## Some minor adjustments | ||
In the end, the wizard presents a list of configuration files, that can be modified, before the wizard is ended. The settings are ok, I only had to adjust some minor points. | ||
|
||
### Change the hostname | ||
I changed it to something meaningful. | ||
|
||
### locales | ||
The `/etc/locale.conf` looked like this: | ||
```plaintext | ||
LANG=de_DE.UTF-8 | ||
LC_COLLATE=C | ||
``` | ||
It only lacks an `LANGUAGE=de_DE` entry at its end. | ||
|
||
### mirrorlist is empty | ||
Surprisingly, the `/etc/pacman.d/mirrorlist` was empty, which prevents pacman from working of course. As I am located in Germany, I added the following: | ||
```plaintext | ||
Server = http://mirror.archlinuxarm.org/$arch/$repo | ||
Server = http://de.mirror.archlinuxarm.org/$arch/$repo | ||
``` | ||
|
||
### Full Arch Linux | ||
Once the wizard has finished, you are put back to the CLI. Before rebooting into your newly installed Arch Linux, the installation needs to be converted into a full Arch Linux, as the Archboot system is stripped down to minimal space usage: | ||
```shell | ||
update -full-system | ||
``` | ||
|
||
## Some rework | ||
As we are talking about virtualization, we need the `open-vm-tools` installed in our VM, to have a proper screen resolution for the VM and working copy & paste between the host and the VM. | ||
|
||
I was surprised, that the tools aren't available in the repro. So we have to compile them manually. Luckily, we are on Arch Linux, so this is no big deal. | ||
|
||
First, we acquire the source code, configured for Arch Linux: | ||
```shell | ||
git clone https://gitlab.archlinux.org/archlinux/packaging/packages/open-vm-tools.git | ||
``` | ||
This is the `PKGBUILD` and according service files for the **x86** architecture. Te only thing we need to change is to replace `arch=('x86_64')` with `arch=('aarch64')` in the `PKGBUILD` script. | ||
|
||
This enables us to compile the source code for ARM and install it afterwards: | ||
```shell | ||
makepkg -si | ||
``` | ||
|
||
That was it! | ||
|
||
# ARM is amazingly fast | ||
It was worth the effort. Check out [this screen recording](https://my.hidrive.com/lnk/6aiFHkLw) to see, how fast the VM is booting. | ||
|
||
# To do | ||
I'll have to find a way to keep manually compiled and installed software up to date. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.