Files
mu300-linux/android/magisk
Abdurrahman Kaan DikeçandClaude Opus 5.5 209c2bfadd Imported Android files: readable by the vendor daemons whoever unpacked them, root's, nothing world-writable (#127, #170)
install.sh run from a folder on FAT or exFAT under macOS stored every imported file and directory as 0700
root:root (the file system keeps no modes, macOS reports 0700, tools/vendor-overlay.py took what it was told).
modem_control and refnotify run as uid 1000 or mu300vnd and keep no capability that reads past a mode: the
property area unreadable ends at "can't get modem type!", vendor/etc unreadable at "can't get modem img!" - the
CP is never loaded, the AT ttys answer ENODEV. Reproduced on the F50-B on 7.2.10 and on 5.4.254 (the kernel makes
no difference), on Ubuntu and on openwrt-luci.

- android-vendor-start: before anything is started, the five imported trees are checked with one find and set
  right where they are not: root's, directories 0755 (0711 left), programs 0755, the property files 0444, other
  files 0644. One line says what was found, in the service's log and in the kernel's; marks in the boot
  timeline. An update carries these files over as they are, so this is what repairs an installed system.
- tools/vendor-overlay.py: the mode of an entry comes from where it goes, never from the host's file system.
- The Magisk installer and android-install.sh run under umask 022 (magisk --install-module gives 000: sixteen
  directories 0777 and ld.config.txt 0666 in a system the v2026.10.22 zip installed), and the overlay is packed
  as root's (bionic was stored as Android's system, uid 1000: the first login account of the installed system).
- android-vendor-start makes /var/log before it starts logdw: on OpenWrt it can run before the boot script that
  creates it, and then there was no vendor log at all - on three of four boots of the F50-B.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVN2zDgf76kMDVSuWhHPUE
2026-10-12 18:13:40 +03:00
..

Magisk module: switch to Linux from Android

A one-tap way to start the Linux system from Android. It replaces having a computer plugged in just to change the boot slot. There are two ways to get it:

  • The release's installer zips (mu300-magisk-<tag>-<system>-k<kernel>.zip, see "Installing from Android with a Magisk zip" in the main README) install Linux and then stay on the device as this module. After the install it is called "MU300 Linux" instead of "MU300 Linux switch"; the module id is the same (mu300_linux_switch), so the two replace each other. The Action button, mu300-linux and everything below work the same. Their files come from this directory (installer/ is the installation part, mu300-linux-switch/ is this module), assembled by tools/make-magisk-zips.sh.
  • The switch-only module, for a device where Linux was installed from a computer (./install.sh). It installs nothing and only changes the boot slot:
android/magisk/build.sh          # builds mu300-linux-switch.zip

Install the zip in the Magisk app (Modules → Install from storage), or from a computer:

adb push android/magisk/mu300-linux-switch.zip /data/local/tmp/
adb shell "su -c 'magisk --install-module /data/local/tmp/mu300-linux-switch.zip'"
adb reboot                      # Magisk applies a new module on the next boot

Using it

  • Magisk app → Modules → MU300 Linux switch → Action. The device arms the slot Android is not on and reboots into Linux.
  • From a terminal or adb:
su -c mu300-linux               # switch to Linux now
su -c 'mu300-linux status'      # what is on each slot; changes nothing
su -c 'mu300-linux --dry-run'   # print the block it would write, write nothing
su -c 'mu300-linux bootchain'   # does the boot chain differ between the slots? changes nothing
su -c 'mu300-linux bootchain sync'   # copy Android's slot's chain to the Linux slot (backed up first)

bootchain sync is the installers' step on its own (bootchain.sh, a copy of tools/android-bootchain.sh; FINDINGS 40): where uboot, sml, teecfg, trustos or vbmeta differ between the slots - after an Android update, say - both slots' images go to /data/adb/mu300-bootchain/<date>/ with a SHA256SUMS, then Android's are written to the Linux slot and read back; a mismatch writes the old ones back. It refuses when Android's slot is not marked as booted successfully, when the other slot is set to boot next without Linux on it (an update waiting for its restart), when any of the ten partitions is missing or the two slots of one differ in size, and on any other model.

Going back needs nothing: Linux restores Android's block during its own boot, so the next reboot returns to Android. From inside Linux, mu300-next-boot linux arms another Linux boot and mu300-os <name> picks which system starts.

What it writes

Switching writes exactly 32 bytes: the AOSP bootloader_control block at offset 0x800 of misc, with the slot Android is not on at the highest priority and tries_remaining = 2 (LK treats 1 as an already failed boot), Android's slot still bootable and marked successful. boot_a, boot_b, the GPT, userdata and every other partition are untouched, so the worst case of a Linux that does not boot is that LK falls back to Android by itself.

The block is not a canned blob: the module reads the live one, changes the slot suffix and the two metadata bytes, and recomputes the CRC32 (zlib, over the first 28 bytes) in awk, so it stays correct on a device whose block differs. It refuses to do anything when the magic is not BCAB, when Android's slot is unknown, or when the other boot partition is missing, is not a boot image, or is just a copy of Android's (no Linux installed).

Checked on hardware

ZTE F50 / MU300, Magisk 30.7, Android 13: status and --dry-run produce exactly the trial block that boot/flash-trial.sh computes on a computer, and the Action/mu300-linux path rebooted the device into Linux.