Thanks to visit codestin.com
Credit goes to github.com

Skip to content

KhanhNguyen9872/initrd-magisk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

initrd-magisk

Another simple way to integrate Magisk into Android-x86 project (BlissOS, PrimeOS, ...)

How to use?

  1. In Android-x86 directory (which contain initrd.img, system.img, data, or data.img, ...), rename initrd.img to initrd_real.img and put initrd-magisk as initrd.img.
  2. Download magisk apk and put it as magisk.apk in Android-88 directory.

Android x86 directory will be like this:

  • ...
  • data.img or data folder
  • findme
  • initrd.img (initrd-magisk)
  • initrd_real.img (original initrd.img)
  • install.img
  • kernel
  • magisk.apk
  • ramdisk.img (if Android 9 and bellow)
  • system.img
  • ...

How does it works?

initrd-magisk boot stage

  • System launched with initrd-magisk (initrd.img) unpacked into root directory in first stage, then unpack original initrd_real.img to root directory.
  • Extract magisk.apk and put binaries into /magisk
  • Put 99_magisk script into /scripts
  • Launch init script from original initrd_real.img and continue to boot.

original initrd boot stage

  • Execute 99_magisk script to patch Android's root directory
    • On rootfs, directly add magisk binaries into /android/magisk and magisk services into init.rc
    • On system-as-root, mount tmpfs on /android/dev, mount overlayfs on /system/etc/init and add magisk binaries and magisk.rc.
    • Patch sepolicy file, dump it into /android/dev/.overlay/sepolicy and mount bind into /sepolicy or vendor precompiled sepolicy.
    • Unmount /android/dev
  • init switch root to /android and execute /init to boot into Android.

Android boot stage

  • Android boot with Magisk

Build initrd on Linux environment

  1. Prepare environment:
apt update; apt upgrade
pkg install git
pkg install cpio
  1. Clone this repo by:
git clone http://github.com/huskydg/initrd-magisk
  1. Change current directory to ~/initrd-magisk:
cd ~/initrd-magisk
  1. Build with these command:
chmod -R 777 *; find * | cpio -o -H newc | gzip > ../initrd-magisk.img

Important

  • If you have rusty-magisk installed (BlissOS 14, PrimeOS 2.0 come with rusty-magisk installed), initrd-magisk will try to invalidate it. It's RECOMMENDED to remove it.
  • If you update Android-x86 OTA, it might wipe out initrd.img so you will need to do again.

About

Another way to integrate Magisk into Android-x86 project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published