• Stars
    star
    591
  • Rank 75,679 (Top 2 %)
  • Language
    C++
  • Created almost 2 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make system partition become read-write (it is also possible without Magisk)

Magisk Overlayfs

On Android 10+, system partitions might no longer be able to remount as read-write. For devices use dynnamic partition, it is nearly impossible to modify system partiton as there is no space left. This module solves these problem by using OverlayFS. So what is OverlayFS? On Wikipedia:

OverlayFS is a union mount filesystem implementation for Linux. It combines multiple different underlying mount points into one, resulting in single directory structure that contains underlying files and sub-directories from all sources. Common applications overlay a read/write partition over a read-only partition, such as with LiveCDs and IoT devices with limited flash memory write cycles.

Benefits of using overlayfs for system partitions:

  • Make most parts of system partition (/system, /vendor, /product, /system_ext, /odm, /odm_dlkm, /vendor_dlkm, ...) become read-write.
  • /data storage is used for upperdir of OverlayFS mount. However, on some kernel, f2fs is not supported by OverlayFS and cannot be used directly. The workaround is to create an ext4 loop image then mount it.
  • All modifications to overlayfs partition will not be made directly, but will be stored in upperdir, so it is easy to revert. Just need to remove/disable module so your system will return to untouched stage.
  • Support Magisk version 23.0+ and latest version of KernelSU

If you are interested in OverlayFS, you can read documentation at https://docs.kernel.org/filesystems/overlayfs.html

Build

There is two way:

GitHub Actions

  • Fork this repo and run github actions

Linux/WSL

  1. Clone this repo to your device
git clone http://github.com/HuskyDG/Magisk_OverlayFS && cd Magisk_OverlayFS
  1. Setup Android NDK in repository directory
wget https://dl.google.com/android/repository/android-ndk-r23b-linux.zip
unzip android-ndk-r23b-linux.zip
  1. Run bash build.sh

KernelSU problem

  • The KernelSU module is similar to Magisk in that it allows users to modify the system partition while maintaining system integrity. It does this through the implementation of overlayfs. However, it's important to note that KernelSU makes changes to the system partition by using read-only overlayfs, which also mounts on top of magic_overlayfs and prevent system from being remounted as read-write. If you want to remount your system partitions as read-write, you simply need to first unmount the KernelSU overlayfs using this command:
nsenter -t 1 -m sh
overlayfs_system --unmount-ksu

or set DO_UNMOUNT_KSU=true in /data/adb/modules(_update)/magisk_overlayfs/mode.sh

  • After that you will be able to remount system as read-write

Change OverlayFS mode

  • OverlayFS is mounted as read-only by default

  • Configure overlayfs mode in /data/adb/modules(_update)/magisk_overlayfs/mode.sh to change mode of OverlayFS

Read-write mode of overlayfs will cause baseband on some devices stop working

# 0 - read-only but can still remount as read-write
# 1 - read-write default
# 2 - read-only locked (cannot remount as read-write)

export OVERLAY_MODE=2
  • OverlayFS upper loop device will be setup at /dev/block/overlayfs_loop
  • On Magisk, OverlayFS upper loop are mounted at $(magisk --path)/overlayfs_mnt. You can make modifications through this path to make changes to overlayfs mounted in system.

Modify system files with OverlayFS

  • If you are lazy to remount, please modify mode.sh and set it to OVERLAY_MODE=1 so overlayfs will be always read-write every boot.

  • You can quickly remount all overlayfs to read-write by this command in terminal:

su -mm -c magic_remount_rw
  • After that you can restore all system partitons back to read-only mode by this commamd in terminal:
su -mm -c magic_remount_ro

Overlayfs-based Magisk module

  • If you want to use overlayfs mount for your module, add these line to the end of customize.sh:
OVERLAY_IMAGE_EXTRA=0     # number of kb need to be added to overlay.img
OVERLAY_IMAGE_SHRINK=true # shrink overlay.img or not?

# Only use OverlayFS if Magisk_OverlayFS is installed
if [ -f "/data/adb/modules/magisk_overlayfs/util_functions.sh" ] && \
    /data/adb/modules/magisk_overlayfs/overlayfs_system --test; then
  ui_print "- Add support for overlayfs"
  . /data/adb/modules/magisk_overlayfs/util_functions.sh
  support_overlayfs && rm -rf "$MODPATH"/system
fi

Bugreport

  • Magisk/KernelSU version
  • Magisk/KernelSU logs
  • /cache/overlayfs.log
  • logcat, dmesg, ...

Reset overlayfs

  • Remove /data/adb/overlay and reinstall module

Without Magisk

  • Simple configuration to test:
# - Create a writeable directory in ext4 (f2fs) /data
# which will be used for upperdir
# - On some Kernel, f2fs is not supported by OverlayFS
# and cannot be used directly
WRITEABLE=/data/overlayfs

mkdir -p "$WRITEABLE"

# - Export list of modules if you want to load mounts by overlayfs
# - If you have /vendor /product /system_ext as seperate partitons
# - Please move it out of "system" folder, overwise **BOOM**
export OVERLAYLIST=/data/adb/modules/module_a:/data/adb/modules/module_b

# - If there is Magisk, export this in post-fs-data.sh (before magic mount):
export MAGISKTMP="$(magisk --path)"

# - Load overlayfs
./overlayfs_system "$WRITEABLE"

Donate

Source code

More Repositories

1

magisk-files.old

1,893
star
2

magisk-files

1,337
star
3

