Supporter
- Joined
- Nov 22, 2018
- Messages
- 1,054
For building your own custom distro for your device, I used chroot-distro; magisk required
exec /system/bin/realrecovery "$@"
End of part 1 (I couldn't post this because it was too long apparently)
- Boot into android and set up your device
- Check your storage to confirm it's been sliced in half (or however you sliced it)
- Connect to wifi and download magisk from your home screen, web browser; download termux, chroot-distro and UPDATE-Busybox.Installer.v1.36.1-ALL-signed from osm0sis
- Install termux, update termux (pkg update && upgrade or something like that) go to magisk and install both chroot-distro and busybox installer, restart after installing the second one. You may also need to install busybox within termux (I had a weird bug where busybox from magisk wasn't detected like a week before my device just refused to charge at least 20% in 12 hrs before it turned worse than that)
- Now use termux to install chroot-distro to your created partition
---> Move required files to root of SD Card (if you're using scripts for this)
-----> restart termux
------> ls -la /storage/
-------> su
--------> GRANT
---------> sh /storage/XXXX-XXXX/scriptname.sh
- create a script that can install packages, device nodes, etc or do it manually (alpine.sh/debian.sh)
- Or in TWRP/OrangeFox; extract a pre-existing ext4 distro to your newly split partition (see any script with 77* for install examples)
- You can modify files after extracting to that distro, along with repackaging back to a ext4.img (move.sh, folder.sh, any 88*.sh) or as a tar.gz (untested in twrp, but tested in termux, just change to the partition location instead of current path).
- No systemd distros unless you're gonna run it in a container because your kernel allows it (PID 1 is init second_stage in recovery). Also don't if you have "4GBs" or less. Just run termux with chroot-distro instead, same ram performance (most android devices runs on ram)
- If it does have the namespace kernels (or you can rebuild that example kernel [lucky f#*k] look into libhybris distros).
- You need a tty dev node or config_vt in your kernel based on currently available libhybris/mir distros (Ubuntu Touch/Alphybris/Manjaro libyhbris)
- Now you need to modify your recovery .img ramdisk to boot into the newly installed partition (I used Android_boot_image_editor, again!)
- You can inspect some of the files within the partitions that are accessible (That payload thing you may have done earlier)
- You may need to use the 1.36 busybox and move it to your /system/bin folder (bash is great too).
- Also take some /system/bin files that you may think about using with your init.rc to help boot into your ext4 linux partition (also take other arm64 binaries, osm0sis has a repository full of them)
- Again, get the ueventd.rc for both system and vendor, combine them into a new ueventd.rc for your /system/etc if you see that /system/etc/init/hw/init.rc or /init.recovery.common.rc references them.
- /system has exec command (at least for my system-as-root experience), but if you try to overlay or bindmount improperly it will crash on you (Unless you use Alpine, more on that below)
- init.rc is your friend, change your /system/bin/recovery to /system/bin/realrecovery (thanks BlackSeraph and turtle) to test how your services are being used by init.rc and how your kernel operates
- Mount the linux partition with init.rc and make their paths accessible by creating the partitions folders in the ramdisk and in init.rc
- Using overlayfs and bindmount method works perfectly with Alpine. The fallen 3Plus uses system-as-root, and when I bind mount the overlayfs merging of the extracted system.img from the super partition and android-rootfs.img from alpine's lxc, It easily unmounted /system and remounted the merged combination of systems (see Alphybris.zip, See! There's more!)
- Debian immediately stops the device from running when copying that method. So glibc can't touch bionic. Musl can. I easily got internet access via script (not like I can see what I'm doing) using the iw pkg downloading from alpine's package manager. While Debian was the reason I was able to test the drm because Alpine's weston is build different (Alphybris doesn't come with it)
- You need to put certain files within your ramdisk while also relying on the bindmount (I put /lib/ld-musl-aarch64.so.1 in my ramdisk, dunno if that helped but I was having issues discovering that alpine uses host's path and not chroot path before doing overlayfs and bindmounts and left it there)
- Create new scripts to run as services to load everything you need with on property (see my alp_* and and_* along with my init.recovery.common.rc and init.rc)
- "Always be testing" - The Full Nerd Network.
- Use your /system/bin/recovery as a script to test. The shebang line at the top uses the available binary in the ramdisk. What does that mean? Well you can use if you can open and close your boot.img and put any arm64 binary in it anywhere that makes sense:
- #!/system/bin/sh
- #!/system/bin/toybox
- #!/system/bin/busybox
- #!/bin/sh
- #!/bin/bash
- #!/and/many/more
exec /system/bin/realrecovery "$@"
- Change /system/bin/recovery to /system/bin/realrecovery (thanks BlackSeraph and turtle for GarlicOS again) to test how your services are being used by init.rc. If you bind mount to the recovery /system with a system.img, change realrecovery back to recovery, as it will now detect the stock recovery that came with that system.img
End of part 1 (I couldn't post this because it was too long apparently)