Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[HOW-TO][ROOT][4NOOBS] Resize sdcard0 and internal storage to maximize space for apps

OP bsined

10th April 2014, 07:41 AM   |  #1  
bsined's Avatar
OP Senior Member
Flag Washington, DC
Thanks Meter: 97
 
211 posts
Join Date:Joined: Mar 2013
More
Ever since I bought my Xperia TL (LT30at), I've been upset at the ridiculous allocation of onboard memory: only 1.97GB were available for apps. The rest was allocated to an emulated external SD card, which meant that any app installed on it would lose widgets and suffer from other weird glitches on reboot. I've searched all over the place and couldn't find a solution until @teidus shared his method (per my research, it has been used on older devices from other manufacturers as well). I tried it and adjusted the steps to ensure 100% compatibility with my phone (and added explanations so that other devices could be tested).

See proof in the attached screenshots.

WARNING: You will lose a lot of data if you don't follow this guide!

WARNING: These operations require a rooted device. If you are running unrooted Android 4.3 or newer, you cannot proceed.

NOTE: All of these changes will be reversed if you flash an FTF that includes partition-image.sin.

DISCLAIMER: I'm not responsible for bricked devices and data loss from power surges, hardware damage, or changes to the linked software. Always check the native manuals for all the tools listed here!

Required Downloads:
1. Flashtool, which includes ADB (got questions about it? - ask them here) - requires installation

2. @[NUT]'s dual XZDualRecovery. I'm linking to v2.7.94 BETA installer. If you wish to check for a more recent version, go to his download page and do a page search (CTRL+F) for XT-lockeddualrecovery[version-goes-here].installer.zip. (got questions about it? - ask them here) - unzip to a location you'll remember (say, C:\xperia-resize\recovery\)

3. FTF with your phone's 4.1.2 firmware - save it to the default Flashtool firmware directory (C:\flashtool\firmwares\)

4. File system utilities (attached) - unzip to a location on your phone's physical SD card you'll remember (say, fs-utils\)
The Guide (skip all the way to the bottom for the short guide if you know how to backup and flash FTFs):

1. Back up all data stored on internal storage:
Option 1: Connect your phone to the computer and save it to a computer drive.
Option 2: Open a file manager on the phone and copy it to a physical SD card (/sdcard1).
2. Back up your current installation with either Online Nandroid or your current recovery and remove the SD card for safety.

3. Flash your phone with basic 4.1.2 install.
3.1 Turn off the phone.

3.2 Launch Flashtool.

3.3 Click the thunderbolt icon on the left and select Flashmode.

