migrating from sdcardfs to esdfs

331 views
Skip to first unread message

Huy Minh Bùi

unread,
Apr 8, 2022, 12:51:57 PMApr 8
to Android-x86
Recently with the deprecation of sdcardfs and the fact the maintaining the file-system is pretty time-consuming especially when it comes to maintaining it alongside the Google's common source (or Google LTS) , I am trying to find another way to fix the apps can't read data & obb problem. By looking at what ChromeOS and Project Celadon did, I realized that they are reusing an old file-system called "esdfs" which dated before sdcardfs and being used to mount on top of the data file-system, as an example from some devices dmesg

[ 32.441432,2] ESDFS-fs (esdfs): mounted on top of /data/media type f2fs
[ 32.441497,2] SELinux: initialized (dev esdfs, type esdfs), uses genfs_contexts
[ 32.441793,2] ESDFS-fs (esdfs): mounted on top of /data/media type f2fs
[ 32.441819,2] SELinux: initialized (dev esdfs, type esdfs), uses genfs_contexts
[ 32.442040,2] ESDFS-fs (esdfs): mounted on top of /data/media type f2fs
[ 32.442063,2] SELinux: initialized (dev esdfs, type esdfs), uses genfs_contexts

It turns out bring back esdfs is not a difficult problem, you just need to go to ChromiumOS's third-party kernel source to find, Google did everything so we just need to cherry-pick it
For example, here is the kernel 5.15 source
2 commits for the driver, and a commit for PKGLIST, esdfs require this driver

I compiled the modules with a kernel of mine that is based on Google's common kernel + some Android-x86 patches. It does compile and the file-system does showed up when I check /proc/filesystems (also logcat showed it got "registered"). But there is no sign of Android picking it up and use so far. I know that Chih-Wei back then have a commit on system/core that basically revert esdfs support and bring back FUSE, I revert it and it esdfs still not picking up. 

Even when set ro.sys.sdcardfs to false like this commit told nothing happened. So I wonder if we can find a way to use it so that we can see if it can helped us with the apps permission issue. I am building r-x86, more specifically a Lineage-based ROM which I ported to x86

youli...@gmail.com

unread,
Apr 10, 2022, 8:49:56 AMApr 10
to Android-x86
mount sdcard as fuse, android_x86:/sdcard # time busybox dd if=/dev/zero of=testw.dbf bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1000.0MB) copied, 1.513464 seconds, 660.7MB/s
    0m01.53s real 0m00.00s user 0m00.53s system
android_x86:/sdcard #

mount sdcard as sdcardfs, android_x86:/sdcard # time busybox dd if=/dev/zero of=testw.dbf bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1000.0MB) copied, 0.721600 seconds, 1.4GB/s
    0m00.74s real 0m00.00s user 0m00.64s system
android_x86:/sdcard #

youli...@gmail.com

unread,
Apr 10, 2022, 8:59:40 AMApr 10
to Android-x86

Huy Minh Bùi

unread,
Apr 10, 2022, 9:01:48 AMApr 10
to Android-x86
Can you try esdfs mount and see the speed ? FUSE is being known for its slow speed so I want to see how esdfs perform


Vào lúc 19:49:56 UTC+7 ngày Chủ Nhật, 10 tháng 4, 2022, youli...@gmail.com đã viết:

Huy Minh Bùi

unread,
Apr 10, 2022, 9:06:30 AMApr 10
to Android-x86
I am guessing that ChromeOS use an external tool called "arc-setup" to handle the bind mount of the emulated storage
I found this post in 2020 written in Chinese
https://www.cxymm.net/article/b178903294/115395826


Vào lúc 19:59:40 UTC+7 ngày Chủ Nhật, 10 tháng 4, 2022, youli...@gmail.com đã viết:

Huy Minh Bùi

unread,
Apr 10, 2022, 9:08:53 AMApr 10
to Android-x86
On r-x86, I found this commit to mount the ext4/f2fs storage to sdcard, I tried but currently it's only bind mount in FUSE, also they didn't mount Android/data and Android/obb
Vào lúc 19:49:56 UTC+7 ngày Chủ Nhật, 10 tháng 4, 2022, youli...@gmail.com đã viết:

youli...@gmail.com

unread,
Apr 10, 2022, 9:37:48 AMApr 10
to Android-x86
How to make fuse passthrough work? need kernel and userspace libfuse support passthrough.
DO NOT MERGE FUSE passthrough: handle unstable kernel interface
DO NOT MERGE Enable passthrough mode for read/write operations
 
