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

Root Link2sd tutorial for a fresh wipe

benslgdroid

rockstar
May 18, 2011
2,568
859
Magrathea
Introduction:
When updating your rom or going to a new rom and using link2sd and you need to do a full wipe or you will run into errors, some say the recreate link scripts works but its never worked for me. So here is a step by step how to do it after its already been set up and you have a fresh wipe. (If you have not already had link2sd and partitioned your sd card go to http://androidforums.com/showthread.php?t=364833and follow that tutorial to get you started.)

Getting started:
To do a full wipe:
First backup all your apps with titanium backup (if you don't have pro you can fallow these same steps just where it's at the batch restore you will have to restore one by one but everything else is the same)
Next,

1) Backup your apps with something like TitaniumBackup or MyBackup

2) Download the BACKside ROM (or rom of your choice) zip file, the gapps zip file, place them on your sdcard

3) Boot into recovery

4) Make a backup

5) Wipe cache, and under advanced wipe dalvik cache

6) Under mounts, format boot, system, data, and cache

7) Flash the BACKside ROM zip file

8) Flash the gapps zip file

9) Reboot your phone

Instructions:
When it asks for you to sign into Google when you first startup after flashing gapps select skip, you'll go back to it when your finished.

First install titanium backup then link2sd. Then open link2sd it will ask you to select your ext, select the right one then reboot. Next open link2sd again push the menu key, then select settings then auto link,

autolink.jpg


Next start titanium backup, push the menu key and select batch go to restore and select app and data (not system apps)

restore.jpg


Make sure you have selected what you want to restore and hit run. Wait until its finished, can be a while depending on the number of apps you have.

Next go back to link2sd and select the location filter,

locationfilter.jpg


Select linked,

selectlinked.jpg


Then select filter,

selectfilter.jpg


Next lib size,

libsize.jpg


Next push the menu key and select multi select, look for the ones where the lib is not linked (it will have no arrow infront of it)

noarrow.jpg


Select all the ones where lib is not linked, (when lib is 0 there are no more lib files to worry about in the list) push the menu key and select create link,

createlink.jpg


Make sure all the options are selected then push okand let it finish, then push back to exit multi select, then select location filter,

locationfilter.jpg


Select on sd,

onsd.jpg


If multiple apps are there push the menu key then multi select, select all the apps there, then hit the menu key and select create link

createlink.jpg


Make sure all three option are selected then hit ok and it will move and link all those apps.

Now your done, now go back and go to the market and install your Google apps and they will auto link as well.
 
i love link2sd. been using it for 4 months and never had any problems. i've flashed every gingerbread rom [Jerry, Bobz, Mrg666, harmonia2, and even thatunknown and rarely heard from artist] and all updates.

if Jerry releases a new update and i happen to be running Bobz's i go to backup and restore and restore Jerry's latest.
i flash the update over this, wiping ONLY cache and dalvic cache.

when it boots up there is a link2sd "mount warning" in the status bar.
i go to link2sd and do NOT quick reboot
i go to menu/ more/ recreate mount scripts, and then select my EXT in the pop-up [ext2 for me]
it then tells you to reboot and i do so manually.

when it boots back up everything is like it was before /except i have all the new stuff that Jerry [or Bobz or...] has just added
 
  • Like
Reactions: benslgdroid
Upvote 0
I'm thinking of making a YouTube video for my "The Truth About ROM Manager" tutorial so those with the Hitachi screen will quit using it and causing the black screen in the recovery menu or worse; a double black screen- one in the recovery and another in the ROM.
I've included the workaround in the tutorial and will include it in the video as well.

I'm still going to take some screen shots for the tutorial.
 
Upvote 0
Please tell us how to do this. This sounds like a really good idea. Remember though, a lot of members are not super techie/c++/linux types. That, and I'm a rock when it comes to new things, until I've done it at least once.

Edit: Benslgdroid, the extension that the touch recovery made was ext. 3 not 4. I don't know if this is standard for CWMod recovery's or not. Just thought I throw that at you for future reference.
 
Upvote 0
ext3 is the standard sd-ext type for CWM Recovery but you can force it to make ext2 or ext4 with some outside help:).

Now modify ROM. It's easy.
Copy the script 11link2sd from /system/etc/init.d folder to your PC. Open ROM.zip with 7zip and navigate to /system/etc/init.d in the zip. Drag and drop 11link2sd there. Now is the time to add/remove any files you want from the ROM before updating. Then open META-INF folder in the root of the ROM.zip and delete the three files in there:
CERT.RSA
CERT.SF
MANIFEST.MF
Do not touch "com" folder. Close 7zip. You have your new modified ROM.zip and it needs signing now. Download SignApk.zip, unzip it and just drag the new ROM.zip and drop it over sign.bat file. In few seconds you will have your new signed-ROM.zip in the same folder ready for flashing. That's it.

I personally use more complex .bat file which in one step adds, removes and modifies many files in the ROM. Here is what I use for my ROMs before flashing, just to get the idea:):

