Android mount external sdcard obb to internal SD card succeed


Question

(I posted this question on Stack Overflow before(https://stackoverflow.com/questions/42738392/android-mount-obb-to-external-sd-card-failed), then I found here may be a better place to post this question.)



I want to move a game's obb(1GB) to SD card.
Copied the obb file to SD card, and symbolic link by:



su
ln -sf /storage/sdcard1/Android/obb/com.game /sdcard/Android/obb/com.game


but failed with "function not implemented".



I googled it, and got "some filesystem doesn't support symbolic link".



So I tried to use mount by command:



su
mount -o bind /storage/sdcard1/Android/obb/com.game /sdcard/Android/obb/com.game


but I found only root can see the files in the folder.
Then I do:



cd /system/bin/
chmod 4777 ./toolbox #make anyone can use mount(in toolbox)
su u0_aXXX #the game's uid
mount -o bind /storage/sdcard1/Android/obb/com.game /sdcard/Android/obb/com.game
ls -l /sdcard/Android/obb/com.game
$ -rwxrwx--- u0_aXXX sdcard_r com.game.obb


But when I



cat /sdcard/Android/obb/com.game/com.game.obb
$ cat: /sdcard/…ame.obb permission denied


I'm using android5, any solution?
Thanks.


Answer

(If you're finding how to move obb to external sdcard and mount it back to internal, here's the right place!)
Finally I found the solution of this question by myself!
The app can't access the obb by itself, it requires media_rw to access it.
Found by lsof:



sdcard 340 media_rw 15 ??? ??? ??? ???
/data/media/obb/com.game/com.game.obb
sdcard 340 media_rw 17 ??? ??? ??? ???
/data/media/obb/com.game/com.game.obb
com.game 26335 u0_a266 36 ??? ??? ??? ???
/storage/emulated/0/Android/obb/com.game/com.game.obb
com.game 26335 u0_a266 37 ??? ??? ??? ???
/storage/emulated/0/Android/obb/com.game/com.game.obb


So I have to mount the external sdcard folder to two places and each has to have its right owner:



owner
 folder
u0_a266 /storage/emulated/legacy/Android/obb/com.game
media_rw /data/media/obb/com.game


But if I mount /storage/sdcard1/Android/obb/com.game to those two places, it will become:



owner
 folder
u0_a266 /storage/emulated/legacy/Android/obb/com.game
u0_a266 /data/media/obb/com.game


Then I found if I do:



mount -o bind /storage/sdcard1/Android/obb/com.game /storage/emulated/legacy/Android/obb/com.game
mount -o bind /mnt/media_rw/sdcard1/Android/obb/com.game /data/media/obb/com.game


I found this works fine, because the mount command's source and destination is their original owner.
The app can run very well!


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes