The Corellium development team has released a port of Ubuntu on a Mac Mini with an Apple M1 processor. Publications on the topic tell only about the success of the craftsmen, but do not disclose details. I decided on my own experience to check how to install and use. Ubuntu on Mac Mini, and described all the pitfalls that exist.
The authors of the Ubuntu port for Mac, Corellium, is engaged in virtualization on ARM64. They have the experience and desire to do such daring things.
Corellium previously worked on Project Sandcastle, which allows you to install Android OS on iPhone 7 thanks to the checkm8 vulnerability. Installing Android on iPhone hasn't been done since the iDroid Project and iPhone 3G. Like the iDroid Project, Project Sandcastle does not provide an OS for everyday use, but rather a massive open source Proof-of-Concept.Such projects are very time consuming from a development point of view, difficult to operate by ordinary users, and are unlikely to be used by a wide audience. Nevertheless, it is worth taking the opportunity to see everything with your own eyes.
What is the difficulty
In more detail, see the corresponding article on the Corellium blog.
It's no secret that Apple deviates from accepted standards and often uses its own solutions. To begin with, we note that macOS boots somewhat differently than operating systems of the Windows and * nix families. Apple devices use iBoot as a bootloader. It loads a Mach-O kernel that can be compressed, signed and stored in an IMG4 container.
More complex things start when it becomes necessary to start the rest of the processor cores. On conventional ARM64 processors, this is done through the Power State Coordination Interface (PSCI). But in M1, other cores are started at an offset, which is indicated in the corresponding Memory-mapped I / O (MMIO) register.
But even that is not all. Apple has created its own interrupt controller that does not conform to any ARM Generic Interrupt Controller (GIC) standard. Also, interrupts generated by the timer use a special type of FIQ (Fast Interrupt Request) requests instead of IRQs, which is not yet supported by the Linux kernel.
For the interaction of processor cores with each other, special interrupts are used - Inter-Processor Interrupt (IPI), which are also generated in M1 using FIQ. Thus, FIQ support is one of the most important things in this port.
Corellium employees had to develop their own driver for handling interrupts via FIQ, write a "wrapper" that would allow all the kernels to run, and solve a few more hardware problems. Only then were they able to launch the Ubuntu kernel .
However, launching the kernel is just the beginning. For successful operation, you need to connect input devices such as a keyboard and mouse. There are three ways: use the USB host in the M1 chip (for ThunderBolt / USB Type-C), use the xHCI host (for USB Type-A), or use Bluetooth.
Bluetooth runs on a non-standard PCIe-like protocol, so developing a custom kernel module for an unknown protocol could take a long time. Corellium decided to set up USB, and after a couple of days of work they were able to connect the input devices.
At the time of this writing, the Proof-of-Concept is already available, which you can try on your own. Please note that you can do all further actions solely at your own peril and risk.
Installing Ubuntu
To start using Ubuntu, we need the following:
- Mac with an Apple M1 processor (Mac Mini, Macbook Pro, and Macbook Air supported)
- a flash drive with a USB Type-C connector with a volume of 16 GB or more;
- USB keyboard and USB mouse.
As a flash drive, I used a 32GB Kingston DataTraveler microDuo 3C that supports USB Type-A and USB Type-C. Corellium's manual insists on using a Type-C stick , as booting from Type-A is not supported at the time of this writing. I connected the mouse and keyboard via USB Type-A.
There are also less obvious requirements. First, your Mac Mini must be running macOS 11.2 or higher. In older OS versions, the kmutil utility lacks the configure-boot command , which is required for correct kernel replacement.
You also need to untie the Mac from Find My Mac. The presence of the "binding" does not allow you to completely disable the security systems and execute all the necessary commands.
First of all, let's prepare an image for the flash drive. Download and then unpack the archive. The preparation should be performed in the Mac terminal on which we plan to run Ubuntu.
tar -xjvf ubuntu-20.10-preinstalled-desktop-arm64+raspi.img.bz2
Next, we expand the image to a USB flash drive:
sudo dd if=ubuntu-20.10-preinstalled-desktop-arm64+raspi.img of=/dev/rYOURUSBDISK bs=1m
Please note that it is necessary to specify the USB flash drive, and not the section on it. For example / dev / rdisk6 . Next, copy the drivers to Wi-Fi:
cp -RLav /usr/share/firmware/wifi /Volumes/system-boot
If you are using a wired Internet connection, you can prepare a USB flash drive on a computer running Linux.Next, connect the USB flash drive to the USB Type-C port and reboot into Recovery OS, known as 1TR (the One True Recovery), and open a terminal. On newer Macs, it works like this:
- Turn off your Mac;
- Hold the power button until the text "Loading launch parameters" appears;
- Select the "Options" option and click "Continue";
- In the top menu, open "Utilities" - "Terminal".
Please note that Recovery should not ask you to enter your OS password or Apple ID at startup. If he nevertheless asks, then you need to disable Find My Mac in macOS settings.Install the Ubuntu kernel:
bash -c "$(curl -fsSL https://downloads.corellium.info/linuxusbboot.sh)"
Script content
#!/bin/sh
bputil -d | grep "CustomerKC" | grep -v "absent"
KC=$?
if [ $KC -eq 1 ]
then
bputil -n -k -c -a -s
csrutil disable
csrutil authenticated-root disable
fi
curl https://downloads.corellium.info/linux.macho > linux.macho
kmutil configure-boot -c linux.macho -v /Volumes/Macintosh\ HD/
echo "Kernel installed. Please reboot";
This script checks boot policies (BootPolicy) and disables macOS integrity checking systems if needed. The script then loads the Linux kernel in Mach-O format into the root of the system drive and configures iBoot for the Linux kernel.
During the execution of the script, you will be prompted for a password to obtain macOS superuser rights. The commands you run will also alert you when the actions you take are significantly reducing the security of your Mac. But if you want to run Ubuntu, you have to take it for granted.
After the script completes, you can restart your Mac, then Ubuntu 20.04 will start downloading.
Experience of use
Starting Ubuntu for the first time won't be very fast. In the download logs, four or five services will "drop" and six more "hang". Ubuntu takes a relatively long time to boot: a few minutes. Moreover, at first, the responsiveness of the OS will be very low. Launching new applications, even without a graphical shell, can take minutes. This problem resolves itself shortly after loading.
As you can see, the image is based on Ubuntu for the Raspberry Pi . Therefore, the root and pi users on the system have the password raspberry. Unfortunately, it is impossible to make a nice and illustrative screenshot with the screenfetch output. The OS does not determine the processor model, so the output contains only faceless Unknown.
Lscpu output
Architecture: aarch64 CPU op-mode(s): 64-bit Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Thread(s) per core: 1 Core(s) per socket: 8 Socket(s): 1 Vendor ID: 0x61 Model: 1 Stepping: 0x1 CPU max MHz: 3204.0669 CPU min MHz: 600.0030 BogoMIPS: 48.00 Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; __user pointer sanitization Vulnerability Spectre v2: Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm ssbs sb dcpodp flagm2 frint
The fact that this is an OS image for an RPi will be noticeable when trying to install software from the package manager. He will try to install not only the software required by the administrator, but also update the OS with the creation of initramfs for the "raspberry". Such actions will lead to errors in the logs, despite the successful installation of the requested software.
As expected, the OS contains the minimum required set of drivers. Sound card, Bluetooth module and graphics accelerator are not supported. Most system utilities, such as lspci , lsusb, and lshw , provide very little information about the hardware.
Despite many limitations, I decided to run the sysbench benchmark.
Device | Calculations per second |
---|---|
Mac Mini (Ubuntu 20.10) | 838 |
Lenovo ThinkPad E14 (Ubuntu 20.04) | 483 |
Conclusion
Installing alternative operating systems on a Mac is always a technically challenging process. Apple's new M1 processors are a great challenge for enthusiasts.
Have you ever used Windows or Linux on a Mac?
Want to try the new Mac Mini at work? Let's give it to the test for free!
Just follow the link .