Code:
@echo off
IF [%1]==[] (
color 0C
echo ---------------------------------------
echo "Don't run this batch file directly!!!"
echo.
echo Drag the zipped ROM in it...
echo ---------------------------------------
echo.
PAUSE
exit
)
color 0A
IF EXIST "%~dp0log.txt" (del "%~dp0log.txt")
IF EXIST "%~dp0signed_%~n1.zip" (del "%~dp0signed_%~n1.zip") > "%~dp0log.txt"
IF EXIST "%~dp0framework-res\unsignedframework-res.apk" (del /Q "%~dp0framework-res\unsignedframework-res.apk") >> "%~dp0log.txt"
IF EXIST "%~dp0%~n1" (rmdir /Q /S "%~dp0%~n1") >> "%~dp0log.txt"
IF EXIST "%~dp0framework-res\framework-res_apk" (rmdir /Q /S "%~dp0framework-res\framework-res_apk") >> "%~dp0log.txt"
IF EXIST "%~dp0framework-res\keep" (rmdir /Q /S "%~dp0framework-res\keep") >> "%~dp0log.txt"
echo ------------------------------------------------
echo Extracting original ROM...
echo ------------------------------------------------
echo.
7z x -r %1 -o%~n1 -y >> "%~dp0log.txt"
echo ------------------------------------------------
echo Cleaning up the ROM......
echo ------------------------------------------------
echo.
del %~n1\META-INF\CERT.RSA >> "%~dp0log.txt"
del %~n1\META-INF\CERT.SF >> "%~dp0log.txt"
del %~n1\META-INF\MANIFEST.MF >> "%~dp0log.txt"
del %~n1\system\app\Calculator.apk >> "%~dp0log.txt"
del %~n1\system\app\Gallery3D.apk >> "%~dp0log.txt"
del %~n1\system\app\LatinIME.apk >> "%~dp0log.txt"
del %~n1\system\app\SoundRecorder.apk >> "%~dp0log.txt"
del %~n1\system\app\Music.apk >> "%~dp0log.txt"
del %~n1\system\etc\init.d\05mountsd >> "%~dp0log.txt"
del %~n1\system\etc\init.d\11mvdalvik >> "%~dp0log.txt"
del %~n1\system\media\*.zip >> "%~dp0log.txt"
del %~n1\system\media\*.mp3 >> "%~dp0log.txt
echo ------------------------------------------------
echo Copying custom files...
echo ------------------------------------------------
echo.
xcopy "%~dp0system" "%~dp0%~n1\system" /E /Y >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (xcopy)"
PAUSE
exit
)
echo ------------------------------------------------
echo Decompiling framework-res.apk
echo ------------------------------------------------
cd "%~dp0framework-res\tools"
IF EXIST "%~dp0framework-res\framework-res_apk" (rmdir /Q /S "%~dp0framework-res\framework-res_apk") >> "%~dp0log.txt"
java -jar apktool.jar d "%~dp0%~n1\system\framework\framework-res.apk" "%~dp0framework-res\framework-res_apk" >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (java)"
PAUSE
exit
)
echo.
echo ------------------------------------------------
echo Copying custom files...
echo ------------------------------------------------
echo.
rem xcopy "%~dp0framework-res\mod_files\new_anim\*" "%~dp0framework-res\framework-res_apk\res\anim" /Y >> "%~dp0log.txt"
rem if errorlevel 1 (
rem echo "An Error Occured, Please Check The Log (xcopy)"
rem PAUSE
rem exit
rem )
rem echo.
rem echo.
rem echo ------------------------------------------------
rem echo Now paste these two lines
rem echo under the line of "shortAnimTime" in the file
rem echo integers.xml which just have been opened for you,
rem echo and Save it.:
rem echo.
rem echo      ^<integer name^="config_activityShortDur"^>150^<^/integer^>
rem echo      ^<integer name^="config_activityDefaultDur"^>220^<^/integer^>
rem echo.
rem echo When done...
rem echo.
rem echo.
rem clip < "%~dp0fresCopy.txt" >> "%~dp0log.txt"
rem notepad "%~dp0framework-res\framework-res_apk\res\values\integers.xml" >> "%~dp0log.txt"
IF EXIST "%~dp0framework-res\unsignedframework-res.apk" (del /Q "%~dp0framework-res\unsignedframework-res.apk") >> "%~dp0log.txt"
echo ------------------------------------------------
echo Building framework-res.apk
echo ------------------------------------------------
java -jar apktool.jar b "%~dp0framework-res\framework-res_apk" "%~dp0framework-res\unsignedframework-res.apk" >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (option 24)"
PAUSE
exit
)
rmdir /Q /S "%~dp0framework-res\framework-res_apk"
IF EXIST "%~dp0framework-res\keep" (rmdir /Q /S "%~dp0framework-res\keep") >> "%~dp0log.txt"
7z x -o"%~dp0framework-res\keep" "%~dp0%~n1\system\framework\framework-res.apk" >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (7z)"
PAUSE
exit
)
echo.
echo ------------------------------------------------
echo Raplacing with custom files...
echo ------------------------------------------------
echo.
rem xcopy "%~dp0framework-res\mod_files\anim\*" "%~dp0framework-res\keep\res\anim" /Y >> "%~dp0log.txt"
rem if errorlevel 1 (
rem echo "An Error Occured, Please Check The Log (xcopy)"
rem PAUSE
rem exit
rem )
xcopy "%~dp0framework-res\mod_files\drawable\*" "%~dp0framework-res\keep\res\drawable" /Y >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (xcopy)"
PAUSE
exit
)
xcopy "%~dp0framework-res\mod_files\drawable-mdpi\*" "%~dp0framework-res\keep\res\drawable-mdpi" /Y >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (xcopy)"
PAUSE
exit
)
del /Q "%~dp0framework-res\keep\resources.arsc" >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (del resources.arsc)"
PAUSE
exit
)
7z a -tzip "%~dp0framework-res\unsignedframework-res.apk" "%~dp0framework-res\keep\*" -r -y >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (option 24)"
PAUSE
exit
)
rmdir /Q /S "%~dp0framework-res\keep" >> "%~dp0log.txt"
echo ------------------------------------------------
echo Zipaligning framework-res.apk
echo ------------------------------------------------
echo.
IF EXIST "%~dp0%~n1\system\framework\framework-res.apk" (del /Q "%~dp0%~n1\system\framework\framework-res.apk") >> "%~dp0log.txt"
zipalign -f 4 "%~dp0framework-res\unsignedframework-res.apk" "%~dp0%~n1\system\framework\framework-res.apk" >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (option 24)"
PAUSE
exit
)
del /Q "%~dp0framework-res\unsignedframework-res.apk" >> "%~dp0log.txt"
cd "%~dp0%~n1"
echo ------------------------------------------------
echo Zipping the modified ROM...
echo ------------------------------------------------
echo.
7z a -tzip -r unsigned_%~n1.zip -ssw -y >> "%~dp0log.txt"
echo ------------------------------------------------
echo Signing the new ROM...
echo ------------------------------------------------
java -jar "D:\Downloads\IE9 Downloads\Optimus V\APK Tools\Sign and Zipalign Apk\signapk.jar" "D:\Downloads\IE9 Downloads\Optimus V\APK Tools\Sign and Zipalign Apk\testkey.x509.pem" "D:\Downloads\IE9 Downloads\Optimus V\APK Tools\Sign and Zipalign Apk\testkey.pk8" "%~dp0%~n1\unsigned_%~n1.zip" "%~dp0signed_%~n1.zip" >> "%~dp0log.txt"
if errorlevel 1 (
echo "An Error Occured, Please Check The Log (Signing ROM)"
PAUSE
exit
)
cd "%~dp0"
rmdir /Q /S "%~dp0%~n1" >> "%~dp0log.txt"
echo.
echo.
echo.
echo ------------------------------------------------
echo Done^:-^) See log.txt for details.
echo ------------------------------------------------
echo.
echo.
echo.
PAUSE

