chadmed / asahi-gentoosupport

Gentoo support files for Apple Silicon devices
61 stars 16 forks source link

Unbootable machine after I install from liveCD #1

Closed luna-xenia closed 2 years ago

luna-xenia commented 2 years ago

I have got to the stage where I have chrooted into my new gentoo rootFS and have set most things up. When I ran the install.sh script, everything seemed to go as normal, then I continued setting up my system by installing wpa_supplicant as well as setting up my /etc/fstab like so (but with tabs not spaces):

/dev/nvme0n1p4 /boot/efi vfat noauto 0 2
/dev/nvme0n1p5 / ext4 noatime 0 1

When I reboot and press enter on Gentoo, I see the loading linux and loading initial RAM disk at the top of my screen, as well as something about an EFI boot stub near the middle of my screen. Nothing seems to happen, and I reboot. Same on any time I try to boot.

I've tried manually loading linux from grub by just setting linux to the path it is stored at, and I get the same exact result (obviously without the loading linux echo).

Also worth noting I had to remove the } from near the end of the install.sh script, otherwise there is a syntax error.

chadmed commented 2 years ago

There's something funky up with either dracut or udev. I managed to hobble across the finish line by building a very barebones kernel with all the Apple related stuff built in, but it seems to just be a 50/50 shot in the dark whether certain platform devices will be probed correctly. I've been trying to get to the bottom of this for the last three days. It doesn't seem to be anything silly the script does since all it does is use the running kernel's config. I'll keep trying to get to the bottom of this today.

If you have clang installed on another machine, you can cross compile the kernel by adding doing make ARCH=arm64 LLVM=1 LLVM_IAS=1 CROSS_COMPILE=aarch64-unknown-linux-gnu -jX without having to install a gcc cross toolchain and build a minimal rescue kernel to at least get to the rootfs. You can also easily get back to macOS of course.

luna-xenia commented 2 years ago

Thank you! I do have a machine that can install clang but unfortunately it’s an older thinkpad on gentoo so it would take approximately 7 years to install 🤣

If there is anything else I can do to help on my machine please let me know, I’m not concerned about breaking my install

chadmed commented 2 years ago

Using m1n1's hypervisor I think I've narrowed it down to something to do with dracut, which is annoying because its documentation is pathetic.

I can see from the serial console that it is indeed probing the modules and loading them, but it hangs when entering the initramfs. Are you using ~arm64 as your keyword?

chadmed commented 2 years ago

I now have it booting reliably, so I'm going to close this issue. I suggest you boot into macOS, nuke all the Asahi-related partitions (this time including the 2.5GB APFS container and ESP) and start again. I've made some changes to the install script that should fix things. I guess the problem was dracut not finding the softdeps or something. I would also suggest not using clang or LTO system wide just yet.

luna-xenia commented 2 years ago

I have completely nuked the asahi linux stuff and reinstalled, yet I’m still getting the exact same issue (worth nothing I’m using a MacBook Air M1 with 16GB RAM). Don’t really know how to get this to boot.

chadmed commented 2 years ago

If you're now using the version I tagged out earlier, then I'm not really sure what your problem would be at this stage. I would assume it's still something wrong with dracut and its insertion of modules. You're going to have to cross compile a kernel with the modules listed in resources/dracut.conf built in, boot it from GRUB and have a look around. I would suggest emerging genkernel then running genkernel initramfs. If it boots with the initramfs genkernel makes for you, then the issue must be with dracut.

FWIW dracut is also broken on x86 Gentoo. My server experienced the same failure mode today. If this persists I may change this script to use genkernel instead.

luna-xenia commented 2 years ago

I’ll be honest I don’t really know how I would cross compile a kernel. Maybe it was the prompts I got when running install? When it was building the kernel there was a couple things that came up which I just pressed enter on (by memory it was something to do with mediatek?). Maybe if I make them modules it might work, but I don’t really know.

After I run install, I normally setup fstab, should I leave this out and just try to boot without it?

chadmed commented 2 years ago

On the machine with clang, you can just run make like I showed above. As a rough guide this takes me about 40 minutes on a dual core MacBook Pro from 2017. The fstab isn't going to be the issue if you're not even getting a framebuffer. It'll be something in the initramfs before the kernel takes over the console from GRUB.

jannau commented 2 years ago

I think I saw the same issue. initramfs contained no modules whatsoever.

Caused by the asahi kernel config using zstd to compress kernel modules and sys-apps/kmod merged without zstd USE flag.

ZerdoX-x commented 1 year ago

I have the same issue currently. After following all instructions on Asahi wiki and Gentoo handbook I got unbootable linux. Could you guys help me out? @jannau @chadmed

Booting `Gentoo GNU/Linux`
Loading Linux 6.2.0-rc3-asahi-ARCH ...
Loading initial ramdisk ...
_