but the two libfuse patch not merge, so how fuse passthrough work on android12? https://source.android.com/devices/storage/fuse-passthrough


youli...@gmail.com

unread,
Apr 10, 2022, 9:56:51 AMApr 10
to Android-x86
android kernel and android MediaProvider FuseDaemon support passthrough, but libfuse not support passthrough, still can't improve the reading and writing speed. 

Huy Minh Bùi

unread,
Apr 18, 2022, 2:43:16 PMApr 18
to Android-x86
I don't think we should use libfuse anymore and focusing on trying esdfs
Vào lúc 20:56:51 UTC+7 ngày Chủ Nhật, 10 tháng 4, 2022, youli...@gmail.com đã viết:

youli...@gmail.com

unread,
Apr 28, 2022, 12:50:15 PMApr 28
to Android-x86
I start used ext4 casefold begin with linux 5.2, https://www.reddit.com/r/linux_gaming/comments/cbrc7s/52_kernel_supports_caseinsensitive_directories/
Android sdcard mount as fuse or sdcardfs, in order to case insensitive, but now ext4 support case insensitive, why not chattr +F data/media/0, so android init.rc "exec - media_rw media_rw -- /system/bin/chattr +F /data/media.
but how to use ext4 casefold on android, i notice external_storage.casefold.enabled=1.

Huy Minh Bùi

unread,
Apr 28, 2022, 1:25:09 PMApr 28
to Android-x86
yes that's the prop on higher Android like 11. device/generic/common already add it in
Vào lúc 23:50:15 UTC+7 ngày Thứ Năm, 28 tháng 4, 2022, youli...@gmail.com đã viết:

youli...@gmail.com

unread,
Apr 28, 2022, 1:42:20 PMApr 28
to Android-x86
mkfs.ext4 -O project,quota,casefold /dev/sda3, grub.cfg, DATA=/dev/block/sda3
will try "encoding=utf8 quotatype=prjquota".

youli...@gmail.com

unread,
Apr 28, 2022, 1:56:33 PMApr 28
to Android-x86
I wonder it can bind mount /data/media to /storage/emulated, but it isn't.
IMG_20220429_013651.jpg
IMG20220429015537.jpg

youli...@gmail.com

unread,
Apr 29, 2022, 8:34:55 AMApr 29
to Android-x86
android support esdfs a long ago, https://android.googlesource.com/platform/system/core/+/c336f86284ee817a2e846452ad80e5d014d11414
disable fuse will use esdfs.
revert androidx86 fuse.cpp, rebuild system/bin/sdcard binary.
disable fuse, add these to default.prop.
persist.sys.fuse=false
persist.fuse_sdcard=false
persist.sys.fuse.default_fuse_enabled=false
persist.sys.fflag.override.settings_fuse=false
persist.device_config.storage_native_boot.fuse_enabled=false

youli...@gmail.com

unread,
Apr 29, 2022, 9:14:39 AMApr 29
to Android-x86
persist.sys.fuse=false
persist.fuse_sdcard=false
persist.sys.fuse.default_fuse_enabled=false
persist.sys.fflag.override.settings_fuse=false
persist.device_config.storage_native_boot.fuse_enabled=false
ro.sys.sdcardfs=false
persist.sys.sdcardfs=force_off

04-29 21:01:15.075 0 0 E ESDFS-fs (esdfs): unrecognized mount option "unshared_obb" or missing value
04-29 21:01:15.075 0 0 I ESDFS-fs (esdfs): mounted on top of /data/media type ext4
IMG_20220429_210158.jpg

youli...@gmail.com

unread,
Apr 29, 2022, 9:23:10 AMApr 29
to Android-x86
system.prop, 
external_storage.projid.enabled=0
external_storage.casefold.enabled=0
external_storage.sdcardfs.enabled=1

default.prop,

Huy Minh Bùi

unread,
Apr 29, 2022, 9:33:29 AMApr 29
to Android-x86
From the picture seems like the mounting is good. However if you force FUSE to off like this can you still be able to use ntfs-3g ?


Vào lúc 20:23:10 UTC+7 ngày Thứ Sáu, 29 tháng 4, 2022, youli...@gmail.com đã viết:

Huy Minh Bùi

unread,
Apr 29, 2022, 9:34:02 AMApr 29
to Android-x86
But it seems like Android/data and Android/obb still haven't got mounted yet

Vào lúc 20:33:29 UTC+7 ngày Thứ Sáu, 29 tháng 4, 2022, Huy Minh Bùi đã viết:

youli...@gmail.com

unread,
Apr 29, 2022, 9:49:24 AMApr 29
to Android-x86
on my android11 phone, dev/fuse mount on /storage/emulated,  data/media on /storage/emulated/Android/data type sdcardfs.
if storage/emulated type sdcardfs, Android/data and obb needn't mounted.
I interest with androidx86 11 how to storage/emulated type fuse, Android/data type sdcardfs.
esdfs and sdcardfs based wrapfs.
ntfs-3g too old, i will remove userspace ntfs-3g, how to make system/bin/sdcard use linux kernel ntfs3 mount ntfs.
remove userspace ntfs-3g and exfat, use linux kernel ntfs3 and exfat.

Huy Minh Bùi

unread,
Apr 29, 2022, 10:26:56 AMApr 29
to Android-x86
> on my android11 phone, dev/fuse mount on /storage/emulated,  data/media on /storage/emulated/Android/data type sdcardfs.
> if storage/emulated type sdcardfs, Android/data and obb needn't mounted.
> I interest with androidx86 11 how to storage/emulated type fuse, Android/data type sdcardfs.
My phone does the same as you, storage/emulated in /dev/fuse and data & obb mount as sdcardfs.
And I hope we can do the same as phones but with esdfs

> ntfs-3g too old, i will remove userspace ntfs-3g, how to make system/bin/sdcard use linux kernel ntfs3 mount ntfs.

I am still planning to use ntfs-3g because although ntfs3 looks good, there are some function of the filesystem it isn't properly implemented yet. So I hope that the drvier can be improved soon.
As for how to make sdcard mount it, I assume that you can try to edit file.te like this and mount ? Also only compile NTFS3, do not compile the older NTFS in the kernel


Vào lúc 20:49:24 UTC+7 ngày Thứ Sáu, 29 tháng 4, 2022, youli...@gmail.com đã viết:

Huy Minh Bùi

unread,
Apr 29, 2022, 10:28:16 AMApr 29
to Android-x86
also I don't know about exfat, if the kernel driver is good enough then we can move on from the fuse one
Vào lúc 21:26:56 UTC+7 ngày Thứ Sáu, 29 tháng 4, 2022, Huy Minh Bùi đã viết:

youli...@gmail.com

unread,
Apr 29, 2022, 10:28:31 AMApr 29
to Android-x86
vold support use kernel ntfs driver a long ago, vold: Native NTFS kernel driver support, but only for Android.mk, https://github.com/LineageOS/android_system_vold/commit/9087457933f336b9d6057725472ec8ab2f223fe2
ifeq ($(TARGET_KERNEL_HAVE_NTFS),true)
  vold_cflags += -DCONFIG_KERNEL_HAVE_NTFS
endif

http://git.osdn.net/view?p=android-x86/system-vold.git;a=commit;h=846a83a1adc98f6cbcde161a2bde23028e0011b6  androidx86 porting ntfs support for android.bp, not porting "Native NTFS kernel driver support".

youli...@gmail.com

unread,
Apr 29, 2022, 10:43:12 AMApr 29
to Android-x86

youli...@gmail.com

unread,
Apr 29, 2022, 11:48:52 AMApr 29
to Android-x86
vold support mount ntfs3, test on androidx86 7.
[ 208.614117] sdcardfs version 2.0
[ 208.614122] sdcardfs: dev_name -> /mnt/media_rw/5F4BBAE56AE257B0
[ 208.614124] sdcardfs: gid=1015,mask=6
[ 208.614140] sdcardfs: mounted on top of /mnt/media_rw/5F4BBAE56AE257B0 type ntfs3

0001-vold-support-mount-ntfs3.patch

youli...@gmail.com

unread,
Apr 29, 2022, 3:05:04 PMApr 29
to Android-x86
mount | grep fuse, mount | grep esd

在2022年4月29日星期五 UTC+8 22:26:56<buin...@gmail.com> 写道:
> on my android11 phone, dev/fuse mount on /storage/emulated,  data/media on /storage/emulated/Android/data type sdcardfs.
> if storage/emulated type sdcardfs, Android/data and obb needn't mounted.
> I interest with androidx86 11 how to storage/emulated type fuse, Android/data type sdcardfs.
My phone does the same as you, storage/emulated in /dev/fuse and data & obb mount as sdcardfs.
And I hope we can do the same as phones but with esdfs
IMG_20220430_030137.jpg

youli...@gmail.com

unread,
Apr 29, 2022, 3:10:10 PMApr 29
to Android-x86
system.prop, 
external_storage.projid.enabled=0
external_storage.casefold.enabled=0
external_storage.sdcardfs.enabled=1

default.prop, only add these, doesn't disable fuse
ro.sys.sdcardfs=false
persist.sys.sdcardfs=force_off

youli...@gmail.com

unread,
Apr 29, 2022, 3:14:14 PMApr 29
to Android-x86
system.prop, 
external_storage.projid.enabled=0
external_storage.casefold.enabled=0
external_storage.sdcardfs.enabled=1

default.prop, only add these, switch to sdcardfs.
ro.sys.sdcardfs=true
persist.sys.sdcardfs=force_on
IMG20220430031157.jpg
Message has been deleted

youli...@gmail.com

unread,
Apr 29, 2022, 3:51:35 PMApr 29
to Android-x86
vold: support mount ntfs3 for r-x86, test on androidx86 11, i don't know how to use TARGET_KERNEL_HAVE_NTFS in Android.bp.
0001-vold-support-mount-ntfs3.patch

youli...@gmail.com

unread,
Apr 29, 2022, 4:04:29 PMApr 29
to Android-x86
oh, a mistake, my write "system.prop" is system/build.prop, 
external_storage.projid.enabled, external_storage.casefold.enabled, external_storage.sdcardfs.enabled, they are in system/build.prop

Huy Minh Bùi

unread,
Apr 30, 2022, 1:28:03 PMApr 30
to Android-x86
Hi, I put the three properties into build.prop and 2 (ro.sys.sdcardfs=false and persist.sys.sdcardfs=force_off) properties to default.prop but my system still got no esdfs bind-mounted
Here are my system/core and system/vold
Please tell me in case something is missing
Also, one thing to mention is that I am currently using a Magisk solution that is patched directly into initrd.img

https://github.com/HuskyDG/initrd-magisk (this is for using a seperate initrd to load Magisk)
I wonder if Magisk affect the bind-mounting process.

Vào lúc 03:04:29 UTC+7 ngày Thứ Bảy, 30 tháng 4, 2022, youli...@gmail.com đã viết:

youli...@gmail.com

unread,
Apr 30, 2022, 2:37:59 PMApr 30
to Android-x86
CONFIG_PKGLIST=y
CONFIG_PKGLIST_USE_CONFIGFS=y

Huy Minh Bùi

unread,
May 2, 2022, 11:01:26 PMMay 2
to Android-x86
It still not working

Vào lúc 01:37:59 UTC+7 ngày Chủ Nhật, 1 tháng 5, 2022, youli...@gmail.com đã viết:

Huy Minh Bùi

unread,
May 2, 2022, 11:30:15 PMMay 2
to Android-x86
Maybe it only detect when you have both sdcardfs and esdfs ? My kernel doesn't have sdcardfs

Vào lúc 10:01:26 UTC+7 ngày Thứ Ba, 3 tháng 5, 2022, Huy Minh Bùi đã viết:

youli...@gmail.com

unread,
May 3, 2022, 1:27:38 PMMay 3
to Android-x86
Screenshot_20220504-012408.png

Huy Minh Bùi

unread,
May 7, 2022, 10:08:02 AMMay 7
to Android-x86
Yes
Vào lúc 00:27:38 UTC+7 ngày Thứ Tư, 4 tháng 5, 2022, youli...@gmail.com đã viết:

youli...@gmail.com