3.4 Select the appropriate 4.1.2 FTF from the list (it'll be there if you saved it to c:\Flashtool\firmwares\).

3.5 Tick "No final verification" checkbox on the right, click Flash, and when prompted, hold the VOLUME DOWN button, and connect the phone to the computer. The operation will take about 10 minutes. DISREGARD THE INSTRUCTIONS IN THE ANIMATION. Xperia T/TL doesn't have a hardware Back button.


3.6 When flashing is complete, boot the phone.
4. Connect your phone to the computer and let the computer recognize it.

5. Enable USB debugging.
5.1 Go to (System) Settings -> Developer options and flip the switch in the top-right corner of the screen.

5.2 Look a bit down (toward the middle of the screen) and check USB debugging.
6. Install the dual recovery.
6.1 Go to the location on your computer where you extracted dual recovery (e.g., C:\xperia-resize\recovery\).

6.2 Double-click install.bat.

6.3 Press 3 on your keyboard for the option 3. Installation on unrooted ROM.

6.4 Follow the instructions on your computer's screen.

6.5 When you will try to reboot the phone back into Android, the recovery will prompt you to root the OS. Do that.
7. Boot into PhilZ Touch recovery by opening App Drawer, starting NDR Utils, and selecting the appropriate option.

8. When the phone boots into recovery, connect it to the computer.

9. Start ADB.
If you don't know where ADB is, press WIN + R on your computer keyboard, type cmd in the pop-up window, hit ENTER, then copy & paste this command (paste by right-clicking the command prompt window): cd C:\Flashtool\x10flasher_lib. Then type adb shell and hit ENTER again.
10. Execute the following commands one-by-one (you can copy & paste, hit enter, and wait for the output):
Code:
umount /storage
parted /dev/block/mmcblk0
print
These commands unmount all drives, launch parted utility for mmcblk0 (onboard flash storage), and show the partition table.
11. Record the beginning of the partition Userdata and the end of the partitionSDCard. These are the limits of your new partitions The numbers are in megabytes (MB) unless specified.
For Xperia T/TL, Userdata begins at 1621 and SDCard ends at 15.6GB. Xperia V (and any other device with less than 16GB of storage) will definitely have a different value.
12. Remove the last 2 partitions by executing the following commands:
Code:
rm 14
rm 15
13. Calculate the new end point for Userdata, which is also the new start point for SDCard:
1621 (or another number you recorded in step 11) + additional space = new end. I added 4GB (4 1024MB = 4096MB) so my new end point was 7865. I advise to add at least 2GB (2048MB) to feel safe about having enough storage for apps. DON'T TRY TO REMOVE SDCARD ALTOGETHER BY ALLOCATING ALL OF THE AVAILABLE SPACE TO USERDATA! Emulated storage is coded into OS environment and requires additional modifications to work properly.
14. Create and name new partitions by executing the following commands (don't copy the text in parentheses):
The system might throw several errors in the process. When prompted, just type ignore and hit ENTER.
Code:
mkpartfs logical ext2 1621 7865 (change the numbers as appropriate for your device)
name 14 Userdata
mkpartfs logical ext2 7865 15.6GB (change the numbers as appropriate for your device and notice the GB to make sure the partition extends to the end of the onboard storage)
name 15 SDCard
quit
These commands create the partitions with ext2 file system and given beginning and end parameters, rename them as required, and close parted.
15. "Damage" the internal, emulated SD card so that it could be formatted properly later.
Tap Mounts and storage -> Format /storage/sdcard0 -> default and confirm the operation.
16. Insert the physical SD card (sdcard1) that you removed in step 2 back into the device.
Make sure it's mounted by tapping Mounts and storage and checking its status (it should say unmount /storage/sdcard1/). If not, mount it by tapping on the appropriate option.
17. Execute the following commands one-by-one in the ADB command prompt:
Code:
cd /storage/sdcard1/fs-utils (the directory name will be different if you didn't follow my conventions)
tune2fs -j /dev/block/mmcblk0p14
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p14
e2fsck -fpDC0 /dev/block/mmcblk0p14
These commands convert Userdata partition into the appropriate ext4 filesystem, which is not supported natively in the recovery environment.
18. Reboot the device into full Android.
18.1 Remove the physical SD card for safety.

18.2 Tap Back until you make it to the top level of recovery. Then tap the top option Reboot the device.
19. When Android loads fully, you'll notice a notification about storage file system. Tap it and follow the prompts to format it.

20. Insert the physical SD card and reboot into the recovery you used to create the backup in step 2 to restore it.
In PhilZ, that's Backup and Restore -> Restore from /storage/sdcard1.
21. Reboot back into full Android and copy the files saved from internal storage back into it. Then reboot again so that apps recognize the data.

DONE!

Short guide/list of ADB commands and other events (*enclosed in asterisks*) if you know the safety drill:
Code:
*flash 4.1.2 & install dual recovery*
*boot into PhilZ Touch*
adb shell
umount /storage
parted /dev/block/mmcblk0
print
*record start point of Userdata and end point of SDCard*
rm 15
rm 14
mkpartfs logical ext2 1621 7865
name 14 Userdata
mkpartfs logical ext2 7865 15.6GB
name 15 SDCard
*Mounts and storage -> Format /storage/sdcard0 -> default -> confirm*
*insert physical SD card*
*Mounts and storage -> Mount /storage/sdcard1*
cd /storage/sdcard1/fs-utils
tune2fs -j /dev/block/mmcblk0p14
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p14
e2fsck -fpDC0 /dev/block/mmcblk0p14
*remove physical SD card*
*reboot*
*format emulated SD card*
*reboot recovery*
*restore backup*
*reboot*
*restore sdcard0/*
*reboot*

Attached Thumbnails
Click image for larger version

Name:	2014-04-10_015902.png
Views:	2669
Size:	180.3 KB
ID:	2678067   Click image for larger version

Name:	2014-04-10_015912.png
Views:	2273
Size:	184.3 KB
ID:	2678068   Click image for larger version

Name:	2014-04-10_015919.png
Views:	2057
Size:	185.4 KB
ID:	2678069   Click image for larger version

Name:	2014-04-10_015927.png
Views:	1840
Size:	205.1 KB
ID:	2678070  
Attached Files
File Type: zip fs-utils.zip - [Click for QR Code] (431.3 KB, 283 views)
Last edited by bsined; 17th April 2014 at 02:56 AM.
The Following 34 Users Say Thank You to bsined For This Useful Post: [ View ]
11th April 2014, 11:56 AM   |  #2  
Junior Member
Thanks Meter: 5
 
5 posts
Join Date:Joined: Mar 2013
nice, i was looking for a way to increase the /data after switching to Omni and ART

Will try ASAP..

PS: i think this thread should be added in ALL IN ONE THREAD Section
11th April 2014, 01:58 PM   |  #3  
bsined's Avatar
OP Senior Member
Flag Washington, DC
Thanks Meter: 97
 
211 posts
Join Date:Joined: Mar 2013
More
Quote:
Originally Posted by raghulrr

PS: i think this thread should be added in ALL IN ONE THREAD Section

That's a request to @gregbradley.
11th April 2014, 06:05 PM   |  #4  
norti's Avatar
Senior Member
Flag Budapest
Thanks Meter: 298
 
717 posts
Join Date:Joined: Feb 2008
More
#6 would be the most welcomed way to resize partitions, but unfortunately it's not so easy as it was e.g. with ZTE Blade. But altogether it's good to know that you can resize them now! Thanks!
12th April 2014, 01:49 AM   |  #5  
mohaxs's Avatar
Senior Member
Thanks Meter: 20
 
107 posts
Join Date:Joined: Dec 2013
nice tutorial brother... i'll be trying tommorow

Sent from S5J using Tapatalk
12th April 2014, 02:56 PM   |  #6  
Junior Member
Thanks Meter: 3
 
14 posts
Join Date:Joined: Jun 2013
Thanks
Thank you I was definetly looking for it

Thanks
12th April 2014, 06:30 PM   |  #7  
Senior Member
Thanks Meter: 20
 
124 posts
Join Date:Joined: Sep 2011
More
@TO: I couldn't test ist but I think made a little mistake:
I think you want want to execute the programms wich are in the Directory in wich you made the cd. So you have to add ./ before each command.

I don't have such a device, to test it by myself: You said you have to make a new virtual SD. Some ROMes have a vold.fstab in /etc. Mayby it't enough to change this file to be able to remove the SD Partition completly.
12th April 2014, 11:44 PM   |  #8  
bsined's Avatar
OP Senior Member
Flag Washington, DC
Thanks Meter: 97
 
211 posts
Join Date:Joined: Mar 2013
More
Quote:
Originally Posted by Partitionator

@TO: I couldn't test ist but I think made a little mistake:
I think you want want to execute the programms wich are in the Directory in wich you made the cd. So you have to add ./ before each command.

I don't have such a device, to test it by myself: You said you have to make a new virtual SD. Some ROMes have a vold.fstab in /etc. Mayby it't enough to change this file to be able to remove the SD Partition completly.

I was writing the guide as I was executing commands so everything is exactly as I entered it. I obviously removed all steps that turned out to redundant and wrong.
The Following User Says Thank You to bsined For This Useful Post: [ View ]
13th April 2014, 10:28 AM   |  #9  
metaljoker's Avatar
Senior Member
Flag Jeddah
Thanks Meter: 24
 
209 posts
Join Date:Joined: Jul 2009
More
Will that work with the Xperia Arc S?!
What is the difference between your method and the [MOD]{CM10.1}{CM10.2}{CM11}{AOSP}Working Int2Ext for Xperia 2011 [ART-compatible]?
Last edited by metaljoker; 13th April 2014 at 10:33 AM.
13th April 2014, 11:00 AM   |  #10  
bsined's Avatar
OP Senior Member
Flag Washington, DC
Thanks Meter: 97
 
211 posts
Join Date:Joined: Mar 2013
More
Thumbs up
Quote:
Originally Posted by metaljoker

Will that work with the Xperia Arc S?!
What is the difference between your method and the [MOD]{CM10.1}{CM10.2}{CM11}{AOSP}Working Int2Ext for Xperia 2011 [ART-compatible]?

These are some great questions! This approach is very different from all Int2Ext scripts:
  1. HUGE NOTE: This works only for devices where the onboard NAND capacity is at least 8GB. That means that 2011 devices with 1-4GB of onboard memory are better off with mounting the physical SD card as /data.
  2. This is a semi-permanent modification to the partition table (it'll work fine if you do factory reset and flash a new ROM .zip but the allocation will be reset every time you flash FTF, possibly even if you exclude partition-image because each .sin contains its offset and size bits).
  3. This approach is compatible with locked bootloaders because support of init.d comes from the kernel.
  4. This approach allows you to allocate as much or as little of onboard NAND storage to each of the 2 partitions (/data and /storage/sdcard0) used for storing apps and their data instead of just allocating the entire physical SD card.
  5. This approach allows you to live a life independent of your physical SD card (i.e., your apps still work and your phone boots up just fine even if the physical SD card dies).

The Following 2 Users Say Thank You to bsined For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes