• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Proposal/Theory for External SD storage solution on F6

This is just some extra information for those users new to this phone and to Android. Please check post #251 first. This method is intended to make small, mostly reversible changes to the stock firmware. My implementation is developed and tested on MS500, stock firmware 12b. D500 is probably similar enough. I don't know enough about D505. If you decide to try, please have a backup of your data because no one can help you break Murphy's Law. I'll assume access to a Windows PC. Instructions for Linux systems would be even simpler. I don't know enough about Macs, but there should be enough info online to understand how to do the equivalent steps.

Preparing the SD card
Use Samsung or SanDisk.
Install MiniTool Partition Manager: Free Partition Manager for Window PC | MiniTool Partition Wizard Free Edition
Make the first partition primary, fat32, aligned to cylinder MB. <-- Aligning to MB is better. Sorry about the mistake.
Make the second partition primary, ext4, aligned to cylinder MB. <-- Aligning to MB is better. Sorry about the mistake.
Put the SD card into the phone.

Installing drivers and ADB
Connect the phone to the PC. Autorun should pop up. Running the LG program should install the drivers.
Download and install ADB. You can use a standalone version from: ADB Stand Alone | SourceForge.net .

Rooting the phone
You need to root the phone to modify system files. Get tr.apk from https://towelroot.com/ and copy it to the phone.
In Settings, Security, turn on Unknown sources.
Go to File Manager and install towelroot.
Run the app to "make it rain."
You can turn Unknown sources back to off.
You can uninstall tr.apk once rooting is successful.

Installing this hack
Extract the zip from post #251 onto the SD. You can do this from Windows to the phone or use File Manager on the phone. So now at the root directory of the SD's fat32 partition, there should be a folder /DataOnSD with three files in it.
Disconnect the phone from PC.
In Settings, Developer options, turn on USB debugging.
Reconnect the phone and open an ADB window.
Typing
Code:
adb devices
should show your device.
Type
Code:
adb shell
to get a prompt from the phone's shell.
Type (or copy and paste) the commands as described in post #252:
Code:
su
cd /storage/external_SD
touch LGF6DataOnSD_INIT
cd DataOnSD
sh installer.sh both
At this point, installation is basically done. Next, you need to decide whether you want to keep root. Note that removing root doesn't mean the phone is returned to the factory condition as far as rooting goes. The stock software keeps track of whether the phone's been rooted, and unrooting with the steps below doesn't remove that history.

Keeping root
Type "exit" three times to close the ADB window.
Disconnect cable.
Turn off USB debugging.
Install a superuser manager from the Play Store, either Chainfire's SuperSU or ClockworkMod's Superuser.
Optionally, install Busybox, which is used by many root apps.
Optionally, use File Manager to remove the /DataOnSD folder and its files from the SD card.

Removing root
In the ADB window, type
Code:
mount -o remount,rw /system
rm /system/etc/install-recovery.sh
rm /system/xbin/daemonsu
rm /system/xbin/su
mount -o remount,ro /system
exit
exit
exit
Disconnect cable.
Turn off USB debugging.
Optionally, use File Manager to remove the /DataOnSD folder and its files from the SD card.

If everything looks right, reboot the phone. File copying will take some time. After files are copied, the script will automatically reboot the phone once. Hopefully everything works. Good luck.

Uninstalling
If you need to uninstall the hack, you would almost do the same thing (root the phone if unrooted), except in the ADB window, you'd type
Code:
adb shell
su
cd /storage/external_SD/DataOnSD
sh installer.sh uninstall
exit
exit
 
How does this hack work with cwm backups? Can I backup and restore the ext 4 partition normally or will it just backup the internal /data? Anyone tried this?
CWM and TWRP will backup the internal /data partition. They do have /sd-ext support, which might work with the external /data partition. However, when I tried backing up on my Nook with CWM, it claimed not to have found /sd-ext, so maybe it was expecting ext2/3 or something. Well, now that you can "separate" your data from the phone, at least you can (and probably should) backup the SD card on a PC.

hello, I've been following this thread for weeks....does the beta work for lg optimus f6 rooted with stock rom? if so what are the steps? U guys are awsom keep up the great work
Both my alpha implementation and pressy4pie's beta mod should work on stock rom with Android 4.1.2. Euro version D505 can have 4.4.2 and the hack probably won't work with KitKat for now. For my implementation, check post #251 and maybe #301. pressy4pie's mod has its own thread as linked by shadowuser.

Hye WV,

I just checked out your new zips and the Install completes successfully and the copy also completes successfully but after a reboot i get the lg boot screen. After getting bck into recovery, it's telling me that it's
unable to mount
/data
/data/media
internal storage

also, uninstall failed...
Unable to mount /data

thanks
So you're using either MS500 or D500 with Android 4.1.2 stock rom? I'm running out of ideas why TWRP would still fail. Sorry my numerous attempts have failed to produce a fix for the TWRP issue. I'll try to install TWRP and figure it out at some point, but right now I'm experimenting with F2FS on the stock kernel and I'm hoping to not have to reset the phone in case of a boot loop. So if you need the (hopefully working) hack, please try another installation method. And if you are just being a willing tester for me, I thank you and hope to return to solving problems soon.
 
yeah WV it does work,the new ones (mostly with Xperion) and a couple older ones with the different version of KK (442) and CM11. I have been trying everything I can think of/search for/discover to get the newer ones working with KK 4.4.2 (euro 505 etc and/or CM11) but I havent been able to (yet...). The version in post #251 with the install method in post #253 works on Xperion but I was unable to get it working properly on the 4.4.2 or CM11 (F6). I'll keep trying because I think its a cool way to gain extra storage and it would be great to work across disparate ROMs (platforms etc.). If I am wrong and/or not in line with what you are trying to accomplish plz let me know.

I personally (with my limited knowledge etc.) think that because of the way the ports were put together, along with the locked bootloader (on these phones) requiring LOKI, and a bit of SElinux thrown in the mix that is whats causing the multiple issues. I can only think the best course (for these F6 phone in particular) would be to build a proper kernel. I think all the problems resonate from there. I very well could be wrong. Thats for greater experience from those people that have it (you WV, maybe GameTheory, Bard or Hroark13, maybe pressYforPie etc) to (hopfully) figure out, if they are so inclined. Else I will keep trying, the best that I (humbly) can.
 
This is just some extra information for those users new to this phone and to Android. Please check post #251 first. This method is intended to make small, reversible changes to the stock firmware. My implementation is developed and tested on MS500, stock firmware 12b. D500 is probably similar enough. I don't know enough about D505. If you decide to try, please have a backup of your data because no one can help you break Murphy's Law. I'll assume access to a Windows PC. Instructions for Linux systems would be even simpler. I don't know enough about Macs, but there should be enough info online to understand how to do the equivalent steps.

Preparing the SD card
Use Samsung or SanDisk.
Install MiniTool Partition Manager: Free Partition Manager for Window PC | MiniTool Partition Wizard Free Edition
Make the first partition primary, fat32, aligned to cylinder.
Make the second partition primary, ext4, aligned to cylinder.
Put the SD card into the phone.

Installing drivers and ADB
Connect the phone to the PC. Autorun should pop up. Running the LG program should install the drivers.
Download and install ADB. You can use a standalone version from: ADB Stand Alone | SourceForge.net .

Rooting the phone
You need to root the phone to modify system files. Get tr.apk from https://towelroot.com/ and copy it to the phone.
In Settings, Security, turn on Unknown sources.
Go to File Manager and install towelroot.
You can turn Unknown sources back to off.
You can uninstall tr.apk once rooting is successful.

Installing this hack
Extract the zip from post #251 onto the SD. You can do this from Windows to the phone or use File Manager on the phone. So now at the root directory of the SD's fat32 partition, there should be a folder /DataOnSD with three files in it.
Disconnect the phone from PC.
In Settings, Developer options, turn on USB debugging.
Reconnect the phone and open an ADB window.
Typing
Code:
adb devices
should show your device.
Type
Code:
adb shell
to get a prompt from the phone's shell.
Type the commands as described in post #252:
Code:
su
cd /storage/external_SD
touch LGF6DataOnSD_INIT
cd DataOnSD
sh installer.sh both
At this point, installation is basically done. Next, you need to decide whether you want to keep root.

Keeping root
Type "exit" three times to close the ADB window.
Disconnect cable.
Turn off USB debugging.
Install a superuser manager from the Play Store, either Chainfire's SuperSU or ClockworkMod's Superuser.
Optionally, install Busybox, which is used by many root apps.
Optionally, use File Manager to remove the /DataOnSD folder and its files from the SD card.