unread,
May 7, 2022, 12:01:45 PMMay 7
to Android-x86
always use esdfs.
persist.sys.sdcardfs force_on or off, always use esdfs.
/data/media on /mnt/runtime/default/emulated type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:1015:771:771,derive=multi,noconfine,derive_gid,default_normal,unshared_obb)
/data/media on /storage/emulated type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:1015:771:771,derive=multi,noconfine,derive_gid,default_normal,unshared_obb)
/data/media on /mnt/runtime/read/emulated type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:9997:750:750,derive=multi,noconfine,derive_gid,default_normal,unshared_obb)
/data/media on /mnt/runtime/write/emulated type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:9997:770:770,derive=multi,noconfine,derive_gid,default_normal,unshared_obb)
/data/media on /mnt/runtime/full/emulated type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:9997:770:770,derive=multi,noconfine,derive_gid,default_normal,unshared_obb)
/dev/block/vold/public:8,2 on /mnt/media_rw/1551-23CF type vfat (rw,dirsync,nosuid,nodev,noexec,noatime,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/mnt/media_rw/1551-23CF on /mnt/runtime/default/1551-23CF type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:1015:771:771,derive=public,noconfine)
/mnt/media_rw/1551-23CF on /storage/1551-23CF type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:1015:771:771,derive=public,noconfine)
/mnt/media_rw/1551-23CF on /mnt/runtime/read/1551-23CF type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:9997:755:755,derive=public,noconfine)
/mnt/media_rw/1551-23CF on /mnt/runtime/write/1551-23CF type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:9997:755:755,derive=public,noconfine)
/mnt/media_rw/1551-23CF on /mnt/runtime/full/1551-23CF type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:9997:770:770,derive=public,noconfine)
/dev/block/vold/public:8,3 on /mnt/media_rw/24C97AC14E629DF4 type ntfs3 (rw,nosuid,nodev,noexec,noatime,uid=0,gid=1023,fmask=37777600007,dmask=37777600007,iocharset=utf8)
/mnt/media_rw/24C97AC14E629DF4 on /mnt/runtime/default/24C97AC14E629DF4 type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:1015:771:771,derive=public,noconfine)
/mnt/media_rw/24C97AC14E629DF4 on /storage/24C97AC14E629DF4 type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:1015:771:771,derive=public,noconfine)
/mnt/media_rw/24C97AC14E629DF4 on /mnt/runtime/read/24C97AC14E629DF4 type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:9997:755:755,derive=public,noconfine)
/mnt/media_rw/24C97AC14E629DF4 on /mnt/runtime/write/24C97AC14E629DF4 type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:9997:755:755,derive=public,noconfine)
/mnt/media_rw/24C97AC14E629DF4 on /mnt/runtime/full/24C97AC14E629DF4 type esdfs (rw,nosuid,nodev,noexec,noatime,lower=1023:1023:664:775,upper=0:9997:770:770,derive=public,noconfine)
:/ # getprop | grep sdcard
[external_storage.sdcardfs.enabled]: [1]
[persist.fuse_sdcard]: [false]
[persist.sys.sdcardfs]: [force_on]
[ro.sys.sdcardfs]: [true]
:/ # getprop | grep sdcardfs
[external_storage.sdcardfs.enabled]: [1]
[persist.sys.sdcardfs]: [force_on]
[ro.sys.sdcardfs]: [true]
:/ #

0001-always-use-esdfs.patch

Huy Minh Bùi

unread,
May 27, 2022, 11:36:23 AMMay 27
to Android-x86
It still not working, I am thinking that might be because of the Magisk I used
can you help me to try ?
Vào lúc 23:01:45 UTC+7 ngày Thứ Bảy, 7 tháng 5, 2022, youli...@gmail.com đã viết:

youli...@gmail.com

unread,
May 27, 2022, 4:49:17 PMMay 27
to Android-x86
no, I won't try anything I'm not familiar with.That's not give it to me I'll use it things.

Huy Minh Bùi

unread,
May 31, 2022, 1:26:34 PMMay 31
to Android-x86
update agian : it still can't be able to bind mount, even without Magisk
I guess I have to switch the base to something else like Bliss and start over, this feels wrong

Vào lúc 03:49:17 UTC+7 ngày Thứ Bảy, 28 tháng 5, 2022, youli...@gmail.com đã viết:

Huy Minh Bùi

unread,
Jun 26, 2022, 5:34:39 AMJun 26
to Android-x86
I found the culprit, it's actually a check in vold. on Utils.cpp there's IsSdcardfsUsed that check for both external_storage.sdcardfs.enabled and if there's sdcardfs on /proc/filesystem .

Here's my fix, it should only require external_storage.sdcardfs.enabled to turn on and off bind mounting
Here's the result, test on BlissOS 15.6
Screenshot_20220625-220137_Termux.png
Vào lúc 03:49:17 UTC+7 ngày Thứ Bảy, 28 tháng 5, 2022, youli...@gmail.com đã viết:

Huy Minh Bùi

unread,
Jun 26, 2022, 5:42:44 AMJun 26
to Android-x86
which makes me understand why your build work while mine doesn't. You compiled both sdcardfs and esdfs
Vào lúc 16:34:39 UTC+7 ngày Chủ Nhật, 26 tháng 6, 2022, Huy Minh Bùi đã viết:
Reply all
Reply to author
Forward
0 new messages