Skip to content

tranarchy/gentoo-apple-silicon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

Gentoo Linux for Apple Silicon

For the official guide click here

This guide uses the Apple Silicon Void Linux LiveCD and it uses asahi-sources instead of dist-kernel

UEFI environment

From macOS run the following in the terminal

curl https://alx.sh | sh

Alternatively you can read the code before running it

curl https://alx.sh > alx.sh
cat alx.sh
sh ./alx.sh

During the install process choose "UEFI environment only"

Warning

Follow the Asahi installer instructions carefully

LiveCD

As of writing this guide Gentoo does not offer an official aarch64 LiveCD that boots on Apple Silicon
We are going to use the official Void Linux apple Silicon LiveCD that you can download here

After downloading the LiveCD write it to an USB with dd

dd if=void-live-asahi-XXXXXXXX-base.iso of=/dev/sdX

Live environment

Once you booted into the LiveCD from the Asahi UEFI environment we can start the installation process

Internet

Use ip a to get the name of your network interface

wpa_passphrase <SSID> <PASSWORD> > wpa.conf
wpa_supplicant -i <NETWORK_INTERFACE> -c wpa.conf &

dhcpcd

Confirm that internet works with ping gentoo.org

sshd (optional)

If you want to do the installation from another machine you can enable sshd with

sv up sshd

If you can't login try enabling PasswordAuthentication and PermitRootLogin in the sshd config

sv restart sshd

Partitioning

The Asahi installer script previously allocated free space on your disk, we are going to use this free space for our root partition

cfdisk /dev/nvme0n1

Select the free space and create a new partition, write the changes then quit

Now you can format the new partition with whatever filesystem you want

mkfs.xfs /dev/nvme0n1pX

Caution

Do NOT touch any other partition

Deleting or formatting the wrong partition can render your system unusable

Acquiring the necessary tools

We will need xz and wget to download and extract the stage3 tarball
The Void live environment doesn't come with these tools by default so we are going to install them

xbps-install -Su
xbps-install xz wget

You could install links instead of wget if you want

Stage3

Create the /mnt/gentoo directory and mount your root partition

mkdir /mnt/gentoo
mount /dev/nvme0n1pX /mnt/gentoo
cd /mnt/gentoo

Download the desired arm64 stage3 tarball

wget https://distfiles.gentoo.org/releases/...

Extract it to /mnt/gentoo

tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner -C /mnt/gentoo

make.conf

vi /mnt/gentoo/etc/portage/make.conf

Modify your make.conf to your liking but make sure you apply the following changes

COMMON_FLAGS="-march=armv8.5-a+fp16+simd+crypto+i8mm -mtune=native -O2 -pipe"
RUSTFLAGS="-C target-cpu=native"
VIDEO_CARDS="asahi"

If you use GRUB

GRUB_PLATFORMS="efi-64"

For M2 chips use armv8.6-a and add bf16

Chroot

Now chroot into the Gentoo install, Void comes with xchroot so we are going to use that

xchroot /mnt/gentoo /bin/bash

Now we are going to mount our boot partition, we are going to use the vfat partition that the Asahi installer created

mount /dev/nvme0n1pX /boot

Important

From now on you can follow the handbook as you would on an amd64 machine

However stop at the "Configuring the Linux kernel" section

Asahi packages

As of writing this guide Gentoo offers some pacakges that are required for Apple Silicon to work, but not everything is included in the official repos

We are going to use the asahi-overlay, that is endorsed by Gentoo to get everything we need

emerge eselect-repository
eselect repository enable asahi
emerge --sync

emerge asahi-meta

Huge thanks to chadmed for creating asahi-overlay

Kernel and bootloader

Kernel

Apple Silicon needs linux-firwmare to work so emerge it

emerge linux-firmware

We are going to use dracut for generating our initramfs

emerge dracut

We will also need installkernel

Make sure you enable the dracut USE flag for it

emerge installkernel

The asahi-meta package we previously installed already pulled in asahi-sources

eselect kernel list
eselect kernel set x
cd /usr/src/linux

You can start configuring the kernel with

make rustavailable
make menuconfig

You can also use the .config from Void Linux as a base

Warning

make rustavailable enables rust specific kernel options

This is crucial on Apple Silicon since multiple drivers for it are written in rust

You can boot without rust enabled but you won't get GPU acceleration or audio for an example

make -j$(nproc)
make modules_install
make install

Apple firwmare and m1n1

Upgrade the firmware and m1n1

asahi-fwupdate
update-m1n1

Warning

Run update-m1n1 whenever m1n1, u-boot or asahi-sources updates

Bootloader

We will use GRUB as our bootloader

emerge grub
grub-install --boot-directory=/boot/ --efi-directory=/boot/ --removable
grub-mkconfig -o /boot/grub/grub.cfg

Note

Now you can return to the handbook and finish your install

Post install

Compiling amd64 only packages

You might want to emerge a package that is only available for amd64

You can try this by unmasking the amd64 or ~amd64 keyword for it and for it's amd64 only dependencies

vi /etc/portage/package.accept_keywords
gui-wm/hyprland ~amd64
other-hyprland/dependency ~amd64

It may or may not compile, but I got hyprland to work this way so it's worth a try

Steam

You can install Steam from the asahi-overlay, it works by running in a micorVM via muvm and FEX

emerge steam

Run steam-aarch64 to launch Steam

Currently the RootFS for FEX is mounted via systemd files, if you are using OpenRC you have to mount the RootFS manually and edit limits.conf click here for more info

About

Guide for installing Gentoo Linux on Apple Silicon

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages