Skip to content

OverlayFS style based on Magic mount

Notifications You must be signed in to change notification settings

CKMagisk/magic-mount

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magic mount

This project is created for fun! :>

OverlayFS style based on Magisk's Magic mount logic (basically bind mount) that allows you to combine multiple directories into one similar to overlayfs. Support whiteout and trusted opaque behavior of overlayfs.

In short, this is OverlayFS re-implemented as magic mount logic. However, it doesn't support upperdir behavior found on OverlayFS for writable because it is actually just tmpfs + bind mounts.

Usage:

usage: magic-mount [OPTION] DIR1 DIR2... DIR

Use magic mount to combine DIR1, DIR2... and mount into DIR

-r            Merge content of mounts under DIR1, DIR2... also
-n NAME       Give magic mount a nice name
-v            Verbose magic mount to stderr
-l            Verbose magic mount to logd
-f FILE       Verbose magic mount to file

Modifying system partition with magic-mount

Merge contents

Example: /data/adb/app has App_1, App_2 and /system/app has App_3

# Ensure /data/adb/app context is u:object_r:system_file:s0
# as mounting with /data/app/app has higher level than /system/app
chcon -R u:object_r:system_file:s0 /data/adb/app
./magic-mount -r /data/adb/app /system/app /system/app

After that, /system/app will have App_1, App_2, App_3

Delete folder systemlessly

The whiteout file is character node with 0:0 (major, minor)

When a whiteout is found in the upper level of a merged directory, any matching name in the lower level is ignored, and the whiteout itself is also hidden.

mkdir -p /data/adb/app
chcon u:object_r:system_file:s0 /data/adb/app
mknod /data/adb/app/Stk c 0 0
./magic-mount -r /data/adb/app /system/app /system/app

Replace folder

Folder with trusted.overlay.opaque:y attribute will be considered as trusted opaque

Where the upper filesystem contains an opaque directory, any directory in the lower filesystem with the same name is ignored.

mkdir -p /data/adb/app/Stk
chcon -R u:object_r:system_file:s0 /data/adb/app
setfattr -n trusted.overlay.opaque -v y /data/adb/app/Stk
./magic-mount -r /data/adb/app /system/app /system/app

Important

Note: Magic-mount is read-only. Extremely ineffective than overlayfs, don't use magic-mount with directory that includes large numbers of file/directory. It is recommended to use magic mount on folder that you actually need.

About

OverlayFS style based on Magic mount

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 93.6%
  • Shell 3.6%
  • Makefile 2.8%