Removing root
In the ADB window, type
Code:
mount -o remount,rw /system
rm /system/etc/install-recovery.sh
rm /system/xbin/daemonsu
rm /system/xbin/su
mount -o remount,ro /system
exit
exit
exit
Disconnect cable.
Turn off USB debugging.
Optionally, use File Manager to remove the /DataOnSD folder and its files from the SD card.

If everything looks right, reboot the phone. File copying will take some time. Hopefully everything works. Good luck.

Uninstalling
If you need to uninstall the hack, you would almost do the same thing (root the phone if unrooted), except in the ADB window, you'd type
Code:
adb shell
su
cd /storage/external_SD/DataOnSD
sh installer.sh uninstall
exit
exit

should FAT32 have more storage space than ext4? i have a 32gb micro sd card
 
should FAT32 have more storage space than ext4? i have a 32gb micro sd card
Not necessary. The two partitions are independent. Also read the bottom half of post #262. Once you understand how those partitions are used, you can decide how much space you want to give to each.

By the way, you don't have to use the ADB method to install. I just wanted to elaborate on that method and add some other general details. Check #251 to see which way makes most sense to you.
 
yeah WV it does work,the new ones (mostly with Xperion) and a couple older ones with the different version of KK (442) and CM11. I have been trying everything I can think of/search for/discover to get the newer ones working with KK 4.4.2 (euro 505 etc and/or CM11) but I havent been able to (yet...). The version in post #251 with the install method in post #253 works on Xperion but I was unable to get it working properly on the 4.4.2 or CM11 (F6). I'll keep trying because I think its a cool way to gain extra storage and it would be great to work across disparate ROMs (platforms etc.). If I am wrong and/or not in line with what you are trying to accomplish plz let me know.

I personally (with my limited knowledge etc.) think that because of the way the ports were put together, along with the locked bootloader (on these phones) requiring LOKI, and a bit of SElinux thrown in the mix that is whats causing the multiple issues. I can only think the best course (for these F6 phone in particular) would be to build a proper kernel. I think all the problems resonate from there. I very well could be wrong. Thats for greater experience from those people that have it (you WV, maybe GameTheory, Bard or Hroark13, maybe pressYforPie etc) to (hopfully) figure out, if they are so inclined. Else I will keep trying, the best that I (humbly) can.
Hey man, I really appreciate your effort in all that testing.

I do want to solve the storage problem in KK. All such storage hacks have some issues under KK, right? How this hack (or any such hack) tries to mount the external storage is like malware from the system's perspective. Google wants tougher security going forward, so it's a challenge that needs to be overcome. I remember reading about D505 users reporting that rooting isn't permanent with their official KK. I think the cause of that issue could be similar to that of the issues we are facing. With custom roms, obviously, you can build them to be rooted. But my understanding is that with the SELinux security model, being superuser doesn't automatically mean you can do everything. You can have the clearance, but you still need to obtain the proper privileges, so to speak. I have some basic ideas, but I need to do some probing to see whether my understanding is right.

A while ago you told me about that universal init.d injector thing. If my approach can't work in general, that approach might be worth a look. Pull the boot image from the phone, do the necessary modification (mounting the partition in init.rc), reapply loki, and put the updated boot image back to the phone. Loki makes the approach less generic and more complex though, so it's just a possibility for now.
 
I think it would be a good idea to make a new thread with a guide for the different methods of installing this mod so people don't get overwhelmed by all the technical mumbo jumbo in here. I personally felt that the file swap/ permission change method was the most simple way to implement this. I would do it myself but I don't have a full understanding of the other methods. Never used adb or successfully flashed a zip before.
 
Thanks WV and all who helped in testing for the alpha version. i have succesfully installed the zip on #251 and solved my internal space solution (rooted stock rom: ms500) Appreciate it
 
I just checked out your new zips and the Install completes successfully and the copy also completes successfully but after a reboot i get the lg boot screen.
OK, I was puzzled when those zips didn't work. It turns out I messed up. The diagnosis was right. The treatment should have worked. But the manufacturing of the cure was flawed. Specifically, I left out a parameter (used "setenforce" instead of "/sbin/toolbox setenforce"). Sorry about that.

So in summary, use these zips for TWRP because TWRP has enforcing mode on. These zips put the recovery system in permissive mode so that installation would work. This enforcing/permissive switch is only for the recovery environment, and is not relevant for the regular booting of the rom. I don't think CWM was built using KK's environment, and consequently, this enforcing/permissive thing should be irrelevant for CWM. The old zips (#259 or #280) should work in CWM. I expect the enforcing/permissive command to silently fail for CWM, so the new zips should work in CWM as well. As usual, if anyone encounters or observes something unexpected, please let me know.
 

Attachments

I think it would be a good idea to make a new thread with a guide for the different methods of installing this mod so people don't get overwhelmed by all the technical mumbo jumbo in here. I personally felt that the file swap/ permission change method was the most simple way to implement this. I would do it myself but I don't have a full understanding of the other methods. Never used adb or successfully flashed a zip before.
I plan to make a separate thread when I make a beta release. This is more like a development thread for me. As you can see, some issues still need to be fixed. I know newbie guides don't really belong here, but I just want to make a few posts to help those brave ones who have some technical knowledge and are willing to test this out.
 
I have stopped trying to get the mounting using 'VOLD' method on KitKat 4.4.2 for the moment. I could not get any of the current versions (starting with post #253, any method to install, down through the rest of the .zip versions) to work, bootloop city. HOWEVER, I had some interesting results on CM11 4.4.4 (Hroark13). A few sidenotes first:

== I could not get TWRP to even display a mount option for .ext4. I might have missed a way to do it (I did try using TWRP terminal to mount /ext4 but I didn't get a positive response). But one day, I had Xperion ROM installed with this mod working and when I used 'factory reset' it included the usual cache,Dalvik,data AND ext4.

After that ext4 has been available to mount (even after factory resets, changing ROMS, etc.). Which makes diagnostics much easier. Additionally, anyone looking to view their /ext4 (or ext3 & ext2) partition in Windows, my friend directed me to

Ext for Windows | PARAGON Software Group - Ext2 / Ext3 / Ext4 for Windows 7 8 xp

a file manager that incorporates the funcionality to view said systems right into Windows built-in file manager. Its a pretty cool utility.

== CM11 is set to 'permissive" for SElinux out of the box. I was hoping that would take care of the possible issues with SElinux.

== In a terminal window, 'su' then 'id' returns uid=0(root) gid=0(root) context=u:r:init_shell:s0, which after reading abit about SuperSU is the highest level of 'root' (even though, as with most things, apparently there are exceptions).

I tried using the init debug script (post#256) with these results:

no /data/.LGF6DataOnSD_DO_NOT_REMOVE ... OK
/dev/block/mmcblk1p2 ... OK
no /cache/DataOnSD ... OK
making /cache/DataOnSD ... 0
mounting /dev/block/mmcblk1p2 at /cache/DataOnSD ... OK
unmounting /cache/DataOnSD ... 0
removing /cache/DataOnSD ... 0
no /data/.LGF6DataOnSD_DO_NOT_REMOVE ... OK
/dev/block/mmcblk1p2 ... OK
no /cache/DataOnSD ... OK
making /cache/DataOnSD ... 0
mounting /dev/block/mmcblk1p2 at /cache/DataOnSD ... OK
unmounting /cache/DataOnSD ... 0
removing /cache/DataOnSD ... 0
no /data/.LGF6DataOnSD_DO_NOT_REMOVE ... OK
/dev/block/mmcblk1p2 ... OK
no /cache/DataOnSD ... OK
making /cache/DataOnSD ... 0
mounting /dev/block/mmcblk1p2 at /cache/DataOnSD ... OK
unmounting /cache/DataOnSD ... 0
removing /cache/DataOnSD ... 0

I'm sure you notice the absence of ext4 and vfat. But I am unsure of the reasons. I had seen this debug script, but on the KK 4.4.2 (505 euro build) I always got a bootloop, and I sort of forgot about it. When I found that CM11 doesnt loop (I suspect its because of it being a KTU84Q build, and was designed with its features baked-in as opposed to being ported from a stock rom from a different country. Maybe?) but still wasn't doing the swap,I remembered that debug file and gave it a shot. The copy went correctly, thanks to TWRP letting me finally mount /ext4, I checked. The LGF6DataOnSD_Do_Not_Remove was there and it seemed the other files/folders were too. When I compared the sample debug you had (post#256) I noticed the discrepancies.

So it seems the ext4 partition isn't mounting using 'vold' at present, even with SElinux being 'permissive'. I even used 'setenforce' in TWRP. I reverted everything back, and used the DataOnSD with script_installer and 'debuggerd' and 'sensord' just to check. Memory swapped on reboot, like I reported before. From the brief stuff I have read, SElinux (even set to permissive) can still exert control in certain instances. Maybe its enforcing on 'vold'? Is there some way to check? I mean, it (using 'vold' binary for mounting) worked on 4.1.2. You had it working on your Nook with KitKat. So its possible...I'll keep working on the problem.

Thank you WV for sticking with it. You accomplished the goal awesomely on 4.1.2 with the newest version. The prior version also works, across the ROMs I tested it on (4.1.2 JB, 4.4.2 KK, 4.4.4 CM). Just to get the new one going on 4.4.*, if possible!
 
WV

looks like the install zip reads successful but copy fails. I reboot the phone and it boots up normally with no visible changes. tried again and same result. not sure what the install did

let me know if I can put any other info to help troubleshoot

BTW. my phone is a d500 and stock Tom rooted




OK, I was puzzled when those zips didn't work. It turns out I messed up. The diagnosis was right. The treatment should have worked. But the manufacturing of the cure was flawed. Specifically, I left out a parameter (used "setenforce" instead of "/sbin/toolbox setenforce"). Sorry about that.

So in summary, use these zips for TWRP because TWRP has enforcing mode on. These zips put the recovery system in permissive mode so that installation would work. This enforcing/permissive switch is only for the recovery environment, and is not relevant for the regular booting of the rom. I don't think CWM was built using KK's environment, and consequently, this enforcing/permissive thing should be irrelevant for CWM. The old zips (#259 or #280) should work in CWM. I expect the enforcing/permissive command to silently fail for CWM, so the new zips should work in CWM as well. As usual, if anyone encounters or observes something unexpected, please let me know.
 
WV

looks like the install zip reads successful but copy fails. I reboot the phone and it boots up normally with no visible changes. tried again and same result. not sure what the install did

let me know if I can put any other info to help troubleshoot

BTW. my phone is a d500 and stock Tom rooted
OK, it's probably best to start from the beginning. I'm going to assume your SD card is already properly partitioned (1st=fat32, 2nd=ext4).
Restore your backup.
Reboot into system to make sure it's fine.
Use the TWRP app to reboot into recovery.
(This step is normally not necessary, but let's do it to make sure nothing weird: Settings->check "use rm -rf..."->back to main screen->Wipe->Advanced Wipe->check only "sd-ext"->swipe to wipe->back to main screen->Settings->uncheck "use rm -rf..."->back to main.)
Install the new DataOnSD-copy.zip, hopefully no error this time.
Install the new DataOnSD-install.zip.
Reboot into system.

You should get no error after each step. The order of -install and -copy is not too important, but since you had trouble with copying, do that first this time. Copying would take a while. Let me know what happens. Good luck.
 
I have stopped trying to get the mounting using 'VOLD' method on KitKat 4.4.2 for the moment. I could not get any of the current versions (starting with post #253, any method to install, down through the rest of the .zip versions) to work, bootloop city. HOWEVER, I had some interesting results on CM11 4.4.4 (Hroark13). A few sidenotes first:
Thanks for the info, as usual. It feels like the big picture is slowly coming into focus.

I'll try to attack the binary method later. It's probably going to take some time to figure out. If targeting "vold" is too difficult, we might go back to "debuggerd". In the meantime, try the init.d method. The script mounts the partition in hroark13's D505-based KK. I did not test anything else (sensors, etc.) though. It should in theory work with CM11 as well, since CM11 seems to be less restrictive. I don't remember whether you use CWM or TWRP, but this zip should be flashed with TWRP because I think the CWM we have for this phone doesn't support SELinux contexts.

The log entries you were observing came from the old init.d script (invoked by the rom), not the init_debug script (invoked by my script_caller binary). So don't worry that. Just delete the log file. The new init.d script should replace the old one and it doesn't produce a log file.

As before, delete the tag .LGF6DataOnSD_DO_NOT_REMOVE to trigger file copying. And to uninstall, just delete /system/etc/init.d/00DataOnSD.
 

Attachments

WV, Success! followed your steps on the check/unchecked "use rm -rf..." and did the copy step before the install. rebooted it's looking good so far.


OK, it's probably best to start from the beginning. I'm going to assume your SD card is already properly partitioned (1st=fat32, 2nd=ext4).
Restore your backup.
Reboot into system to make sure it's fine.
Use the TWRP app to reboot into recovery.
(This step is normally not necessary, but let's do it to make sure nothing weird: Settings->check "use rm -rf..."->back to main screen->Wipe->Advanced Wipe->check only "sd-ext"->swipe to wipe->back to main screen->Settings->uncheck "use rm -rf..."->back to main.)
Install the new DataOnSD-copy.zip, hopefully no error this time.
Install the new DataOnSD-install.zip.
Reboot into system.

You should get no error after each step. The order of -install and -copy is not too important, but since you had trouble with copying, do that first this time. Copying would take a while. Let me know what happens. Good luck.
 
OK, it's probably best to start from the beginning. I'm going to assume your SD card is already properly partitioned (1st=fat32, 2nd=ext4).
Restore your backup.
Reboot into system to make sure it's fine.
Use the TWRP app to reboot into recovery.
(This step is normally not necessary, but let's do it to make sure nothing weird: Settings->check "use rm -rf..."->back to main screen->Wipe->Advanced Wipe->check only "sd-ext"->swipe to wipe->back to main screen->Settings->uncheck "use rm -rf..."->back to main.)
Install the new DataOnSD-copy.zip, hopefully no error this time.
Install the new DataOnSD-install.zip.
Reboot into system.

You should get no error after each step. The order of -install and -copy is not too important, but since you had trouble with copying, do that first this time. Copying would take a while. Let me know what happens. Good luck.

I just tried this and it totally works! I began with xperion rom and pressy4pie's mod installed which killed the camera which is a no-go for me. I followed the quoted steps and the SD hack was still enabled but the camera was still broken. I went back into recovery and installed freedom kernel lite and the SD hack was still active (it would revert back at this step with just pressy4pie's mod) and now the camera works!

I decided to press my luck and install the freedom OC kernel and voila SD hack still enabled and camera still works!

Thanks WarrantyVoider! I will let you know if anything weird happens.
Should this mod, freedom OC, and the CM11 rom all behave with each other?
 
I just tried this and it totally works! I began with xperion rom and pressy4pie's mod installed which killed the camera which is a no-go for me. I followed the quoted steps and the SD hack was still enabled but the camera was still broken. I went back into recovery and installed freedom kernel lite and the SD hack was still active (it would revert back at this step with just pressy4pie's mod) and now the camera works!

I decided to press my luck and install the freedom OC kernel and voila SD hack still enabled and camera still works!

Thanks WarrantyVoider! I will let you know if anything weird happens.
Should this mod, freedom OC, and the CM11 rom all behave with each other?
The SDhack mod by pressy4pie needs to make a change to /fstab.qcom, which is a part of the boot image. Changing the boot image means the kernel is replaced as well. So if the kernel included in the pressy4pie's mod doesn't support your camera, your camera won't work. Freedom kernel obviously replaces the kernel and thus the boot image, which replaces pressy4pie's mod. My hack (and JVene's original idea) modifies a file in /system and since it doesn't touch anything in the boot image, it shouldn't interfere with custom kernels.

It should be possible to modify the boot image of the custom kernel so that the method used in pressy4pie's mod (edited /fstab.qcom) is merged into the same boot image. But I don't think GameTheory wants people to modify his package. Besides, the changes need to be made manually for each new zip, so it's not too convenient.

As for CM11, does the Freedom kernel even work with it? Anyway, this hack (#251 with various installation methods, including #309) right now doesn't work with any KK rom if the rom has SELinux running in enforcing mode. I am not sure about permissive mode, crm701 and I are still trying to resolve issues. The hack works with KK if SELinux is disabled entirely. The best bet for CM11 right now is the init.d script I sent to crm701 just a few posts above. But no testing is done yet so I can't say whether it works.

I want to say thanks, to you and everyone who's reported their result, good or bad. Let me know if you observe anything strange or any conflict with another program that might be related to this hack.
 
Hey WV. I did try the init.d .zip from post #314. I was using Hroark13's CM11 (4.4.4) and my recovery is TWRP. I flashed the .zip, and everything appeared to work correctly. No 'fail' warnings from either the .zip or TWRP. I checked after mounting /sdext and saw the files copied there, down to the .smpl logs. I reboot,and check storage. No swap. No bootloop, I know it copied, just not mounted. Still saw the fat32 partition as external, but internal 1.2 GBs. My friend showed me a scripy he partially modified from Links2SD. I also made a change, I changed from /data/extSdcard to /data. Reading the log file it creates, I saw it wasnt working because there was no '/data/extSDcard'. Copy of script:

#!/system/bin/sh
#added by link2sd
modprobe ext4
LOG=/data/link2sd-11link2sd.log
echo "$(date) mounting..." > $LOG
sleep 2
mount -t ext4 -o rw /dev/block/vold/179:34 /data 1>>$LOG 2>>$LOG

mount -t ext4 -o rw /dev/block/mmcblk1p2 /data 1>>$LOG 2>>$LOG

mount >> $LOG
echo "$(date) mount finished" >> $LOG

On reboot after checking storage, I could see that /data was mounted on the external SD card. I could check /data and see the .LGF6DataOnSD_DO_NOT_REMOVE file there.In SManager, after running 'su'and 'df' my file system had the following:

/data 16.2 GB, 2 GB being used, 14 GB free
/mnt/shell/emulated 16.2 GB, 2 GB used 14 GB free
/mnt/media_rw/sdcard1 12 GB, 2 GB used 14 GB free
/storage/sdcard1 12 GB, 5.8 GB used 6 free

I also retained your 00DataOnSD. I renamed 11link... to 00Link2SD so it ran before '00DataOnSD00' (EDIT I renamed it 01DataOnSD00, not really important, it worked both ways).So this is just a mount-(like a bind mount?)? or actually a legitiment way to get your mod working on KK 4.4.2 and CM11? I havent tested on KK 4.4.2, or Xperion (or stock 4.1.2) but I plan to. Is this helpful to you? It seems to really mount in the 'right'way? *EDIT->* Or did I just basically use a method similar to your earlier version? Or alternatively, maybe you could polish the script, etc. to tune it for an init.d install? I'm not sure lol thats your "job", I am passing on the results I found.*<-EDIT* Let me know my friend. I will give it a shot on 4.4.2 to see if it works, soon.

EDIT: Still on CM11, the buttons seem to work properly, and sensors do seem to work. I did lose them once, but I think I may have done something because on rebooting they came back. I think I understand a little bit better about trying to get a mounting point earlier in the boot process, and also how KitKat has made it more difficult and complicated. Looking at the .LOG file the script produced, I did notice that the first 'mount' (I believe dev/block/vold/179:34) seems to return mount:device or resource busy. Now its dawning on me, (with my previous ignorance) why the various ways of doing this each have different sets problems. Which makes your effort and persistence even more impressive. I attached a copy of the log, maybe it contains something that could assist you.
 

Attachments

I tried the init.d script on both CM11 and hroark13's D505-based KK. I saw increased /data, but I didn't test anything else. If it doesn't work for you, check to see if you have a folder /cache/DataOnSD. Delete it if you do. Or just wipe cache. Anyway, while looking at it, I changed two minor things. 1) The new /data now gets the same selinux context as the old /data and 2) the new /data gets the same mount options as the old /data. I don't think these changes matter too much, but what the script does is now more correct, so to speak.

The script you showed tries to mount the same thing directly to /data twice (/dev/block/vold/179:34 and /dev/block/mmcblk1p2 refer to the same thing). I didn't choose to mount directly because I don't want to ignore the possibility the partition is not the right one (i.e. no tag file). If I mount the partition, find no tag, then unmount, there's a chance, even if a very tiny one, that another process accesses /data between the mounting and unmounting. What I do is to mount at a temporary mount point, do a bind mount to /data, and then unmount the temporary mount point. So functionally, there isn't too big of a difference.

As for the binary method, I'm glad to report that with your help, I got it working as well. There were two major issues. One is that partition didn't mount, even when using debuggerd. It turns out selinux has labels that my old code didn't expect. Once I understood how my code reacted to the labels, it was an easy fix. The other issue is using vold prevented booting. Like we've discussed, targeting debuggerd, which would be less restricted than vold, was an alternative. But I wanted to do it the hard way so that future, more locked-down versions can't stop me. So I figured out the proper permissions to get vold to load. From there, I operated within the rules that vold must follow and things worked as they should.

The init.d script is loaded quite early in the two roms I tried so it should hopefully not cause issues with other processes. For roms without init.d support, the binary method hopefully provides the same result. I did not have time to test compatibility with other hw/sw components or apps, or to try these new files on any JB roms. I'm not as proficient in testing, so if you or anyone feels like doing that, let me know your findings. Thanks.

Note: for SELinux-enabled (say, KK) roms, use TWRP to flash. For other (e.g. 4.1.2) roms, either CWM or TWRP should be okay. As before, -initd.zip includes file copying but no uninstaller. Its file copying method is the same as the one used by -copy.zip so the files are compatible. To uninstall the init.d script, just delete /system/etc/init.d/00DataOnSD. To wipe "data" (files on external partition) between different roms, format the partition or remove all files. Alternatively, remove the tag file, let the rom sets up its /data on internal storage, and then use the copier script.
 

Attachments

Cm11 4.4.4 ms500
Setting instead of format
Wipe ext
Settings instead of format
Install intd.
Hung at unmount ext.
Done.
Unable to Mount /data
It stopped here.
Tryed install zip after
Unable to mount /data
Rebooted.
No changes :(
 
wow this does mean you got the the vold binary mount working like you were trying to accomplish? Because when I saw your post, I got excited. I was beginning to think it might not be possible without a built kernel or something, and then there it was. Awesome! After flashing (using TWRP) the dataonSD-install.zip (sdext already populated from prev. copy script) and on boot I checked and /data was mounted, and Android storage shows 16 GB. No bootloops, sensors and buttons work, I installed Xposed, no problems there (only minimal test, Xposed [reboot] couple modules [reboot] everything behaving normal). /System/bin contained 'vold', 'vold-original', 'vold-copy'. I downloaded some .apks using Playstore and 1 mobile market, I had to clear data for playstore and after that downloaded fine. Torrents downloaded fine. I haven't encountered any issues as of yet, but its only been half a day. I also used the uninstall.zip, which successfully restored the original 'vold'. I then flashed DataonSD-initd.zip. After booting a few times with no success, I found /cache/DataOnSD (empty), deleted that folder and rebooted. Success. I tested on (hroark13) KK Beta 5 (4.4.2 build KOT49I.D500hK_B4)

**DataOnSD-install.zip (vold binary) + dataonSD-copy (so far) swap successful 4.4.2 (Hroark13 KK Beta 5)

**DataOnSD-init.zip (init.d version) also worked correctly (same ROM)

I am going to run this through one time on other ROMS, but I believe it will perform successfully. Great work WV. You brought to fruition the idea Jvene proposed those months ago.

I did note a bit of lag, not much, on the browsers or the app stores scrolling up/down. I got thinking and tested my SD-card and got benchmark scores of 27-32 read / 8-11 write. The F6's intern. storage 45 read / 15 write. I was wondering if there is a way to have /cache and maybe /system mounted (or symlink?) back to F6's intern.? If so, would that possibly provide any boost for slow SD cards? I am not sure if it would provide any benefit, or if its possible or feasible, but I am curious.
 
Cm11 4.4.4 ms500
Setting instead of format
Wipe ext
Settings instead of format
Install intd.
Hung at unmount ext.
Done.
Unable to Mount /data
It stopped here.
Tryed install zip after
Unable to mount /data
Rebooted.
No changes :(

I got both the -install.zip (vold mount binary) and the -initd.zip to work on CM11 (hroark13 4.4.4 KTU84Q). The -copy.zip and uninstall also work. I use TWRP. I don't format sdext with TWRP, for some reason it wiped my sdcard (fat32 partition). I go 'MOUNT' (main menu), I check 'sdext' to mount. Then I go ADVANCED, and use the file manager. Navigating to 'sdext', I select .LGF6DataOnSD_DO_NOT_REMOVE, and delete that. I use dataonSD-copy.zip, then I flash either -initd.zip, or -install.zip. Reboot.

EDIT: use either -install OR initd. You dont need both.
 
Back
Top Bottom