clonezilla live rebuild
之前測試APPLE M1 MINI for Clonezilla Live boot test已經大致確認開機流程,但是clonezilla live進不去,其實主要就是kernel, initramfs 做怪,大概嘗試了2周之後,才找到原因。
解法就是先準備好 clonezilla-live zip
安裝 clonezilla
apt-get install clonezilla
透過 ocs-live-swap-kernel
換 asahi linux kernel 重新打包並置換 linux kernel
需要包好的 asahilinux kernel 可以從這邊下載 https://thomas.glanzmann.de/asahi ,我下載的是 linux-image-6.5.0-asahi-00780-g62806c2c6f29_6.5.0-00780-g62806c2c6f29-1_arm64.deb
換之前先簡單patch下 ocs-live-swap-kernel
:
$ diff /usr/sbin/ocs-live-swap-kernel ./ocs-live-swap-kernel
176c176
< cp_mod_cmd="rsync -a $rsync_vopt ../../$wd_tmp/usr/lib/modules/ squashfs-root/usr/lib/modules/"
---
> cp_mod_cmd="rsync -a $rsync_vopt ../../$wd_tmp/lib/modules/ squashfs-root/usr/lib/modules/"
186a187,190
> echo "Adding Asahi Linux Modules"
> echo "tps6598x" >> squashfs-root/etc/initramfs-tools/modules
> echo "phy_apple_atc" >> squashfs-root/etc/initramfs-tools/modules
> echo "typec" >> squashfs-root/etc/initramfs-tools/modules
變成這樣:
ocs-live-swap-kernel
執行
sudo ./ocs-live-swap-kernel clonezilla-live-3.2.0-31-arm64.zip linux-image-6.5.0-asahi-00780-g62806c2c6f29_6.5.0-00780-g62806c2c6f29-1_arm64.deb
把新的 zip clonezilla-live-3.2.0-31-arm64-k6.5.0-asahi-00780-g62806c2c6f29.zip
解壓縮到隨身碟用 type-c port 開機即可
開機過程:
補充資訊
modules
測試發現缺少重要的module導致預設 initramfs 沒有辦法驅動usb type-c; 所以需要加以下內容到 squashfs-root/etc/initramfs-tools/modules ; 再進行更新
例如 MAC m2 2023 需要:
tps6598x
phy_apple_atc
typec
建議?:
CONFIG_HID_DOCKCHANNEL=m
CONFIG_PHY_APPLE_ATC=m
CONFIG_PHY_APPLE_DPTX=m
CONFIG_HID_APPLE=m
CONFIG_USB_XHCI_HCD=m
CONFIG_USB_DWC3=m
CONFIG_TYPEC_TPS6598X=m
需要載入的modules
https://leo3418.github.io/asahi-wiki-build/kernel-config-notes-for-distros/
m1debian
大量參考 m1debian 的成果,建議有需要的話可以看以下內容
- prepare_rust.sh - Prepares a rust installation suitable for kernel compilation
- m1n1_uboot_kernel.sh - Builds m1n1, u-boot and the kernel including gpu support.
- mesa.sh - Creates mesa packages
- bootstrap.sh - Creates Debian root and live filesystem
- meta.sh - Meta package which makes sure that we always get latest and greatest kernel.
Asahi linux image
https://thomas.glanzmann.de/asahi
# Debian asahi packages
cat <<'EOF' | sudo tee /etc/X11/xorg.conf.d/30-modeset.conf
Section "OutputClass"
Identifier "appledrm"
MatchDriver "apple"
Driver "modesetting"
Option "PrimaryGPU" "true"
EndSection
EOF
echo 'deb https://thomas.glanzmann.de/asahi testing main' | sudo tee /etc/apt/sources.list.d/glanzmann.list
sudo curl -sL -o /etc/apt/trusted.gpg.d/thomas-glanzmann.gpg https://tg.st/u/thomas-glanzmann.gpg
sudo apt update
sudo apt install -y m1n1 linux-image-asahi libgl1-mesa-dri
sudo apt upgrade -y
m1n1
m1n1 is the bootloader developed by the Asahi Linux project to bridge the Apple (XNU) boot ecosystem to the Linux boot ecosystem.
Initializes hardware
Puts up a pretty logo
Loads embedded (appended) payloads, which can be:
Device Trees (FDTs), with automatic selection based on the platform
Initramfs images (compressed CPIO archives)
Kernel images in Linux ARM64 boot format (optionally compressed)
Configuration statements
Chainloads another version of itself from a FAT32 partition (if configured to do so)
Boot chain overview
Apple stuff → m1n1 stage 1 → m1n1 stage 2 → DT + U-Boot → GRUB → Linux
m1n1 stage 1 is installed by the Asahi Linux installer from recovery mode (in step2.sh), is signed by an internal machine-specific key in the process (as part of Apple’s secure boot policy), and can be considered immutable. Upgrading it should seldom be needed, we’ll make tooling for this when it becomes necessary. It has the PARTUUID of the EFI system partition assigned to this OS hardcoded into it (set at install time), and chainloads m1n1 stage 2 from ESP/m1n1/boot.bin (the ESP must be in internal NVMe storage, no external storage is supported). It also passes through this PARTUUID to the next stage (as a to-be-set /chosen property, see below), so the next stage knows what partition it’s booting from.
有一個很重要的地方
(the ESP must be in internal NVMe storage, no external storage is supported)
這就是為什麼需要先透過asahi linux 安裝程序先在 mac 上安裝 uboot 開機的原因!
編譯與實作參考:
GitHub: AsahiLinux/m1n1 https://github.com/AsahiLinux/m1n1
linux-image-asahi 編譯
需要包好的 asahilinux kernel 可以到這邊下載:
https://thomas.glanzmann.de/asahi
編譯參考
https://git.zerfleddert.de/cgi-bin/gitweb.cgi/m1-debian/blob/HEAD:/m1n1_uboot_kernel.sh