EFI stub: Booting Linux Kernel...
EFI stub: Using DTB from configuration table
EFI stub: Exiting boot services...

I also stumbled upon #6 including not working wifi which I fixed by patching genstrap.sh: thanks to this article: https://leo3418.github.io/2023/01/14/gentoo-asahi-linux.html

And I encountered #8 bug. I needed to emerge sys-apps/asahi-scripts and run asahi-fwextract manually.

This is not the only issues I encountered and TBH this is my first experience with Gentoo (but not with Asahi, I am also pretty familiar with Arch and Void).

Currently it feels awful. I spent about 6 hours trying to install some nice non-systemd distro on macbook and twice got the same result...

I would like to not erase all partitions and start over again as this is really frustrating and won't give any other results probably. I would appreciate any help and feedback.

Maybe also related: https://github.com/AsahiLinux/PKGBUILDs/issues/15

And if it matters, I have enabled zstd USE flag globally. This is not mentioned in any ever tutorial, I found it on Reddit scrolling through comments about Gentoo on M1. And for my first try I was missing this flag, but I guess it should work without it.

Also I am not sure if I done mounting ESP properly. efi mount point was missing in /boot folder so I just mkdir and mounted my EFI partition to it. After that I used genfstab and script allowed me to run it. There is no any clear consistent updated tutorial how to do install Gentoo on M1 so I need to come up with something with myself.

Thank you again for any feedback.

chadmed commented 1 year ago

@ZerdoX-x You have used a nonstandard guide to fix a problem which doesn't actually exist, at least as far as any of us with by-the-books installations are concerned. WiFi works fine out of the box with no changes to genstrap.sh or any other script involved in the bootstrapping process.

The author of the guide you followed clearly didn't follow the instructions because that particular failure mode can only present itself if you're running out-of-sync packages on Asahi. The way firmware works changed in a release some time back. The instructions say to do a full system upgrade and reboot before doing anything else, which is in part there as a step to fix this exact problem and get you the latest and greatest kernel.

As far as other bugs you encountered, let's go through them one by one.

6 is a known issue, however until recently was kind of impossible to fix elegantly as the size of the directories we need to import is constantly in flux. Now that all the firmware these machines need is provided by the initramfs with special firmware hooks, we can just omit the entire /lib/firmware directory and this should never be a problem again. I will push a permanent fix for this within a few minutes of this comment going up. The flipside to this is that the error message is pretty self-explanatory and anyone comfortable enough with a Linux environment to attempt a from-scratch Gentoo install should be more than capable of bodging a fix for this without assistance. It's a very obvious one-liner if you read the (very short) shell script.

8 should be impossible to encounter now with the fixed sys-apps/asahi-scripts and sys-firmware/asahi-firmware

which have been marked as stable for quite a while now. Again the only way you could trigger this is somehow running out-of-sync packages, perhaps by trying to ACCEPT_KEYWORDS=~arm64 for the kernel but nothing else?

In terms of the general problem you're experiencing with the screen freezing at the EFI stub error messages, this is an issue with your kernel config, most likely DCP or GPU driver misconfiguration. Given that you have followed a guide which makes unnecessary and ill-informed changes to the installation infrastructure, there's not much I or anyone else can do to help you fix these issues. Troubleshooting this particular issue is more trouble than it's worth since you need to rejig m1n1 to boot into proxy mode and upload a tethered kernel and initramfs. It's worth noting that you need Rust to build the GPU driver. Ensuring you have the correct Rust toolchain for the job is an exercise for the reader since there's no upstream Gentoo infrastructure for dealing with oxidised kernels at the moment.

Wipe your partitions and try again, this time following the guide exactly.

I realise that there's a lot of stuff in flux and the experience is not quite as smooth as a vanilla Asahi install, but keep in mind that marcan does this (almost) full time and receives financial backing from folks to ensure that the UX with an Asahi install is as smooth as it is currently.

The long-term goal is to get everything in the overlay usptreamed into the main Gentoo ebuild repo. In that regard, I have neither the time nor the mental bandwidth to deal with the additional overhead of upstream bureaucracy while things are still moving as fast as they are. I don't have the financial latitude to drop any of my other commitments to make the time or mental bandwidth either. Eventually, this repo will become obsolete too as more stuff is upstreamed into the vanilla kernel and we get around to tackling USB boot in a reliable and user-friendly manner. At that point, installing Gentoo will look about identical to doing so on an x86 machine.

In future, drop by #asahi-alt on OFTC for support or open a new issue. Don't necro old issues that have been fixed for almost a year unless you're absolutely certain it's the same problem.

ZerdoX-x commented 1 year ago

Thank you. I will try again and will post my own tutorial with every command I run during setup and then open new issue.

I followed that tutorial (it's not even tutorial, just guy sharing a patch) not because I wanted, but just because I could not find any other solution to the issue.