Skip to content

Instantly share code, notes, and snippets.

@sebnyberg
Last active March 7, 2024 16:14
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebnyberg/ccf6b6c37df99a125bc2346977284622 to your computer and use it in GitHub Desktop.
Save sebnyberg/ccf6b6c37df99a125bc2346977284622 to your computer and use it in GitHub Desktop.
Ubuntu installation on iMac 2019 (MacOS 11 - Big Sur)

Ubuntu 20.04 with Wifi on iMac 2019 (MacOS 11 - Big Sur)

The purpose of this document is to summarize some of the things I had to figure out to successfully install Ubuntu on my iMac '19 27" 5K, a.k.a. iMac 19,1.

t2linux

From what I could find, iMac's do not have the t2 security chip. However, it does share hardware (and firmware) with contemporary Macbook Pros. For this reason, the t2linux.org website contains lots of helpful information about how to install Ubuntu on an iMac.

However, the guides on the t2linux website did not work for me when I ran it, so I had to mix and match some old pages from the wiki to make things work. Also, most issues are focused on Macbooks, not iMacs.

Downloading the ISO and installing Ubuntu

Download the iso from here.

The ISO can be burned to an USB with Balena Etcher.

Follow this Installation Guide.

Wifi setup

Once you've successfully booted into Ubuntu, Wifi will not be working. This is the tricky part.

Neither the new or old Wifi guide worked for me. I had to mix the two to get things working properly.

iMac (and Macbooks) use proprietary Wifi (and Bluetooth) drivers which are not available on Linux. So, you must copy these over to Ubuntu to get Wifi to work. Bluetooth appears to work out of the box for the ISO in the previous section.

Finding driver files and making them available on Ubuntu

Reboot your Mac, hold the Option key when the Mac logo appears, and select the macOS bootloader.

Once on Mac, run ioreg -l | grep RequestedFiles to list the Wifi drivers loaded by macOS. Here's some example output:

"RequestedFiles" = ({
    "Firmware"="C-4364s-B2/midway-X3.trx",
    "TxCap"="C-4364s-B2/midway-X3.txcb",
    "Regulatory"="C-4364s-B2/midway-X3.clmb",
    "NVRAM"="C-4364s-B2/P-midway-X3_M-HRPN_V-u__m-7.5.txt"
})

These files live in /usr/lib/firmware/wifi.

If you have a USB stick, simply copy over the files to the USB stick and reboot back into Ubuntu. I would recommend also putting the output of ioreg -l | grep RequestedFiles into a file on the USB as well.

If you do not have a USB stick, you can mount the EFI partition with sudo diskutil mount disk0s1 then move files to /Volumes/EFI. Be very careful not to break your EFI partition!

sudo diskutil mount disk0s1
tar -czvf /Volumes/EFI/wifi.tar.gz /usr/share/firmware/wifi
ioreg -l | grep RequestedFiles > /Volumes/EFI/ioreg-output.txt
sudo diskutil unmount disk0s1

Adding drivers to Ubuntu

Reboot back to Ubuntu (again by holding the Option key and selecting the Ubuntu bootloader).

Different Ubuntu kernels use different names for the expected drivers, and I found it easiest to keep reloading and checking dmesg | grep brcm output to find the right target names.

For example, in my Ubuntu installation, dmesg outputs

[ 2505.669998] brcmfmac 0000:03:00.0: Direct firmware load for brcm/brcmfmac4364b2-pcie.apple,midway.bin failed with error -2
[ 2505.670065] brcmfmac 0000:03:00.0: Direct firmware load for brcm/brcmfmac4364b2-pcie.bin failed with error -2

As you rename the macOS files and move them to the expected location, keep reloading with sudo modprobe -r brcmfmac && sudo modprobe brcmfmac and check output to see if you are making progress.

The table below should help you with renaming.

macOS Ubuntu
.trx .bin
.clmb .clm_blob
.txt .txt
.txcb .txcap_blob

For my iMac19,1, the requested files in ioreg were called midway-X3 etc.

If you used the EFI partition to transfer data, mount the partition and go to that directory:

sudo su
lsblk # check name of EFI partition, mine was nvme0n1p1
mkdir /mnt/efi
mount /dev/nvme0n1p1 /mnt/efi

Then copy the ioreg files into the locations requested in dmesg. This is the sequence of commands I ran to figure out what to do

# dmesg complained first about two .bin files:
# [...] brcm/brcmfmac4364b2-pcie.apple,midway.bin failed with error -2
# [...] brcm/brcmfmac4364b2-pcie.bin failed with error -2
dmesg | grep brcm

# cat ioreg output to find the right filename
cat /mnt/efi/ioreg-output.txt

# copy .trx to .bin
cp /mnt/efi/wifi-drivers/midway-X3.trx /usr/lib/firmware/brcm/brcmfmac4364b2-pcie.bin
cp /mnt/efi/wifi-drivers/midway-X3.trx /usr/lib/firmware/brcm/brcmfmac4364b2-pcie.apple,midway.bin
modprobe -r brcmfmac && sudo modprobe brcmfmac

# check dmesg again
# it complained about three new files:
# [...] brcm/brcmfmac4364b2-pcie.txt failed with error -2
# [...] brcm/brcmfmac4364b2-pcie.clm_blob failed with error -2
# [...] brcm/brcmfmac4364b2-pcie.txcap_blob failed with error -2
dmesg | grep brcm

cp /mnt/efi/wifi-drivers/midway-X3.clmb /usr/lib/firmware/brcm/brcmfmac4364b2-pcie.clm_blob
cp /mnt/efi/wifi-drivers/P-midway-X3_M-HRPN_V-u__m-7.5.txt /usr/lib/firmware/brcm/brcmfmac4364b2-pcie.txt
cp /mnt/efi/wifi-drivers/midway-X3.txcb /usr/lib/firmware/brcm/brcmfmac4364b2-pcie.txcap_blob

# reload once again
modprobe -r brcmfmac && sudo modprobe brcmfmac

# Success! Wifi is now available and dmesg shows successful output
# [ 2862.539050] brcmfmac: brcmf_c_process_txcap_blob: TxCap blob found, loading
# [ 2862.539868] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM4364/3 wl0: Jul 12 2021 19:26:30 version 9.30.464.0.32.5.76 FWID 01-45ccefcd
dmesg | grep brcm

Cleanup (EFI)

Remove the drivers from the EFI partition and unmount:

sudo rm -r /mnt/efi/wifi-drivers
sudo rm /mnt/efi/ioreg-output.txt
sudo unmount 
@whughes511
Copy link

whughes511 commented Jul 24, 2022

Hey! This worked in 2022 with my 2019 iMac19,1, with a caveat (see below). Wi-Fi is running, although my required files were a little different. I needed the midway-X0 firmware versions, so for those out there installing Linux on this Mac, be sure to run the script to find the required files on Mac. Also, just like the guide said, I had to modprobe after every file copy to get it running.

Fixed! For others with the issue below, see fix for Arch running Linux-t2 kernel after following sebnyberg’s guide above…

One issue I’m dealing with is not being able to connect to the 5ghz network; therefore, my Wi-Fi speeds are much less than I should be getting. I’m currently running different scenarios to see if I can help anyone else struggling with this… as small of a niche Linux group as we are on the 2019 iMac haha. Will keep you posted!

My next trial will be using iwd for the NetworkManager backend.

*iwd did actually solve the issue I ran into with Wi-Fi only connecting to 2.4Ghz band.

  1. I installed the iwd package on Arch.
  2. I followed t2linux.org blog post on using iwd for NetworkManager backend: https://t2linux.org/guides/wifi-bluetooth/
  3. The final step was to enable IPv6 support using arch wiki guide: https://wiki.archlinux.org/title/iwd#IPv6_support

After this, I’m getting full gigabit speeds on an iMac19,1 running Arch Plasma. Hope this helps!

Also, like sebnyberg, no sound, but a usb audio interface works great. Higher fidelity anyways…

I’m currently running Arch Linux with Plasma. This is really great work on @sebnyberg ’s part! You rock!

@sebnyberg
Copy link
Author

I'm happy this was helpful @whughes511 ! We are indeed a small clique. Ironically, I think the M1 will get better Linux support simply because it's interesting to work with.

I'm running Linux on my iMac and MBP, but it's like whack-a-mole. I've managed to get Wifi working on the MBP, but then my sound wasn't working. Or the other way around. The sound isn't working for my iMac, so I'm using an external soundcard.

In some ways, I think it makes the most sense just to buy an external sound/network card and give up on getting everything to work.

Anyway, happy hacking!

@phileagleson
Copy link

@sebnyberg I wanted to see if you've tried this https://github.com/davidjo/snd_hda_macbookpro for your sound issues? I was able to get this working successfully in Arch on my iMac 19,1. The main issue I've had is with GRUB not working properly because of the 5k resolution. I also don't believe there is a way to get 5k on linux yet due to the implementation Apple used in the driver. Finally, I wanted to ask if you know which graphics driver you are using? When I installed Arcolinux, the graphics work as expected but when I've tried a manual Arch install and manually install a graphics driver, I haven't been able to get it working.

@dominospots
Copy link

How do I get to the files? I did command G and pasted in /usr/lib/firmware/wifi but nothing showed up ?

@nastasuper
Copy link

Could you please message me? I have many issues on my iMac 2019. her_ricc@hotmail.com
Thanks!!

@sebnyberg
Copy link
Author

@nastasuper I wrote this guide mostly as personal record-keeping. If you have issues, I would recommend visiting the T2 Linux discord (https://t2linux.org/).

I also updated the document to say that this was on Big Sur (MacOS 11). I haven't tried this method since.

@ityulkanov
Copy link

ityulkanov commented Nov 8, 2023

If anyone happened to have a solution for the following error: brcmfmac 0000:03:00.0: Direct firmware load for brcm/brcmfmac4364b2-pcie.Apple Inc.-iMac19,1.bin failed with error -2 pls let me know. I've followed the above tutorial, but stuck with this error, trying to install the latest Ubuntu 22.04 on the iMac 27 2019 yr Sonoma 14.1, and doesn't seemed to be able to solve it for the last 6 hours(

@YE5446
Copy link

YE5446 commented Nov 26, 2023

Having the same issue. What is the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment