Related
hi all! im new TF user but i tough i could post here some fixes and scripts that i use on my Samsung galaxy 3 but beaware that i have not tested these but they should work on every device im not responsible for any damage that may occur when you apply these scripts!!
1st there are 3 app2sd scripts
What is App2sd? App2sd is a utility which automatically moves some/all your data partition to your ext sd partition. So, your internal space is partially/not used
Which app2sd version should i choose? As you can see, there are 3 versions: App2sd-v1, App2sd-v2 & App2sd-v3.
Differences in versions App2sd-v1: It is the normal app2sd script. This script moves your /data/app/ & /data/log/ to your sdcard's ext partition. It is very fast but your real internal space will be full if you install many apps. This version is not recommended. App2sd-v2: It is an enchanced version of app2sd, which moves /data/app/, /data/log/ & /data/dalvik-cache/ to your sdcard's ext partition. It is fast and you can install many apps until your internal memory reaches 0mb.. Is is recommended for sdcards class2 - class4. App2sd-v3: It is an ultra enchanced version of app2sd, which is like data2sd, but you won't have so many lag like data2sd. App2sd-v3 moves /data/app/, /data/log/, /data/dalvik-cache/ & /data/data/ to your sdcard's ext partition. Your internal memory won't be used unless you do install so many apps and your sdcard's partition get full! SDcard class6+ is highly recommended! Conlusion: If you have class2 or class4 sdcard use App2sd-v2. If you have class6 sdcard use App2sd-v3.
Requirements You must have a kernel which supports init.d & ext4. And you must have an ext partition in your sdcard. Ext4 is recommended. And last thing... You need android 2.2.
How do i check my sdcard's class? Remove your sdcard from your phone and check if you see a circle with a number. If your dont see anything, you may have a class2 sdcard.
How to partition my sdcard? Download MiniTool Partition Wizard Home Edition 6.0. But make a backup before
How to install the script? Take a nandroid backup. Download it from links below and decompress it to your sd. You can either adb push this script in /system/etc/init.d/ or copy it with root eplorer to /system/etc/init.d/. Type the commands: adb shell (adb only) su mount -o rw,remount /dev/block/stl6 /system chmod 777 /system/etc/init.d/* chown 0.0 /system/etc/init.d/* Then reboot in recovery and do a wipe data/factory reset. All your data will be wiped. From now on some/all of your data (depends on the script version) will be moved to your sd automatically. Before you restore your apps with titanium, go in titanium preferences and select to force restore apps to internal memory. Don't move apps to external!!
Why i see only 200mb as internal? App2sd is invisible You can check your sdcard's ext partition in Titanium Backup.
=> app2sd script v.1
http://forum.xda-developers.com/attachment.php?attachmentid=592379&d=1305062488
=>app2sd script v.2
http://forum.xda-developers.com/attachment.php?attachmentid=592380&d=1305062488
=> app2sd script v.3
http://forum.xda-developers.com/attachment.php?attachmentid=592381&d=1305062488
credits go to KYRILLOS13 who introduced these on SG3!
then there is sd card reading speed fix
How to make it work!
At first it needs root & busybox...
Download the script, choose the cache size you want between 1024, 2048, 3072, 4096 kb! (Recommended size: 2048kb)
Extract the .zip file you downloaded and put the 77sdcardspeedfix in your sdcard.
Run root explorer and move the file in /system/etc/init.d/ (If there is no init.d folder, create one!).
You can also adb push 77sdcardspeedfix /system/etc/init.d/
Run a Terminal Emulator/Adb and type the commands:
Code:
adb shell (if you are using Terminal Emulator, skip this command)
su
chmod 777 /system/etc/init.d/77sdcardspeedfix
chown 0.0 /system/etc/init.d/77sdcardspeedfix
reboot
After that the phone will reboot. You will see that your sdcard reading speed has increased!
thanks for BRAINMASTER who made the script!
more scripts coming soon!!
[HOWTO] get ADB up and running (easy way)
ADB is an acronym for Android Debug Bridge and is a development tool for the Android Mobile Operating System
NOTE this is only for windows!
-open this link --> http://adf.ly/Xfyl wait 5 secs and click upper right corner "skip ads" it will download a program that automaticly installs android sdk (wich includes ADB)
-Open the app, leave the destination as C:\ and click ok/install
-Installing ADB/USB Drivers:
*NOTE* You may need additional (Device Specific) Drivers for your Device!
- Connect your Android Device to your PC using the provided USB Cable or just a plain ole 6-pin to 4-pin usb cable... (I prefer to use one with a ferite core)
- When the new hardware device notification pops-up on your pc point windows to the driver folder we moved to our C-drive(C:\android-sdk-windows\google-usb_driver) and install the adb driver.
** if your having issues with installing ADB drivers read this --> http://dl.dropbox.com/u/20575563/ADB...or_dummies.pdf
-Running ADB from the Command Prompt:
-Windows XP: Select Start or Tap the Windows Key on your Keyboard, select
"Run" and type "CMD" then hit "Enter".
-Windows Vista/Win7: Select Start or Tap the Windows Key on your Keyboard, select the search box on the left and type "cmd" then hit "Enter".
Add the "ADB" directory path as a system variable in windows:
-To do this right-click on "My Computer" and select Properties. Next select the Advanced tab(Advanced Settings in Vista/7) then select Environment Variables.
-Click "New" under System Variables and add the following:
Variable =
Code:
adb
value =
Code:
C:\android-sdk-windows\platform-tools
-Call up your Command Prompt:
Time to start adb
- Open up a Command Prompt Windows
- Type the commands below:
Code:
cd C:\android-sdk-windows\platform-tools
<= press enter
Code:
adb.exe
<= press enter
and voila You will see alot of scripting fly through the command prompt window.
***note! you have to enable usb debugging in --> settings --> applications --> developement --> check usb debugging
tutorial is not made by me, its made by AndroidSamurai. i found it after lot of researching, so i tough i could share it with you!
[HOWTO] edit BUILD.prop
1. open root explorer
2. go to /system, find build.prop, change to read/write mode. open the build.prop in text editor
* change build version: 4th line should say ro.build.display.id=(here you write your build version name), reboot and check build version in "about phone"
* change model number: 15th line should say ro.product.model=(here write your model number ), reboot and check model number in "about phone"
* change firmware version: 8th line should say ro.build.version.release=(here write your firmware version, like 4.x ice cream sandwich), reboot and check firmware version in "about phone"
you can also change different things but ill write a guide of that later
hope you like it!
also reserved for later use
updated how to´s
over 100 views but no replys.... are you there ? if you like these ill provide more scirpts, how to's and fixes
Considering the TF is android 3.x based I assume this is just a typo in the first post "Requirements You must have a kernel which supports init.d & ext4. And you must have an ext partition in your sdcard. Ext4 is recommended. And last thing... You need android 2.2."
Thanks for the post
1 question:
WHY use app2sd on a device with 16gb of internal storage?
DroidRevenge said:
1 question:
WHY use app2sd on a device with 16gb of internal storage?
Click to expand...
Click to collapse
well, maybe you have 16gb of music and you wnt to have somegames too : D
jazux said:
well, maybe you have 16gb of music and you wnt to have somegames too : D
Click to expand...
Click to collapse
Why not put the music on the microsd card instead? Then you wouldnt need apps2sd.
stuntdouble said:
Why not put the music on the microsd card instead? Then you wouldnt need apps2sd.
Click to expand...
Click to collapse
true.. well the script is there if someone wants it
jazux said:
true.. well the script is there if someone wants it
Click to expand...
Click to collapse
Ehhh....just a couple notes about the "speed fix" at least. First, it's easy enough to test using hdparm. Second, none of those scripts will work for the external card because that's not where the readahead knob is located. Third, the only script that will work is one that would be exceptionally ill advised to use. The scripts writing to .../vold/179:0 or mmcblk0 adjust the readahead for all of the mmc0 partitions, ie, /system, /cache, /data, etc. If you set readahead to some obscene value, you'll certainly end up thrashing data as you do all sorts of unnecessary readahead. (ie, you readahead on a file, you don't use the section of data which was read ahead, it gets flushed from memory, you readahead on another file, don't use it, it gets flushed from memory, etc, etc.)
Fourth, I actually did test this when I first got my Transformer, and the difference is read speeds was only about 1.5% for a readahead value at the default 128kB or 2048kB for either the internal or my external class 10. YMMV.
edit - Please update the op so we don't keep spreading bad information.
Waste Thread
lol don't you think this thread is crap and it should be deleted
jazux said:
true.. well the script is there if someone wants it
Click to expand...
Click to collapse
But does it work with android 3.2??? or only 2.2?
stuntdouble said:
Why not put the music on the microsd card instead? Then you wouldnt need apps2sd.
Click to expand...
Click to collapse
because some reason the stock music player and many other music player dont even read music on the microsd card.
Add the fact we are starting to get large games that has gigabyte worth of data to download(shadowgun)
victorythagr8 said:
because some reason the stock music player and many other music player dont even read music on the microsd card.
Add the fact we are starting to get large games that has gigabyte worth of data to download(shadowgun)
Click to expand...
Click to collapse
What are you talking about? The stock music app absolutely DOES read music off the microSD. I don't keep any music on the internal SD.
You guys are arguing over a several month old thread that someone necroed.
philburkhardt said:
What are you talking about? The stock music app absolutely DOES read music off the microSD. I don't keep any music on the internal SD.
Click to expand...
Click to collapse
i confirm it,i have msic on sdcard and gb of gameplay files on internal memory from the day that i buy transformer,half summer!
Jazux thanks so much you rule
Sent from my Transformer TF101G using Tapatalk
Hi,
I have an i9000 and unfortunately, the internal sdcard is not recognised at all.
I can only boot using voodoo 500hz kernel, to bypass this problem.
All other kernels will fail at boot screen (reboot loop).
After booting with voodoo kernel, I've rooted the phone and connected through ssh to it (adb shell)
Listing devices in /dev/block showing nothing like mmcblk (/dev/block/mmcblk0)
I thought it must be the card itself or the controller so I went and bought an external sd card (8gb).
After I insert it, the phone shows it has 0 (zero) capacity , tried to format it to fat32, ext2, etc, both on device (parted) and computer (windows, linux). Not a chance. Tested it using a i9100 I also own and the card was recognised correctly.
Next step was to check if the controller still works so again adb shell and checked for a mmcblk device in /dev/block.
This time, a /dev/block/mmcblk0 and /dev/block/mmcblk0p1 / /dev/block/mmcblk0p2 were listed.
Removed the external card, no device at all so the internal sd card is gone for good.
Next step was to use a hack to swap the internal/external sd cards in (/etc/vold.fstab), but even it is recognized in recovery mode (I can factory format/ wipe data), still 0 size in android interface and I can't use Camera and other apps.
I tried to mount it manually, directly on phone (adb shell), with mount comand and it works! I can create files on it, which are persistent.
So the controller actually works and the card is recognised low level.
BUT, why Android interface (java layer) won't recognize it? It says it's there but size is 0.
Please help, I can't use a lot of features on the phone, I don't know what to do.
Tried to mount it manually (to /mnt/sdcard), and even it get mounted and everything works on shell (creating files, etc), still 0 size in Android.
Running df in shell shows the correct size.
Checked the fstab / vold.fstab / vold.conf , everything seems to be ok.
Can anyone help me to fix this issue? Or at least, to give me some clues / ideas? I've lost several nights and I can't find a fix.
I'm good at linux but don't know very much about Android and it's java layer over linux.
It happenned to me too... not sure it can help you, but this is how i fixed my problem:
1. connect i9000 to the pc thru usb.
2. found a filename "no media" in the root directory.
3. erase the "no media' filename and everything is back to normal.
Did you fix it? I have the same problem and can't find a solution yet
Description:
A small command line tool to create, delete, enable or disable swap file on sdcard and autostart swap file or partition on boot (zRam (compcache) is configured through system Settings))
Features:
- Automatic detection of partitions and files: if you do not have a dedicated swap partition, script uses swapping to file - first on sd-ext and if that one does not exist then it swaps to sdcard. Swap partition takes precedence over files. This should work no matter if you have or do not have ext partition (for app2ext) on sd card.
- create and delete swap file - you can test different sizes without rebooting
- ability to start and stop swapping where ever it may be configured: biggest advantage of this is that you can stop swap if you have it on your /sdcard so you can use mass storage mode. Also, you can test various sizes for swap files or how your system works when swap is disabled, without need for a reboot
- misc. activities: view status of swap partition/files and status of memory
Usage:
Code:
Disable startup: swapconf 0 -> disables startup script
Enable startup: swapconf 1 -> enables startup script
Create swap file: swapconf mkf size_in_MB -> creates swap file of specified size (e.g. swapconf mkf 30 for 30MB swap file)
Remove swap file: swapconf rmf -> removes previously created swap file
Start swap: swapconf start p|f -> starts swapping to partition (p) or file (f)
Stop swap: swapconf stop -> stops swapping whereever it may be started
View swap status: swapconf status -> view status of swaps and memory
NOTE: Enabling both swapping to partition and to file is not supported.
If you have a dedicated swap partition on sdcard it will be used if enabled. Otherwise you need to configure swap file.
The attachment is OpenRecovery flashable update zip. Simply apply update.
Startup script should persist across new ROM updates until you do a factory reset (wipe data)
Feedback is welcome
Changes for version 0.2:
- relocated script from /data/local/bin to /system/bin: if your terminal app does not export /data/local/bin to PATH that should not be an issue anymore. Script should still persist across ROM updates [thanks to kabaldan for the tips ], startup script should persist until you do a factory reset (or you delete/disable it ).
- reworked script commands: previously you were not able to create swap file without enabling startup script
- improved partitions detection
- fixed a bug where you could not stop swapping to file if zRam was active
- mics. fixes and cleanups
Changes for version 0.2b:
- fixed backup of swapconf script during ROM upgrade on CM10
Notes:
- script will not persist when changing different ROM versions, e.g. from CM7 to CM10
- kabaldan and Skrilax_CZ have informed me that it is a bad idea to have active swap on sdcard's FAT32 partition unless there is an app that will disable swapping when the sd card is going to be mounted to PC. So far, the only issue I have noticed is that you can not mount USB mass storage mode until you turn off swap so I left that possibility enabled. The choice is yours (btw., it uses fat32 partition only if you have no dedicated swap partition or ext partition).
Thanks a lot for the info.
Bravo mrvek!
"Svaka cast!"
Sent from my Milestone using xda app-developers app
Great piece of swap tool! Great jobs mrVek!
in my case i can't directly cmd 'swapconf status' as shown in your screenshot, but have to cmd 'sh swapconf status' than the script run...
Thank you anyway, save me lots of time.
@arttree: that's odd. I haven't had such issues. Do other commands have the same issue? What rom are you using?
That seems like a permissions problem, execute perm. maybe missing. I'll look into it. You can try to chmod 755 /data/local/bin/swapconf to see if it'll help.
/data/local/bin/swapconf permision is 755. i installed/flashed it using update-OR-swapconf.zip you posted in 1st post.
anyway other than execute using "sh", everything work fine, even after reboot my MS, swap partition detected automatically.
Do you have /data/local/bin in your PATH? Or you always navigate to /data/local/bin?
Try this:
echo $PATH
To see if /data/local/bin exists in your path, if not then:
export PATH= $PATH:/data/local/bin
after that you wont need "sh" or "./" before swapconf (and you will be able to execute swapconf cmd from everywhere)...
Remember that this is not permanent PATH export, you need to do that everytime, as mrvek guided me, in terminal's settings there is an option to execute some commands on console startup (similar to .bash_profile) and you should put there "export PATH= $PATH:/data/local/bin" so you don't have to do that every time on console startup.
Sent from my Milestone using xda app-developers app
great tips! It work! Thanks.
Little problem:
$ su
# swapconf 1
[[: /dev/block/mmcblk0p1: unknown operand
Created configuration.
Enabled startup script.
#
Seems like the script thinks that mmcblk0p1 is swap - but that's my ext-partition...
My swap is mmcblk0p2
But it seems like I'm misinterpreting this error, am I not?
Sent from my Milestone using xda app-developers app
Eiertschik said:
Little problem:
$ su
# swapconf 1
[[: /dev/block/mmcblk0p1: unknown operand
Created configuration.
Enabled startup script.
#
Seems like the script thinks that mmcblk0p1 is swap - but that's my ext-partition...
My swap is mmcblk0p2
But it seems like I'm misinterpreting this error, am I not?
Sent from my Milestone using xda app-developers app
Click to expand...
Click to collapse
mmcblk0 is sd card, if present. mmcblk0p1 is first partition and should be FAT32, mmcblk0p2 is second partition (ext, and it must be p2 because some things in system assume that ext is 2nd partition if it exists, otherwise it won't mount it) and mmcblk0p3 is 3rd (usualy swap).
Neverthelss, these are issues, especially on CM7, with the script that need to be fixed asap.
Updated OP with new version (0.2).
I have tested it with different configurations and it seems to be working. Let me know if I missed anything.
Thank you all for your feedback.
I hope not being nasty, more between your script and what we've used (-FuFu-v5), is there any difference important?
with this script you can config your settings by using the terminal
my script only aktivate swap and creates a swapfile (if needed), to config my script you must edit the script itself
Yes, interactivness.
ty!
bug fix
Updated OP (again).
Only change was a fix for CM10 so it should persist between rom upgrades (ie., swapconf script is properly backed up during CM10 install).
I'm sorry for the trouble, haven't noticed it before.
thank you for improving your scripts. Great piece of script that our life a lots lots easier.
btw, if i used swap file option, do i need to manually stop it before i enable the mass storage(connect to PC)?
arttree said:
thank you for improving your scripts. Great piece of script that our life a lots lots easier.
btw, if i used swap file option, do i need to manually stop it before i enable the mass storage(connect to PC)?
Click to expand...
Click to collapse
Yes but only if swap file is on sd card fat32 partition. If you do not have an ext partition then it was created in sdcard's fat32 (/sdcard/.swapfile)
If it is on your fat32 partition and is active you need to stop it before connecting to mass storage mode.
Please note that intended purpose of startup script is to enable swap on boot. To do that it uses certain priority - first it tries swap partition, if that did not exist then it tries ext partition (if you created file) and the last resort is sd card fat partition (also needs pre-created file). The same applies to manual creation of file - ext has precedence over fat32.
I guess that is not a design flaw.
is it fullly compatible with Compcache of zRam?
gambarini said:
is it fullly compatible with Compcache of zRam?
Click to expand...
Click to collapse
Hm... not sure if I understand.
zRam/compcache is controlled in ROMs settings.
On the other hand you can have zram enabled and still use this scrip to configure swap to partition or file but you can't manipulate zram with this script.
August 4th 2013 - This script has not been maintained in a while. A big thank you to Captain_Throwback for providing continued support.
This is now minimally supported. Now that CM is adding native NTFS/exfat support, the only thing my script handles is multiple partitions.
July 21 2014 - Thank you n01ce! Please see n01ce's post for a "6.5 Alpha" that may solve some checksum problems with exFAT. I have changed devices, so this thread is for historical purposes/legacy support.
"HELP! I accidentally made my exFat card unreadable!!" -- or-- "I can't see more than 1 partition in windows!!"
Please read the instructions at the bottom of THIS POST HERE. No data will be lost!
"My card was working up until a moment ago but now the phone is showing "card damaged!!"
Re-run the script by typing "fuse-mountsd.sh" as root. The script will attempt to repair and re-mount.
If that fails, run "chkdsk /f" in Windows. Do not reformat until it is the last resort!
TL;DR: (Flash this), put exFat/FAT32/NTFS/EXT4 sdcard in, reboot.To remount, type "fuse-mountsd.sh" in a console (or) run using RomToolbox Lite (in /system/xbin/)
Needs to be run every time card is ejected + reinserted -- including when UMS is used
To unmount, type "fuse-mountsd.sh umount" (or if 1 partition) use Storage Manager
Non-customized multi-partitions mounted in /storage/<their name>
Uses init.d to fix/mount at boot
Scans for/mounts all useable block devices (with safety checks)
User-specifiable dynamic mount points
~~Create a ".mounthere" file in the partition with the first line "/location/to/mount/at"
~~Use the first line "skip" or "SKIP" to bypass that partition
Rescans for media when you re-mount
Repairs typical exFat damage caused by CM10.1 (with safety nets)
FAT32 support
NTFS-3g support (noatime set to reduce wear)
EXT4/3/2 support (*fuse built into JB/CM10.1) <- (MTP+EXT4 permissions need to be set to media_rw:media:rw 775!!))
Cleans up after itself: disables/enables ADB/root-security to what you set
BUGS:
All -- ntfsfix does not work. Binaries need to be recompiled. Not a major issue only dead weight.
exFAT may prevent deep-sleep. (NTFS on GS3 doesn't seem to have this issue.)
If you use EXT4/3/2, you need to run the following commands to allow the card to be accessed by the mobile-user:
Code:
find /storage/sdcard1/ -print0 | xargs -0 chown media_rw:media_rw
chmod -R 775 /storage/sdcard1/
(or)
find /storage/sdcard1/ -print0 | xargs -0 chown root:media_rw
Other phones -- Post a debug.txt if it works for you.
CM10 (4.1.x) -- Support is experimental. Use at your own risk.
CM 10.1 (4.2.x) -- Implemented RSA Key Signing Fix, works with BOOTICE.exe partitioned cards.
EXPERTS:
Everything is softcoded thanks to the $SECONDARY_STORAGE, $ANDROID_DATA, $ANDROID_STORAGE, $ANDROID_CACHE env variables and get/setprop command. Some locations are hardcoded in the script's "analyzePhone" function as fallbacks.
To custom-map mountpoints, create a ".mounthere" file in the root of each partition. "skip" or "SKIP" = ignore partition at mount, "/your/path/here" will use that path (or the default if bad). Defaults to "$ANDROID_STORAGE/device_id" if directory is invalid. Removes any temporary directories (in /storage/ only) at unmount. YOU HAVE TO CREATE ANY CUSTOM DIRECTORIES OUTSIDE "/storage" YOURSELF -- I set it like that as a security precaution.
To disable "Directory Creation Security", edit the line at the top of the script to say "dirSECURITY=0". This script will remount / and /storage as RW if needed.
Here is a quick rundown of typical use-cases:
You want one large (exFat/NTFS/ext4) partition:
No customization needed, just flash and go
You want a small FAT32 partition (p1) at the beginning (for firmware/CWM/TWRP) with another big ext4 partition (p2) for your SD card mount. [ Your ROM's vold will mount (p1:fat32) as /storage/sdcard1 automatically. To get it to swap over: ]
Create a ".mounthere" file on (p2) "big" partition with the text "/storage/sdcard1"
This will override Vold and mount the (p2) as external storage. The FAT32 partition will be mounted in /storage/mmcblk1. If you want to mount it elsewhere (even /data/media/0/extSD ! ) simply add another ".mounthere" on the FAT32 partition. (The directory must already exist -- you must make it beforehand -- or disable Directory Security feature.) Be warned - Vold will mount the first partition as /storage/sdcard1 any chance it gets -- even in the background -- unless there is something mounted there already (by this script).
You have (1) partition for a game app you play (internal storage) that you want to rebind, (2) another part you want to rebind OVER an existing directory, and (3) your main storage.
Create a ".mounthere" on (1) with text "/location/of/your/game/app/data"
".mounthere" on (2) with text "/folder/you/want/substituted"
".mounthere" on (3) with text "/storage/sdcard1"
You are a long-hair-hippie Linux developer with 4 partitions, each in a different filesystem, and want them mounted hidden from apps and listed by block device so you know what partition you are on:
No customization needed, just flash and go
SUPPORT:
I can only provide support if you supply me with logs. Do so by typing "fuse-mountsd.sh > /sdcard/debug.txt 2>&1" and opening the Debug.txt in your phone's storage.
It's all automatic now - so if it mounts your modem as writeable and kicks your dog don't blame me. (It excludes dangerous block devices automatically [mmcblk0, /system, mtdblock, etc], but there is always a 1% chance it will miss something.) If it does, report it here so I can fix it.
If you intend to use this with a other ROMs/phones, IT SHOULD STILL WORK. Post any errors or weird behavior.
Code:
Changelog
[I]7.0 - TBA (Make GUI? Fix ext4 permissions automatically? Get paid?)[/I]
6.4 - No longer uses "mount" output (wasn't acting standard-ly. Using /proc/mounts instead)
- [COLOR="Red"]Got rid of conv=notrunc[/COLOR]. Be careful!
6.3 - Bugfix to scrubMount code
6.2 - No longer Experimental / final unstable
- added rough ext2/3 support
6.1 - mount command bugfix
6.0 - Added a bypass for Directory Security, fixed some bugs.
5.9 - Rewrote NOGO code from scratch -- UUIDs ignored
5.8 - (??)
5.7 - Support for Note2 formatted exFat cards + more (0xf4 bug)
5.6 - bug fixed: no longer detects zram/assumes multimount
5.5 - [COLOR="Red"]Experimental support for weird devices[/COLOR]
5.4 - [b]Major bugfix!![/b] Fix fixmyexfat.sh coding fail
5.3 - Fixed "vffat" support. Undid HARD QUIT on bad Nogo, made it a soft one.
5.2 - Increased logging of tables, HARD QUIT if Nogo not found
5.1 - Quick patch to fix dm-* device blacklist
5.0 - [b]SUPPORTS MULTI-PARTITIONED CARDS! Autoscans for block devs! Complete rewrite![/b]
4.1 - Quick patch to check mmcblk1
4.0 - [B]WORKS 100% ON 4.2.2!![/B] My script is the first to achieve this AFAIK
3.3 - fixed a bug detecting existing mounts (related to "non-persistent mount points" issue)
3.1 - added dynamic exFAT repair code
3.0 - added NTFS/ext4 support
1.0 -> 2.0 <Removed>
Attribution credits:
Original thanks go to originator of the method, smitna in the Galaxy S2 forum. Additional thanks go to shardul_seth (Post 23) for compiling the latest version of the fuse-exfat and ntfs-3g binaries for ARM, and of course Andrew Nayenko for his efforts in creating GPL'd exFat code (fuse-exfat on google code).
[HOWTO][exFAT][WORK IN PROGRESS] Mount exFAT formatted drives and cards - smitna
Full NTFS Read Write support for Android (ARM) - shardul_seth
[HOWTO][exFAT][CM10.1] Working 64GB ext sdcard with fuse-exfat (1.0.1) + FIX broken (my original Dev thread)
I believe the term is I "kanged" their binaries. The rest is mine. This is a "mod"/"hack" until CM adds native support. (If ever: exFat)
DONATIONS:
https://supporters.eff.org/donate , or help a noob by linking to a solution in their thread. :good:
https://plus.google.com/+CyanogenMod/posts/ib5wz8jk1JyOne of the CM Team has flesh eating bacteria! Keep CM alive! (Literally)
I'm a noob, this looks scary to me. Either way, I needs me some exfat cuz my movies are too large for fat32.
My only question is: Even though this is written for CM10.1 on Verizon s3, might this also work on T-mobile s3 with an AOSP (Android 4.2.2) ROM?
Here's what I'm running:
SGH-T999 (d2tmo)
Android 4.2.2
Kernel: 3.0.62-cyanogenmod-g137df31
ROM: Liquid-JB-v2.1-RC1
Build:liquid-d2tmo-userdebug 4.2.2 JDQ39
I've spent the last 2 days searching and testing to no avail. My sdcard is running hot trying to get files larger than 4gb on it. I've tried formatting to exfat, ntfs, ext4, even hfs+, no success. Paragon and ntfssd apps couldn't mount it either.
Any help on this matter would be greatly appreciated!
Even though this might not work on T-mobile, thank you either way, I'm glad there are people like you developing for 64gb cards.
I wouldn't say I'm a developer, just a scripter with a lot of time on her hands.
lordazoroth said:
My only question is: Even though this is written for CM10.1 on Verizon s3, might this also work on T-mobile s3 with an AOSP (Android 4.2.2) ROM?
Click to expand...
Click to collapse
MAKE A NANDROID. This mod should do nothing permanently harmful anyway: it looks for EXFAT before writing anything.
Carrier doesn't matter. It only depends (1) if your kernel has FUSE support, (2) if it has init.d support and (3) what your Block device is.
I think Google added FUSE by default in JB, and anything based off CM10.1 will have it
Type "echo $SECONDARY_STORAGE" in a terminal emulator. If it displays ANYTHING other than blank it should work.
The Block device is trickier. Type "blkid" as root with with your FAT32 card in and out. The one that disappears is your Card's Block device, and should be /dev/block/mmcblk1p1.
If you have any doubts, don't do it.
HMkX2 said:
I wouldn't say I'm a developer, just a scripter with a lot of time on her hands.
MAKE A NANDROID. This mod should do nothing permanently harmful anyway: it looks for EXFAT before writing anything.
Carrier doesn't matter. It only depends (1) if your kernel has FUSE support, (2) if it has init.d support and (3) what your Block device is.
I think Google added FUSE by default in JB, and anything based off CM10.1 will have it
Type "echo $SECONDARY_STORAGE" in a terminal emulator. If it displays ANYTHING other than blank it should work.
The Block device is trickier. Type "blkid" as root with with your FAT32 card in and out. The one that disappears is your Card's Block device, and should be /dev/block/mmcblk1p1.
If you have any doubts, don't do it.
Click to expand...
Click to collapse
Awesome instructions, very much appreciate it. Looks like it's time to get to work. I checked the zip file thoroughly and cross-checked it with my root directories to see if it overwrites anything and it looks like it just adds stuff. From what I've seen, this is the only game in town so I'll post back once I'm done.
If this does work, this is a godlike zip file and it does something nothing else can do right now
Ok still not mounting properly.
Here's what I did:
Typed "echo $SECONDARY_STORAGE" in a terminal emulator, showed "/storage/sdcard1"
Typed "blkid", showed "/dev/block/mmcblk1p1" only when sd card was inserted under fat32 file format
Formatted sd card to exFAT on PC, inserted back into s3
Flashed CM10.1_exFAT-mountsd_2.0_HMkX2.zip
Ran terminal emulator, typed su >> exfat-mountsd.sh got this:
[email protected]:/ $ su
[email protected]:/ # exfat-mountsd.sh
[exfat-mountsd v2.0] exFat autorepair and mount script for CM10.1 (HMkX2 CORE//XDA)
Automated mounting script for exFat on GS3
/storage/sdcard1 is not mounted. (OK)
Calling [fixmyexfat] on /dev/block/mmcblk1p1 (if needed)
Broadcasting: Intent { act=android.intent.action.MEDIA_CHECKING dat=file:///storage/sdcard1 }
Broadcast completed: result=0
[fixmyexfat v2.0] exFat header repair tool (HMkX2 CORE//XDA)
More robust than before!
Usage: /system/xbin/fixmyexfat.sh <block device, eg /dev/block/mmcblk1p1>
[fixmyexfat] Manual target is /dev/block/mmcblk1p1
1+0 records in
1+0 records out
512 bytes transferred in 0.166 secs (3084 bytes/sec)
Segment 1 (0:4) (BAD)
4+0 records in
4+0 records out
4 bytes transferred in 0.012 secs (333 bytes/sec)
Segment 2 (484:4) (BAD)
4+0 records in
4+0 records out
4 bytes transferred in 0.007 secs (571 bytes/sec)
Segment 3 (508:4) (BAD)
4+0 records in
4+0 records out
4 bytes transferred in 0.005 secs (800 bytes/sec)
Check complete!
Check complete, mounting and initializing...
########################## ATTEMPTING COMMAND ##########################
mount.exfat-fuse -o rw,dirsync,umask=0 /dev/block/mmcblk1p1 /storage/sdcard1
Attempting bypass...
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
connected to localhost:5556
List of devices attached
localhost:5556 device
Running ADB commands
FUSE exfat 1.0.1
ERROR: invalid VBR checksum 0xa04b8eb5 (expected 0x804d6ce4).
Broadcasting: Intent { act=android.intent.action.MEDIA_MOUNTED dat=file:///storage/sdcard1 }
Broadcast completed: result=0
Process complete!
[email protected]:/ #
Not sure how to read this...
Afterwards my notification panel says: "Damaged SD card : SD card is damaged. Try reformatting it."
Tried restarting s3, mounting in storage settings, reformatting in PC. Ran script 4 times on a fresh exFAT format with the same notification error (format was unrecognizable by s3 and PC after running terminal command "exfat-mountsd.sh" [don't worry didn't lose any data ]).
After each format to exFAT on my PC I placed a few images on the card to ensure it was functioning properly, /storage/sdcard1 directory is always empty.
Mounting in settings >> storage generates the same notification error: "Damaged SD card : SD card is damaged. Try reformatting it."
Any ideas?... it is detecting an SD there after mount attempts (despite exFAT format) interestingly enough. Though nothing is detected after a reboot unless another script or settings >> storage mount attempt is performed.
I should mention that I ran a "quick" format when formatting the SD card from Fat32 to exFAT, not sure if that might be relevant.
Hm... well, I can tell you what it means. Quick formatting is fine, I actually prefer it since flash memory has a limited life. Second, "chkdsk /f" in windows will repair your card + data -- the card isn't "damaged", it's just that 4 letters at the beginning were changed. (See: Segment1, Segment2, Segment 3 messages.) My scripts change those 4 letters back, in a safe-ish way.
Unfortunately, without having a hex-dump of your working exFat header I can't say what those four letters should be. I got mine using a program called Hex Editor Neo on what I had available, a Sandisk 64gb class-10, and are what I included in the script. When the letters don't line up like it expects, you get a checksum error.
Without that, there is one single thing you can try - but has a high likelyhood of success.
Use RootBox explorer, navigate to /system/xbin/ and DELETE the file called "fixmyfat.sh".
Turn your phone OFF. Eject the SD card
chkdsk /f the card or quick format it to fix it, put a test file on it from Windows
Put the card in your phone, turn on.The card must be in the phone before it is turned on.
If that works for you, and the card works, you can give me a hex dump pretty easily so I can edit the script. IF it works, and I highly suspect it will, get a hex dump by typing EXACTLY:
dd if=/dev/block/mmcblk1p1 bs=1 count=512 of=/sdcard/working_sd.bin <- corrected
That will place a text file in your internal sd card than you can post/send me. Again, thanks for bearing with me, this started out as something for myself then made better in the hopes other people could use it. If you could re-corrupt the card (by unplugging/replugging it while the phone is on) and send me a hex dump of the "Card Damaged" state, even better.
O.O... you are awesome!
I'll get on this right away, and I'd be happy to help any way i can
---------- Post added at 09:19 PM ---------- Previous post was at 08:52 PM ----------
OMG IT WORKS!!! the card mounted
I tried the line of code and it gave me an error:
[email protected]:/ $ su
[email protected]:/ # dd if=/dev/blk/mmcblk1p1 bs=1 count=512 of=/sdcard/working_sd.bin
/dev/blk/mmcblk1p1: cannot open for read: No such file or directory
1|[email protected]:/ #
My /sdcard directory seems to be a redirect to /storage/sdcard0 (i think), i have a lot of these (what appear to be redirects) on my phone now after upgrading from android 4.0.4 to 4.2.2. If I changed the end of that line of code to something like "of=/storage/sdcard0/0//working_sd.bin" (or any similar working directory), might that solve the problem or am I reading that wrong?
Thank you so much, this is... very powerful!
Great work on this!
Double post.
Please check my post for the correct DD command - I typed /blk instead of /block due to habit.
I'm glad it works. As long as you don't re-plug the card while it is on, you will have no problems. If you accidentally DO "corrupt" the card, just "chkdsk /f" in Windows, turn the phone off, put the card in, and turn it on.
And the biggest help you can give would be those headers. (I was looking at the exfat.fsck-fuse code, apparently even THAT can't fix it!) For the time being, I will re-do the scripts to display more information so I can troubleshoot more easily.
HMkX2 said:
Please check my post for the correct DD command - I typed /blk instead of /block due to habit.
I'm glad it works. As long as you don't re-plug the card while it is on, you will have no problems. If you accidentally DO "corrupt" the card, just "chkdsk /f" in Windows, turn the phone off, put the card in, and turn it on.
And the biggest help you can give would be those headers. (I was looking at the exfat.fsck-fuse code, apparently even THAT can't fix it!) For the time being, I will re-do the scripts to display more information so I can troubleshoot more easily.
Click to expand...
Click to collapse
Sounds bad, I don't know why all these companies are sticking with Fat32 after all these years. Fat32 has been obsolete since like 2000, don't we have open source formats like ext4 now? - that's my rant lol. Either way, it works and I got the file. Btw, this file acts strangely on my device, I couldn't see it in windows explorer during plugin and It wouldn't copy to my sd card even though other files seem to be copying fine. Had to email it to myself from my phone. Thank you so much for all your help, let me know if you need anything else
Rename the file and remove .rar extension before use, xda doesn't allow .bin extensions to be uploaded.
Quick question: If I shut the phone down and pull the SD, can I turn the phone back on and use it without the SD while I load the SD up with files, then power off, re-insert the SD and power on again? (like will it automount again?)
Yay!
HMkX2 said:
Please check my post for the correct DD command - I typed /blk instead of /block due to habit.
I'm glad it works. As long as you don't re-plug the card while it is on, you will have no problems. If you accidentally DO "corrupt" the card, just "chkdsk /f" in Windows, turn the phone off, put the card in, and turn it on.
And the biggest help you can give would be those headers. (I was looking at the exfat.fsck-fuse code, apparently even THAT can't fix it!) For the time being, I will re-do the scripts to display more information so I can troubleshoot more easily.
Click to expand...
Click to collapse
Very interesting. I can go on the hunt for headers if you like. I have loads of sd cards.
Oddly enough, I switched to FAT32 even though I'm on a TouchWiz ROM, cause exFAT does not use alternating file allocation tables. When exFAT gets borked, it gets super borked and you have to use chkdsk (or some other brutish method) to retrieve files. When FAT32 gets borked, you can load the last table that was working and elegantly pull your files off the card (no need to muddle through a pile of chkdsk files and find the correct extensions).
Any possibility that this method could be used to mount a more robust file system like ext[2,3,4]? Journaling would be nice. Or some transaction safe file system.
Ta very much,
ALQI
Re: [MOD] Flashable exFAT support for CM10.1 / AOSP roms (external SD)
Great.I'll try it.
Sent from my SCH-I535 using xda premium
lordazoroth said:
Sounds bad, I don't know why all these companies are sticking with Fat32 after all these years. Fat32 has been obsolete since like 2000, don't we have open source formats like ext4 now?
Click to expand...
Click to collapse
Why we have 15 competing standards... "Never attribute to malice that which is adequately explained by stupidity."
Btw, this file acts strangely on my device, I couldn't see it in windows explorer during plugin and It wouldn't copy to my sd card even though other files seem to be copying fine.Any files you create on the device without "Rescanning for media" will not be visible in the MTP (Mass Tranfer Protocol) "MP3 player-like" abstracted FUSE filesystem. (One reason why people want UMS (USB Mass Storage) "hard drive-like" support, you see things immediately/it's faster.) Get a free program called SDrescan from Google Play, or run the command below(?), to update the MTP index and see files you create ON the device.
Code:
am broadcast -a android.intent.action.MEDIA_MOUNTED -d file://$SECONDARY_STORAGE
am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///storage/sdcard0
...let me know if you need anything else Quick question: If I shut the phone down and pull the SD, can I turn the phone back on and use it without the SD while I load the SD up with files, then power off, re-insert the SD and power on again? (like will it automount again?)Yes, the mount script will simply fail and there will be a silent error. (I need to code some error checking if you insert a non-exfat card...)
Like I said, if you could intentionally re-corrupt the header by using Storage Manager to "Unmount SD" then "Mount SD", then the DD command, (and rescanning media to copy the file off!) I'd appreciate it. Although, I have a second idea of how to get around that problem in mind.....
alquimista said:
Very interesting. I can go on the hunt for headers if you like. I have loads of sd cards.
Click to expand...
Click to collapse
Thanks but I think the bottom line is (1) there is no working open source exfat.fsck anyway and (2) headers are unique per-device. The proper fix is re-coding vold to not run fsck.msdos on a fsck.exfat card.
Oddly enough, I switched to FAT32 even though I'm on a TouchWiz ROM, cause exFAT does not use alternating file allocation tables. When exFAT gets borked, it getse that wa super borked and you have to use chkdsk (or some other brutish method) to retrieve files. When FAT32 gets borked, you can load the last tabls working and elegantly pull your files off the card (no need to muddle through a pile of chkdsk files and find the correct extensions).
Any possibility that this method could be used to mount a more robust file system like ext[2,3,4]? Journaling would be nice. Or some transaction safe file system.Yep, that is all 100% true. But I've lost files on fat32 drives as well - and I'd hardly call multiple file tables elegant, especially when they become desynced. NTFS would be a better fix, except for the fact it is a magnetic-media filesystem with journaling/timestamps/excessive writes, and exFAT was designed for flash media in the first place!! Even EXT4 writes too much, EXT2 or EXT4 with journaling disabled is a better solution for integrity, but much worse for flash-life. Nowadays, the value of error-recovery outweighs the limited media life. (This discussion comes up a lot in custom Linux firmwares for routers: DD-WRT NVRAM/Flashdrives)
Shardul_seth, the gentleman that compiled these binaries, has made a package for full NTFS support already using ntfs-fuse3g. (<- link) NTFS-3g is very mature/stable at this point, and installation for our devices is even simpler since we already have FUSE support in the kernel. However, his scripts are to mount USB, not the SD card. Mine does the SD card - all those ADB workarounds - so absolutely could be adapted for mounting NTFS cards. I will work on that when I have some time -- I'd need to figure out how to identify a NTFS card on header alone.
Again, all these methods are HACKS, proper support should be added in the kernel at some point. Someone actually has, and I've been cheering for him. He added EXT4 support to CM10.1, his post and code are here. However, he says it "stalled in code review". For the time being, you have to do all this manually.
Why we have 15 competing standards... "Never attribute to malice that which is adequately explained by stupidity."
Click to expand...
Click to collapse
Nice post lol, I only meant why FAT32 of all choices, these companies must know we're gonna be packing large files at some point, why knee cap us at 4gb when so many formats don't? Universal would be nice but of course it's entirely impractical
Any files you create on the device without "Rescanning for media" will not be visible in the MTP (Mass Tranfer Protocol) "MP3 player-like" abstracted FUSE filesystem. (One reason why people want UMS (USB Mass Storage) "hard drive-like" support, you see things immediately/it's faster.) Get a free program called SDrescan from Google Play, or run the command below(?), to update the MTP index and see files you create ON the device.
Click to expand...
Click to collapse
Thanks for the media scan info, that'll help a lot, I'll try out your suggestions tonight
Yes, the mount script will simply fail and there will be a silent error. (I need to code some error checking if you insert a non-exfat card...)
Like I said, if you could intentionally re-corrupt the header by using Storage Manager to "Unmount SD" then "Mount SD", then the DD command, (and rescanning media to copy the file off!) I'd appreciate it. Although, I have a second idea of how to get around that problem in mind.....
Click to expand...
Click to collapse
Will do, sounds interesting, will there be data loss or just header corruption? second idea in mind?
Also, each time I take the card out of my phone (properly after shutdown of phone) and place it in my computer (vista 64bit ultimate) It asks to check for errors, i'll click continue (confirmation to check), takes 3-5 seconds, finishes with no errors found. If I don't do this the card is write protected. I've made sure only to disconnect from PC after "safely removing hardware" so it appears that usage in the phone is generating the confusion. This doesn't seem to be an issue but I thought it might be worth mentioning
do you enter it correctly?
I get this when running the script:
Code:
BREAK! /dev/block/mmcblk1p1 is not a block-special file/device, do you enter it correctly?
How do I find what block file I need to change to script to?
Thanks for your work
boricua1213 said:
How do I find what block file I need to change to script to?
Click to expand...
Click to collapse
Safest (not easiest) way is to insert your FAT32 card, type "mount|grep vfat". The one you are looking for says "/dev/block/vold___:__" . (Shortcut: "mount|grep vold");
Then type "blkid". The one that's listed twice (UUID or Label) as "vold" is your block device's other name. (/mnt/block/mmc_somethingorother) Both names lead to the same spot.
(or)
Type "blkid" with your card in. Make a list. Remove your card. Type "blkid" again. The one that dissapears is your block device.
Ok got the file, I created 2 files, 1 before and 1 after the force unplug, just in case.
Remember to rename the files without the .rar extension before use
Re: [MOD] 1-Click Flashable exFAT + NTFS + EXT4 support for CM10.1 / AOSP (external S
I am about to embark on this journey and make another attempt at ditching TouchWiz. Does this script make it as if everything is normal as far as apps accessing the SD card go? I assume so, but I'm specifically wondering if I'll still be able to use Directory Bind and if I'll be able to create symbolic links to redirect Google Music to the external SD.
Getting ready to flash and try anyway but figured I'd ask to see if someone knows the answer all ready.
I'll be the first to admit the problem is almost certainly user error on my part but I have been wholly unsuccessful with this mod. I have tried it on Carbon Rom and Paranoid Rom. I guess they both have FUSE support, I couldn't find any confirmation of that on the Rom threads....particularly Carbon.
I flashed the zip in the OP in CWM after installing both Roms clean. I tried installing the zip as soon as I installed the Rom and I tried installing it after doing a full boot up first. Ran the chkdks /f command probably 12 times after each successive failed attempt to get my 64 exFAT card recognized. Said Damaged SD no matter what I tried. I saw the post on Page 1 about deleting the fixmyfat file....tried that too and no go. That tip may no longer be relevant since you've updated the script.
Is there something I am missing? There are lots of posts in this thread about mount commands and adb, but it seems from the OP none of those things are supposed to be necessary.
spearoid said:
Does this script make it as if everything is normal as far as apps accessing the SD card go? I assume so, but I'm specifically wondering if I'll still be able to use Directory Bind and if I'll be able to create symbolic links to redirect Google Music to the external SD.
Click to expand...
Click to collapse
In short, it should. However, exFAT/FAT32 don't support permissions/softlinks like ext4 does. So if you use ext4, just remember to set permissions appropriately! When in doubt, set permissions to 755 root:sdcard_rw or root:media_rw on the external sd.
I have tried it on Carbon Rom and Paranoid Rom. I guess they both have FUSE support, I couldn't find any confirmation of that on the Rom threads....particularly CarbonType "mount | grep fuse" in console. If you see "fuse" listed anywhere in the text, you have it. Google added it to JellyBean.
I flashed the zip in the OP in CWM after installing both Roms clean. I tried installing the zip as soon as I installed the Rom and I tried installing it after doing a full boot up first. Ran the chkdks /f command probably 12 times after each successive failed attempt to get my 64 exFAT card recognized. Said Damaged SD no matter what I tried. I saw the post on Page 1 about deleting the fixmyfat file....tried that too and no go. That tip may no longer be relevant since you've updated the script.
Is there something I am missing? There are lots of posts in this thread about mount commands and adb, but it seems from the OP none of those things are supposed to be necessary.Do me a favor... open a terminal, type "su", then type "fuse-mountsd.sh > /sdcard/debug.txt 2>&1" (no spaces in 2>&1). It will make a "debug.txt" file in the root of your internal storage. Paste the output here. I am 90% certain you have the wrong block device set. 9% certain it is the 4.2.2 ADB thing.
You do not need to delete "fixmyfat.sh" -- those instructions are very old. Was the phone *physically off* when you plugged the SDcard in? Ignore the mount commands/ADB - you should not have to deal with them if you only plug in/unplug the card when the phone is off.
I am nigh certain it has to do with 4.2.2 messing with ADB. Like I said, for now, put in a *working* sd card *before* the phone is turned on and you won't run into that issue.
Disclaimer: I know that there are other ways to put apps and data on a sdcard which might circumvent the problems I have. I'm not looking for a practical alternativ, but for insight why things are like they are - understanding. This might or might not lead to a 'howto replace your device and keep your sdcard which is formated as adoptable storage'. I'm aware that understanding things might not lead to any practical help.
Also I searched XDA and the internet for information on this topic various times and didn't find anything helpful. If I oversaw something I'm greatful if I'm pointed to it.
I'm testing on two Sony Xperia Z1. Up till now I did the following:
Test 1:
- made backup of everything to usb otg device in twrp on Device1 (sdcard configured as adoptable storage)
- recovered backup of Device1 on Device2 (excluding trim area)
- put sdcard (adoptable storage) from Device1 into Device2 and started the system
- /dev/block/dm-0 is mounted on /mnt/expand/[uuid], but the sdcardfs-mounts to /mnt/runtime/default/emulated, /storage/emulated, /mnt/runtime/read/emulated and /mnt/runtime/write/emulated are missing.
- relocating the sdcard to Device1 shows that it is still working
Test 2:
- made backup of everything to usb otg device in twrp on Device1 (sdcard configured as adoptable storage)
- recovered backup of Device1 on Device2 (excluding trim area) (so far same as Test1)
- started Device2 inserted blank sdcard2 and generated new adoptable storage.
- shutdown Device2, removed sdcard2 and connected original sdcard1 (removed from Device1) and sdcard2 to a computer
- set up device mapper devices for partition 2 of both devices using the keys copied from the devices.
- mounted both device mapper devices and copied files of sdcard1 encrypted filesystem to sdcard2 encrypted filesystem
- umount of device mapper devices, remove of device mapper devices.
- replaced sdcard1 to Device1 and sdcard2 to Device2. Powered on
- Device1 working with all data found (gallery pictures, maps for osmand)
- Device2 had all the expected mounts, but osmand couldn't read its maps
- logcat showed that selinux stopped osmand from reading the maps directory inside the sdcardfs mount of the adoptable storage
- set selinux to permissive: osmand works as expected
Conclusion: On Device2 and/or sdcard2 selinux policies for osmands data on adoptable storage are missing. Since everything (except trim area) is copied from Device1 to Device2 and from sdcard1 to sdcard2 the policies either have to be in trim area (which as I understood is not available on all types of devices) or they are dependend on some device attribute (uuid of sdcard, s/n of device, etc.).
Ideas?
Chri^2 said:
Disclaimer: I know that there are other ways to put apps and data on a sdcard which might circumvent the problems I have. I'm not looking for a practical alternativ, but for insight why things are like they are - understanding. This might or might not lead to a 'howto replace your device and keep your sdcard which is formated as adoptable storage'. I'm aware that understanding things might not lead to any practical help.
Also I searched XDA and the internet for information on this topic various times and didn't find anything helpful. If I oversaw something I'm greatful if I'm pointed to it.
I'm testing on two Sony Xperia Z1. Up till now I did the following:
Test 1:
- made backup of everything to usb otg device in twrp on Device1 (sdcard configured as adoptable storage)
- recovered backup of Device1 on Device2 (excluding trim area)
- put sdcard (adoptable storage) from Device1 into Device2 and started the system
- /dev/block/dm-0 is mounted on /mnt/expand/[uuid], but the sdcardfs-mounts to /mnt/runtime/default/emulated, /storage/emulated, /mnt/runtime/read/emulated and /mnt/runtime/write/emulated are missing.
- relocating the sdcard to Device1 shows that it is still working
Test 2:
- made backup of everything to usb otg device in twrp on Device1 (sdcard configured as adoptable storage)
- recovered backup of Device1 on Device2 (excluding trim area) (so far same as Test1)
- started Device2 inserted blank sdcard2 and generated new adoptable storage.
- shutdown Device2, removed sdcard2 and connected original sdcard1 (removed from Device1) and sdcard2 to a computer
- set up device mapper devices for partition 2 of both devices using the keys copied from the devices.
- mounted both device mapper devices and copied files of sdcard1 encrypted filesystem to sdcard2 encrypted filesystem
- umount of device mapper devices, remove of device mapper devices.
- replaced sdcard1 to Device1 and sdcard2 to Device2. Powered on
- Device1 working with all data found (gallery pictures, maps for osmand)
- Device2 had all the expected mounts, but osmand couldn't read its maps
- logcat showed that selinux stopped osmand from reading the maps directory inside the sdcardfs mount of the adoptable storage
- set selinux to permissive: osmand works as expected
Conclusion: On Device2 and/or sdcard2 selinux policies for osmands data on adoptable storage are missing. Since everything (except trim area) is copied from Device1 to Device2 and from sdcard1 to sdcard2 the policies either have to be in trim area (which as I understood is not available on all types of devices) or they are dependend on some device attribute (uuid of sdcard, s/n of device, etc.).
Ideas?
Click to expand...
Click to collapse
The only understanding that you need is that you can't do what you're trying to do. You can't "transfer" adoptable storage from one device to another. You have to setup adoptable storage on the new device the same way it was done on the old device, from scratch.
The new device has to make its own "links" to adoptable storage, so to speak, the new device can't use the "links" from the old device, it has to create its own the same way the first device did. When the sdcard is adopted as internal, the device creates an encryption key that is specific to that device, another device can't use the sdcard because it will not recognize the encryption key that was created by the first device. As far as it is concerned, the data on the card may as well not exist because it can't "see" the data.
The encryption key "can" be used to retrieve the data on the adopted sdcard via PC, perhaps, but this encryption key can't be used to help the new device "read" the data.
This is similar to trying to use the hard drive and OS from one PC in another PC, but in android, it is more specific.
Sent from my LGL84VL using Tapatalk
Thanks for your reply, but it didn't help, because you didn't explain why the key should not be usable by another device. I'm looking for technical background: How does android prevent the use of the card even if the target system does know the correct key?
Furthermore I think that you're not right about this point - if you were right the following wouldn't have worked and the decrypted /dev/block/dm-0 wouldn't have existed on the second device:
Test 1:
- made backup of everything to usb otg device in twrp on Device1 (sdcard configured as adoptable storage)
- recovered backup of Device1 on Device2 (excluding trim area)
- put sdcard (adoptable storage) from Device1 into Device2 and started the system
- /dev/block/dm-0 is mounted on /mnt/expand/[uuid]
Click to expand...
Click to collapse
You can try it out if you have two similar devices - maybe I have to move the thread to Sony Z1, because on other devices the test I made doesn't work the same way.
Chri^2 said:
Thanks for your reply, but it didn't help, because you didn't explain why the key should not be usable by another device. I'm looking for technical background: How does android prevent the use of the card even if the target system does know the correct key?
Furthermore I think that you're not right about this point - if you were right the following wouldn't have worked and the decrypted /dev/block/dm-0 wouldn't have existed on the second device:
You can try it out if you have two similar devices - maybe I have to move the thread to Sony Z1, because on other devices the test I made doesn't work the same way.
Click to expand...
Click to collapse
Because each device has it's own "identity" to which each key is associated. The new device has a different "identity" and "key", if the data is not encrypted with the key that the device is looking for, it can't decrypt the key assigned to the data by the previous device.
Effectively, a simplified answer is to say that it is because the two devices speak a different language when it comes to their own encrypted data and there is no way to translate between the two to make encrypted data created on "this" device accessible or readable by "that" device.
It's similar to signatures that are assigned to apps and device firmware from various manufacturers. You can't flash a firmware from a completely different device because the software tools involved will not recognize or pass the signatures of different firmware, it will only approve firmware that has the signature it is looking for.
I could also be wrong, no one knows everything, but I'm certain that it is much deeper than you think.
Maybe you can adapt something from the thread below to work something out.
https://forum.xda-developers.com/general/help/corrupted-sd-card-adoptable-storage-t3801250
Sent from my LGL84VL using Tapatalk
Droidriven said:
Because each device has it's own "identity" to which each key is associated.
Click to expand...
Click to collapse
This is what I thought after my Test1 and has been the reason I did Test2 to check if it's true. But Test2 didn't work neither, because there seems to be some selinux policies missing.
I downloaded the source of vold. I'm no programmer and I'm really bad at reading source code. That said: I searched for 'expand_' to find some hint to the key files. Found function BuildKeyPath, which seems to generate a complete path to a key file. This function is used in 'status_t Disk:artitionMixed(int8_t ratio)'. The interesting part that might be the generation of the key for the encrypted partition is
Code:
// We've had some success above, so generate both the private partition
// GUID and encryption key and persist them.
std::string partGuidRaw;
std::string keyRaw;
if (ReadRandomBytes(16, partGuidRaw) || ReadRandomBytes(16, keyRaw)) {
LOG(ERROR) << "Failed to generate GUID or key";
return -EIO;
}
std::string partGuid;
StrToHex(partGuidRaw, partGuid);
if (!WriteStringToFile(keyRaw, BuildKeyPath(partGuid))) {
LOG(ERROR) << "Failed to persist key";
return -EIO;
} else {
LOG(DEBUG) << "Persisted key for GUID " << partGuid;
}
If this is the point in code where the key is generated I read it the way that the key is purely random and not dependend on any component associated with the devices identity.
Taken together with Test2 there are - in my opinion - strong hints pointing in the direction of selinux. Maybe I should retry Test1, but start the phone without the sdcard which then would be shown as missing, set selinux to permissive and then insert the sdcard. I guess I'll give it a go...
Now I found something interesting: I used twrp 3.2.3-0 on my Sony Xperia Z1 to wipe (advanced) all of the partitions of a phone I used to experiment with adoptable storage. Afterwards I looked at the partitions and found that on data existed the following files
Code:
/data/misc/vold/expand_[uuid1]key
/data/misc/vold/expand_[uuid2].key
/data/misc/vold/expand_[uuid3].key
/data/system/storage.xml
/data/.layout_version
To me it looks like twrp conserved those files and put them back after formating the data partition. However it did it and why it pushed me in the right direction.
Test3 on Xperia Z1 using twrp 3.2.3-0:
made backup of everything excluding trim area to usb otg device in twrp on Device1 (sdcard inserted and configured as adoptable storage)
connected via 'adb shell' to Device1 and made a tar archive containing the above mentioned files in /tmp
downloaded the tar archive from Device1:/tmp using 'adb pull'
recovered backup from usb otg of Device1 on Device2
pushed tar archive with keys, .xml and layout-version to to Device2:/tmp
connected via 'adb shell' to Device2 and unpacked the tar archive from /tmp to /data
started Device2: device complains that my sdcard with adoptable storage is missing
put sdcard (adoptable storage) from Device1 into Device2: sdcard is recognized and integrated as adoptable storage
/dev/block/dm-0 is mounted on /mnt/expand/[uuid] and sdcardfs-mounts to /mnt/runtime/default/emulated, /storage/emulated, /mnt/runtime/read/emulated and /mnt/runtime/write/emulated exist also
osmand works and is able to open the files on the adoptable storage. All other applications I looked at worked also
Can anybody try to confirm that this way works to move a backup from one device to another keeping the adoptable storage?
An interesting conclusion about selinux could be that it reads sometimes storage.xml to generate policies allowing the access to adoptable storage. Might be interesting how this works and whether manipulating storage.xml could be a way to inject selinux policies...