ANDROID

 in linux we have a command called su ( switch user). 

When you type only su (without a username), it defaults to switching to the root user.

and in android we have 2kind of rooting system. 

1. Traditional root (system root) (we go to /system folder and enter there su executeable file)

2. Systemless root (e.g., Magisk):


(1).Traditional root

1.Flash a custom recovery (e.g., TWRP)

2.Mount /system as read-write

3.Copy su binary to /system/bin/ or /system/xbin/ (Android does not contain su by default.)

4.Set correct permissions (chmod 755)

5.Modify boot scripts (like init.rc) if needed


(2) 

Boot-Time Modifications:

  1. Bootloader loads patched boot.img

    • This contains original kernel + Magisk-injected initramfs

  2. Kernel boots and unpacks initramfs

    • Instead of the stock init, Magisk’s magiskinit runs

  3. magiskinit:

    • Sets up:

      • Virtual filesystem overlays (/system,/system/bin,tmpfs, overlayfs)(Overlay Filesystem (overlayfs) হলো একটি লিনাক্স ফাইলসিস্টেম ফিচার, যা দিয়ে আপনি একটি read-only ফাইলসিস্টেমের উপরে একটি writable স্তর বসাতে পারেন, যেন বাইরের দুনিয়ায় মনে হয় আপনি ফাইলগুলো পরিবর্তন করছেন — কিন্তু আসলে মূল ফাইলগুলো অপরিবর্তিত থাকে।)

      • Root namespace (for hiding root)

      • Injected su binary into a mounted location(/system)

      • Loads Magisk modules (mounts overlays into /system, /vendor, etc.)

    • Then it chains to original init, so normal boot continues

  4. magiskd (Magisk Daemon)( deamon means which process run in bacgrund):

    • Starts in background

    • Manages:

      • Root access requests

      • su session handling

      • Dynamic policy control (like DenyList, Zygisk)

      • Modules and updates


again


In modern Android (especially Android 10+):

  1. Partitions Structure:

    • /system, /vendor, /product, etc., are often dynamic partitions inside a super partition (super).

    • These are mounted as read-only during boot.

  2. Rooting Process:

    • Rooting does not modify /system or /vendor directly anymore.

    • Instead, tools like Magisk use overlay techniques (like initramfs modifications and bind mounts) to make it look like /system/bin/su or other root binaries exist.

  3. Overlay & Mounting:

    • During boot, the root image or boot partition is patched to inject a modified initramfs.

    • This patched initramfs:

      • Mounts system partitions.

      • Applies overlay or bind mount changes using Magisk.

      • This gives the illusion that /system is modified, while it remains untouched (read-only).

  4. SU Access:

    • After boot, the Magisk daemon (magiskd) runs.

    • It handles su requests, manages root permissions, and keeps SafetyNet/Play Integrity passing (if possible).


Comments

Popular posts from this blog

Assembly

Linux Concept (Everything is a file,file descriptor etc)

Memory Management