EDIT: I forgot, I have this built into QtADB Update ROM Function. You select your ROM on /sdcard, check box "Copy Link2SD mount script to the updated ROM" and press "Update". Your phone will reboot to CWM recovery, 11link2sd will be copied to temporary location, cache and dalvik will be wiped, ROM will be flashed, 11link2sd will be copied back to the new ROM's /system/etc/init.d folder and the phone will reboot in Android. All in just one click. Can't get easiest than that.
 
Upvote 0
I just used this tutorial and found it very helpful; many thanks for putting it together. One question:

9) Reboot your phone

When it asks for you to sign into Google when you first startup after flashing gapps select skip, you'll go back to it when your finished.

* * *

Now your done, now go back and go to the market and install your Google apps and they will auto link as well.

It wasn't obvious to me what you need to do to go back and get the Google apps installed. Eventually, when I was adding a second Gmail account to the phone, it did bring up that page that shows you the Google apps, and I installed the ones I need. But if there's some other way to bring that page up, you might want to add it to the tutorial.
 
Upvote 0
Please my friends, help me!

First of all i noticed that Google Play and Gmail applications have disappeared from my Android 2.3.4.

Then i understood that my sd card was somehow getting slow, so throw an application called "testdisk-6.14-WIP" i've backup all the contents of my partition used by Link2SD.

Now i got a new sd card, and have done the restore of all my applications, but the ones that were on the Link2sd partition are not there.

Can please someone tell me how can i copy them again, in order to have these applications working???
 
Upvote 0
You have to partition the new card. Then what I did was the clean wipe method shown in this tutorial. Make your backups with your old card, then move everything to your pc, then partition the new one, then move everything to your new card, don't worry about copying the partition, then do the wipe and follow the tutorial.

Thanks for your help, but it was a lot easier if i simply copy the contents of the Link2sd partition to the new one, and then recreate all links from the dalvik cache on it, but i can't realise how...
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones