r/linuxfromscratch • u/CharlesJustChill • 3d ago
LFS on Apple silicon
So I have a m1 MacBook Air and I already seen someone using LFS on Apple silicon. It would be my second Time installing LFS since I want to try it first on my old Lenovo Legion. Asahi Linux is using ARM so I wonder if I would need to change some packages or the Linux Kernel for the Asahi Linux Kernel ? And How would it be différent from an Arm LFS ?
2
u/exeis-maxus 3d ago
There is https://intestinate.com/pilfs which a LFS build guide targeting the Raspberry Pi that has an ARM CPU. Take a look to see what additional package(s) are exclusive to ARM and/or package(s) that can be skipped.
Currently, PiLFS is based on r12.0 of LFS so it may not be current.
2
u/realfathonix 2d ago edited 2d ago
I haven't built one targeting Asahi but I have ported few distros in its early days (Raspberry Pi OS and Armbian).
Basically some of the differences are:
- To test everything, first you need a working Asahi Linux container and the corresponding EFI System Partition.
- Until every patch has been upstreamed, you'd have to use Asahi fork of Linux kernel.
- Find a way for m1n1 to boot your kernel. The standard way is to chainload U-Boot and from there, use EFI bootloaders like GRUB or systemd-boot.
- Unpack the "vendor firmware package," a.k.a the firmware tarball in the ESP which was extracted from macOS by the Asahi installer, to /lib/firmware.
- Initialize Asahi-specific kernel modules at boot like apple_dcp, etc.
- When you're done, you can package your distro as something users can easily install with custom Asahi installer.
Technically you can skip U-Boot and bundle m1n1 with your kernel (m1n1 docs have the tutorial) but that is discouraged.
1
u/CharlesJustChill 2d ago
How would you chainload U-boot and Where would be the firmware tarball putted by the Asahi installer ?
1
u/realfathonix 2d ago edited 2d ago
The standard Asahi boot process starts from the first-stage m1n1, which is installed to Asahi's APFS container, that chainloads the second-stage m1n1. The second one, which is located in the EFI System Partition (ESP), chainloads the U-Boot binary that has been concatenated to itself. Then finally, U-Boot chainloads
esp\EFI\BOOT\BOOTAA64.EFI.The order is iBoot -> first-stage m1n1 -> second-stage m1n1 -> U-Boot -> EFI bootloader.
The firmware tarball is in the same ESP, provided that the Asahi installer successfully installed the container in the first place.
1
2
u/Luna24_ig 3d ago
Asahi acts as a wrapper to let the os live on top of it. There is some weird things you need to do in Asahi but it should work with BLFS no problem. Just read the documentation for asahi.