Installing Gentoo Linux on a T2 Mac¶
Unmaintained distro
Gentoo is currently unmaintained. Due to lack of any maintainer, the Gentoo guides shall not be updated unless we get another maintainer. If you want to be a maintainer for Gentoo, contact the Discord.
Hardware Requirements¶
- Gentoo Minimal Installation ISO
- Requirements for this ISO: USB keyboard, mouse, ethernet adapter/Wi-Fi adapter
- If you don't meet the requirements, then you are required to use another distro's ISO. A recommended distro to use is Ubuntu, more specifically, T2-Ubuntu.
- Make sure to follow this guide along with this guide and the Gentoo Handbook starting at step 5
- USB-C to USB-A adapter
- USB Flash Drive
Install Procedure¶
-
Partition your SSD
- Open the Bootcamp installer and follow along until it requests for you to input a Windows ISO. This should clear space for a Linux partition because of removed APFS snapshots.
- Now open up Disk Utility. Make a partition with any format. The amount of space you allocate for this Linux partition will be final, so choose wisely.
-
Download a Gentoo ISO and flash it to your USB Flash Drive via Balena Etcher (you can also use dd)
-
Ensure that Secure Boot is disabled
- Follow the instructions from this article
- Once in the Startup Security Utility, set secure boot to no security and enable external boot.
-
Boot into the Live USB enviornment
- Plug in the USB Flash Drive into your computer
- Startup while holding the Option key, this will put you in the macOS Startup Manager
- Select the orange EFI Boot option and press enter to boot into it. (If you're using a Ubuntu Live environment, then make sure to select the orange EFI Boot option all the way to the right)
-
Follow the Gentoo Handbook
- Instead of making a new EFI partition for Gentoo, you should instead mount
/dev/nvme0n1p1
to/mnt/gentoo/boot/efi
- Make sure that you have deleted the partition you made ahead of time, or else you'll lose important data
- Instead of making a new EFI partition for Gentoo, you should instead mount
-
Continue through the Handbook until chapter "Configuring the kernel"
- In order to have the Linux Kernel support your device the most, you'll have to build from a modified Linux Kernel source tree.
- Git clone the t2linux kernel source tree to
/usr/src
- Make sure to git checkout the version you want. For example, if you want kernel version v5.16.17, you would checkout tag
t2-v5.16.17
.
- Make sure to git checkout the version you want. For example, if you want kernel version v5.16.17, you would checkout tag
- Run these commands to symlink the kernel to
/usr/src/linux
:
eselect kernel list # there should be one option that shows up eselect kernel set 1 ls -l /usr/src/linux # check if the symlink succeded
- Run these commands to grab apple-bce and apple-ibridge:
git clone https://github.com/t2linux/apple-bce-drv /usr/src/apple-bce git clone https://github.com/t2linux/apple-ib-drv /usr/src/apple-ibridge for i in apple-bce apple-ibridge; do mkdir /usr/src/linux/drivers/staging/$i cp -r /usr/src/$i/* /usr/src/linux/drivers/staging/$i/ done
- Run these commands in order to include apple-bce and apple-ibridge into the kernel source tree:
git clone https://github.com/Redecorating/mbp-16.1-linux-wifi /linux-patches cd /usr/src/linux for i in /linux-patches/*.patch; do echo $i patch -Np1 < $i done
- Git clone the
https://anongit.gentoo.org/git/proj/linux-patches.git
repo to a folder called/gentoo-patches
. This repo includes Gentoo patches for the kernel source tree usually included with thegentoo-sources
Portage package. - Apply them with a modified version of the commands used above.
- Copy the default config from the patches repo to the kernel source tree. If you do this, please make sure to set any filesystem drivers you want to use (like for ext4) to be built-in instead of being a module with
make menuconfig
- Build with
make all
. If you want to speed up the build process, add-j$(nproc)
-
Before finishing, if you want to connect to the internet later, now is a good time to install
NetworkManager
and optionallyiwd
. -
Continue through the Handbook until chapter "Configuring the bootloader"
- Install grub by using
emerge --ask --verbose sys-boot/grub
- Edit the config file
/etc/default/grub
with your favorite text editor of choice (i.e. vim or nano) - On the line with
GRUB_CMDLINE_LINUX
, append the following parameters:intel_iommu=on iommu=pt pcie_ports=compat
- Run
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB --no-nvram --removable
to install Grub. - Run
grub-mkconfig -o /boot/grub/grub.cfg
to make the config files for Grub
- Install grub by using
-
You're done! You should now be able to boot into Gentoo via the macOS Startup Manager
- If you confirmed that Gentoo does bootup no problem, then you can boot into macOS and follow the Wi-Fi guide