MagiskHide

Portable MagiskHide
C++
305
star
4

MagiskOnEmu

This repo is no longer used
299
star
5

VMOSPro_MOD

The MOD version of VMOS Pro which unlock Premium features and remove Ads
163
star
6

initrd-magisk

Integrate Magisk into Android-x86 project
Shell
145
star
7

magic_proc_monitor

A Magisk/Zygisk module allows user to run script whenever app process start
C++
117
star
8

Zygisk-FontLoader

Preload font modules, original version: http://github.com/RikkaW/FontLoader
C++
88
star
9

riru-momohider

A Riru module tries to make Magisk more hidden. http://github.com/canyie/riru-momohider
C++
79
star
10

zygisk-maphide

Wipe out the traces of mounted files of Magisk module for process on DenyList
C++
53
star
11

huskydg.github.io

Shell
40
star
12

VMOSPro_ROM

Official ROMs which were ported from VMOS Pro come with Root and Xposed Framework (GEEK) or not (LITE)
37
star
13

Bypass-Activate-Windows-10

Using a Windows 10 license will always receive a lot of support from the provider, in addition it also increases stability, you will encounter fewer Windows 10 errors during use. However, not everyone has the conditions to own a copyrighted version of Windows 10 as well as Active Windows 10 every year so that they can promptly receive the necessary support and continuous updates from the prevention system
Batchfile
32
star
14

magic-mount

OverlayFS style based on Magic mount
C++
30
star
15

magisk-xposed

Legacy Systemless Xposed Framework by topjohnwu
Shell
27
star
16

Magisk-on-VMOS

Magisk successfully installed on VMOS - but Magisk can't work properly
Shell
21
star
17

VMOSPro_RootXposed_Terminal

A simple scripting tool that gives you useful features. Add or remove Root and Xposed Framework, Busybox, etc. without paying for VMOS Pro VIP 😎
21
star
18

ksu_unmount_injector

Unmounting KSU overlay for kernel bellow 5.9
C++
18
star
19

bluestacks_zygote_app_process_wrapper

app_process wrapper for Bluestacks
C++
15
star
20

shell_script_compiler

Compile shell script as binary
C++
15
star
21

injectprop

Inject Android system properties
C++
13
star
22

sample_cpp_build

Sample C++ build project
Shell
13
star
23

Riru-Pixelify

Riru version of Pixelify
Shell
12
star
24

VMOSPro_GEEKTools

Another based-TerminalEmulator app with various features for modding virtual machine of VMOS Pro
Shell
12
star
25

my_cpp_header

Personal header files, you can use it if you want
C++
10
star
26

magica

C
10
star
27

magisk-overlay.d-sample-patch

Proof-of-concept for using Magisk overlay.d feature, inject rc script, replace some file in rootdir in pre-init.
Shell
10
star
28

VMOSPro_Google_Services

(Deprecated) A modification is used for installing Google/microG in any VMOS Pro OM safely and easily (Required GeekTools or VMOSTool 1.27+)
10
star
29

Magisk-on-VphoneGaga

Set up a proper minial Magisk on VphoneGaga virtual machine without patching boot image
Shell
9
star
30

magisk_overlayfs

Emulate read-write partition for read-only system partitions
Shell
9
star
31

download

Download entry
8
star
32

kernel-package_android-x86

Kernel package zip for Android x86 project
C
7
star
33

riru-unshare

C
7
star
34

systemMagisk

System version of Magisk
Shell
6
star
35

Mount-VMOSPro-OT-Disks

Mount VM disks so you can access files in other virtual machines.
5
star
36

Magisk_BootloopSaver

Protect your system from bootloop caused by Magisk modules.
Shell
5
star
37

magic-flashtool

An android CLI flash tool without custom recoveries
Shell
5
star
38

VMOSPro_Log-Catcher

Catch boot log and save to /data/local/boot/boot-$time.log Error or Warning only log is saved to /data/local/boot_error/error-$time.log.
5
star
39

custom-overlayd-no-magisk

Inject custom init.rc script without installing Magisk
Shell
5
star
40

ExampleApp

My very first app written by myself :3
Kotlin
4
star
41

vmos_xposed_installer

This repository hosts the Xposed Zip installer
Shell
4
star
42

Termux-VMOS

Run Termux enviroment on Terminal Emulator withot Termux app for VMOS Pro
4
star
43

Riru-Momohider

From http://github.com/canyie/Riru-Momohider
C++
3
star
44

libcxx

C++
3
star
45

Riru-ModuleTemplate

Template for developing Riru modules
Shell
3
star
46

Magisk_RAM_Swapper

Expand RAM memory by converting a part of storage to Swap RAM
Shell
2
star
47

android_x86_grub_config

This repository store the default Grub config for Android x86
2
star
48

TerminalEmulator

Java
2
star
49

Cache_Cleaner_Magisk

A simple module for Magisk which easily clear cache of all apps
Shell
2
star
50

decision-tree-cpp

C++
2
star
51

FindingPath_Unity2D

HTML
2
star
52

Zeetaa-Tweaks

Shell
1
star
53

busybox-no-root

The shell script which allows you to install Busybox for Terminal Emulator no need root access
Shell
1
star
54

magisk-alpha

C++
1
star
55

Cpp-Tutorial-Samples

C++
1
star
56

web-subproject

CSS
1
star
57

decision_tree_ai_car_reviews_predict

Decision Tree implemented from scratch
Python
1
star
58

XposedDetector

1
star