tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs
MIT License
757 stars 76 forks source link

nvme drive isn't found in installer #61

Closed oliver-ni closed 1 year ago

oliver-ni commented 1 year ago

Hi! Thanks for your work on this. I'm able to boot into the installer correctly, but once in, not able to see the nvme drive to install to. nvme0n1 doesn't exist in lsblk and any other commands I tried.

Am I doing something wrong?

oliver-ni commented 1 year ago

Did some debugging with a friend who had their system working but wasn't able to find the cause.

Here's journalctl -b0: https://gist.github.com/oliver-ni/ac69582073e68d5e3464ff9fd3664fff

Might have something to do with Line ~446?

I also noticed that the nvme devices showed up in U-Boot normally. They just didn't show up in the installer (nothing at /dev/nvme*, only thing in /dev/disk/* was the usb drive)

tpwrules commented 1 year ago

I'm not really sure what could be up here. It works fine on my 16" M1 Max machine and I verified we are using the same ISO.

Line 446 is a failure to mount the ESP to grab the WiFi firmware automatically for a better install experience. The NVMe block device will already exist by that point if everything is operating properly.

I assume this persists across multiple boots? Is this using the U-Boot provided by the official installer?

oliver-ni commented 1 year ago

This does persist across multiple boots. I'm using the U-boot provided by the official installer afaik. Used the release iso

oliver-ni commented 1 year ago

Update: I installed Asahi Arch and built the iso myself there, and flashed it to the usb. That worked, so not sure why the release iso would not work.

Not sure if this is helpful, but the journalctl -b0 output from the working installer: https://gist.github.com/oliver-ni/2786d24c7c4ad1f2d6de35e8a98cd019

tpwrules commented 1 year ago

If it’s not too much trouble, could you delete NixOS, install Asahi Arch again, and then try with the GitHub ISO? There might be a different version of the boot files between the UEFI only option and the Asahi Arch option.

tpwrules commented 1 year ago

Did you update Asahi Arch before using the ISO?

oliver-ni commented 1 year ago

Hiya, I can try doing that. I did update Asahi Arch before building the ISO.

tpwrules commented 1 year ago

That is probably the issue. It looks like the boot files are around a year old for both options, actually. They evidently are not compatible with the latest kernel enough to get NVMe up. But updating Asahi Arch installed new compatible ones. Building the ISO yourself wasn't the thing that fixed it.

I have asked for the UEFI installer boot files to be updated.

oliver-ni commented 1 year ago

That makes sense. Thank you for your help!

damien-biasotto commented 1 year ago

I'm facing the same issue.

It seems to affect only my Macbook Pro. I followed the guide without issue to install NixOS on my Macbook Air, but on my Macbook Pro (with m1 pro chip) the nvme disk is not detected.

(Using the same usb key / iso that I used for the Macbook Air).

Do you have any ETA, regarding the UEFI installer boot files?

sysedwinistrator commented 1 year ago

I was experiencing the same issue on a 14 inch MacBook Pro M1. I wiped my previous working installation of Arch / Asahi Linux (that was installed from Monterey, if I remember correctly), and installed the UEFI environment from Ventura (13.0).\ After replacing m1n1/boot.bin (the boot payload consisting of m1n1 stage2 + u-boot) with the one provided by the uboot-asahi flake output didn't work, I manually recreated the boot.bin file from Asahi Linux. I fetched the packages (m1n1, uboot-asahi, linux-asahi, and asahi-scripts as a reference) from the CDN and did what the update-m1n1 script would do:

cat m1n1/usr/lib/asahi-boot/m1n1.bin linux/usr/lib/modules/6.2.0-asahi-11-1-ARCH/dtbs/*.dtb > boot.bin
gzip -c u-boot/usr/lib/asahi-boot/u-boot-nodtb.bin >> boot.bin
sysedwinistrator commented 1 year ago

I noticed that the uboot-asahi package is using the u-boot DTBs for boot.bin, while update-m1n1 from Asahi uses the kernel's DTBs:

: ${DTBS:=/lib/modules/*-ARCH/dtbs/*.dtb}
tpwrules commented 1 year ago

The kernel DTBs are added here. I can't do anything until the Asahi folks update the default installer images. It is possible to fix this issue on first boot by extracting and installing this boot.bin.

To fix this issue:

  1. Install the UEFI option as described in the guide and make sure you can boot into U-Boot (you don't need to boot the installer)
  2. Boot back into macOS
  3. Locate the NixOS ESP. You can check which partition it is using diskutil list in Terminal. It should be named EFI - NIXOS assuming that's what you named the install using the Asahi installer.
  4. Mount and open the ESP using a command like diskutil mount /dev/disk0s4 && open /Volumes/EFI\ -\ NIXOS (depending on partition number and name).
  5. Download and unzip the linked boot.bin.
  6. Copy the extracted boot.bin into the m1n1/ folder on the ESP and replace the existing file.
  7. Reboot into U-Boot and run the installer as described in the guide.

m1n1, U-Boot, and the device trees will be managed by NixOS going forward, so these steps will not need to be repeated unless you completely wipe the partitions and start over.

The attached boot.bin can be reproduced by checking out commit 4e27fb9b22baab92af3a311054f136f286d94597 of the repo and running nix build .#installer-bootstrap.config.system.build.m1n1 && cp result boot.bin on an aarch64-linux machine (or x86_64-linux if you wish).

damien-biasotto commented 1 year ago

Thank you @tpwrules! I just followed the directions in your comment and was able to install NixOS on the macbook pro M1 :)

tpwrules commented 1 year ago

This should be fixed in the latest set of Asahi installer images.

Smaug123 commented 1 year ago

Edit: please ignore me, fully restarting the entire procedure got past this and up to the point of #78.


I just saw the same problem after following the instructions this morning with the latest Asahi installer, though I did also recently upgrade to macOS 13.4 (MBP 16-inch 2021). lsblk just shows me loop0 /nix/.ro-store and sda /iso. Afraid I'm not in a position to dig further right now (I bet this is my own stupid fault for upgrading macOS :P)

tpwrules commented 1 year ago

@Smaug123 a workaround for that issue is available in that thread