Google Maps, My Maps, YouTube, Androidify, Slides, Music Updated–Here’s What’s New

In the last few weeks, Google has been … more

SuperSU BETA: Root Android Lollipop on Stock Kernel

Up until now, if you wanted to get root on Android 5.0, you needed to flash a modified … more

Android App Review: Get Amaze with Material Design – XDA TV

Material Design is all the buzz in the Android world right now. Android 5.0 … more

Small But Eternal: HTC Explorer Receives Unofficial CM12

When HTC officially announced the HTC Explorer, they most likely weren’t … more

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

[GUIDE][ROOT] Resizing emulated SD card and userdata partitions

OP bsined

17th April 2014, 04:25 AM   |  #1  
bsined's Avatar
OP Senior Member
Flag Washington, DC
Thanks Meter: 95
 
211 posts
Join Date:Joined: Mar 2013
More
I originally created this guide for Sony Xperia T/TL/TX/V and have since discovered that the method works for other devices, too. So I present the universal guide to getting rid of that annoyingly tiny allocation of space for internal storage in devices that have plenty of it.

Kudos to @teidus for pointing me to this long-forgotten method.

Screenshots of proof are attached to my original post.

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 a factory image that contains a partition table.

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!

I'm also not responsible for your curiosity and desire to resize other partitions. I haven't tried that because messing with /system and /cache can lead to unexpected results.


Requirements:
1. Your device must currently have root access, CMW recovery v6.0.4.6 or later, less than 50% allocated to internal storage, emulated SD card (usually, it's /storage/sdcard0), and at least 8GB of total onboard memory. If you answered "No" to at least one of these, this guide won't help you. To check whether you have an emulated SD card, remove your physical SD card, go into a file manager app, and see whether you still have some sdcard listed.

2. A factory image flashing software for your device unzipped and/or installed on your computer. Look in the relevant forums for downloads.

3. ADB from either Android SDK or your device's flashing tool. Look in the relevant forums for instructions.

4. For locked bootloaders, factory firmware image with Android v4.1.2 or v4.0.x saved on your computer (consult your flashing tool's manual for the default location) - nearly 100% of these have root exploits. Look in the relevant forums for downloads.

5. Root exploit with Superuser or SuperSU installer for your device unzipped on your computer. Look in the relevant forums for downloads.

6. CMW recovery installer v6.0.4.6 or later compatible with your device and the factory firmware version obtained in step 4 unzipped on your computer. Look in the relevant forums for downloads.

7. File system utilities (attached) unzipped to a folder on your device's physical SD card you'll remember (I'll be using /fs-utils in this guide).

8. For Windows 8 users, ADB drivers for your device.
The Guide (skip all the way to the bottom for the short list of ADB commands):

1. Back up all data stored on internal storage:
Option 1: Connect your device to the computer and save it to a computer drive.
Option 2: Open a file manager on the device 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 device with basic 4.1.2 install.
Refer to the documentation for your tool.
4. Connect your device 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. Root your device.
Refer to the documentation for your tool.
7. Install recovery on your device.
Refer to the documentation for your tool.
8. Boot into CMW recovery.
Depending on the device, reboot into recovery may be available in the power menu, or you'll need to press/hold a button during the power on sequence. Refer to the documentation for your recovery.
9. After the device boots into recovery, connect it to the computer.

10. Start ADB shell in command prompt.
Navigate to the folder where adb.exe resides, hold SHIFT, right click the mouse, and select Open command window here, then type adb shell in the command prompt and press ENTER.
11. 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 display the partition table on your screen.
12. Write down the info from the following columns for partitions Userdata and SDCard (or Media). Usually, they are the last 2 partitions.
Column 1 - Number, Column 2 - Start, Column 3 - End, Column 5 - File system, Column 6 - Name. The start of the first partition and the end of the second partition are the limits, within which your new partitions will be created. The numbers are in megabytes (MB) unless specified. Make sure the name is recorded just as it appears in the partition table - Andorid is case-sensitive.
13. Remove the 2 partitions by executing the following commands:
Adjust the numbers according to your system.
Code:
rm 14
rm 15
14. Calculate the new start and end point for both partitions.
For the first partition, the start point will be the same. For the second partition, the end point will be the same. The end point of the first partition is the start point of the second partition.

Take the end number for the first partition you recorded in step 12, add more space to get the new end. Alternatively, if your first partition is actually the emulated storage, subtract the reallocated space to get the new end point. I advise to add at least 2GB (2048MB) to Userdata feel safe about having enough storage for apps. DON'T TRY TO REMOVE EMULATED STORAGE ALTOGETHER BY ALLOCATING ALL OF THE AVAILABLE SPACE TO USERDATA! Emulated storage is coded into OS environment and requires additional modifications to work properly.
15. 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 OLD_START NEW_END (change ext2 to fat32 if the first partition had that file system)
name 14 Userdata (change the number and the name according to your environment)
mkpartfs logical ext2 NEW_START OLD_END (change ext2 to fat32 if the second partition had that file system; make sure to include GB as the designation of the end point in order to stretch the partition to the end of the onboard storage)
name 15 SDCard (change the number and the name according to your environment)
quit
These commands create the partitions with ext2 file system and given beginning and end parameters, rename them as required, and close parted.
16. "Damage" the internal, emulated SD card so that it could be formatted properly later. REMOVE YOUR PHYSICAL SD CARD BEFORE THIS STEP TO AVOID WIPING THE WRONG CARD!!!
Tap Mounts and storage -> Format /storage/sdcard0 -> default and confirm the operation.
17. Insert the physical SD card (sdcard1) that you removed in step 2 back into the device.
Make sure it's mounted by going to Mounts and storage and checking its status (it should say unmount /storage/sdcard1/). If not, mount it by executing on the appropriate option.
18. 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 (change the number in mmcblk0pXX according to your environment - that's the partition that need to have file system ext4 - refer to your notes from step 12)
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p14 (change the number in mmcblk0pXX according to your environment)
e2fsck -fpDC0 /dev/block/mmcblk0p14 (change the number in mmcblk0pXX according to your environment)
These commands convert Userdata partition into the appropriate ext4 filesystem, which is not supported natively in the recovery environment. If you receive any errors while executing these commands, reboot recovery.
19. Reboot the device into full Android.
19.1 Remove the physical SD card for safety.

19.2 Go to the top menu level of recovery. Then select the top option Reboot the device.
20. When Android loads fully, you'll notice a notification about storage file system. Tap it and follow the prompts to format it.

21. Insert the physical SD card and reboot into the recovery to restore the backup from step 2.
Backup and Restore -> Restore from /storage/sdcard1.
22. 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 & bash-based parted utility:
Code:
*flash 4.1.2 & install recovery*
*boot recovery*
adb shell
umount /storage
parted /dev/block/mmcblk0
print
*record start point of Userdata and end point of SDCard*
rm 15 (change the number according to your environment)
rm 14 (change the number according to your environment)
mkpartfs logical ext2 1621 7865 (change the numbers according to your environment)
name 14 Userdata (change the number and the name according to your environment)
mkpartfs logical ext2 7865 15.6GB (change the numbers according to your environment)
name 15 SDCard (change the number and the name according to your environment)
*remove physical SD card*
*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 (change the number in mmcblk0pXX according to your environment)
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p14 (change the number in mmcblk0pXX according to your environment)
e2fsck -fpDC0 /dev/block/mmcblk0p14 (change the number in mmcblk0pXX according to your environment)
*remove physical SD card*
*reboot*
*format emulated SD card*
*reboot recovery*
*restore backup*
*reboot*
*restore sdcard0/*
*reboot*

Attached Files
File Type: zip fs-utils.zip - [Click for QR Code] (431.3 KB, 25 views)
Last edited by bsined; 17th April 2014 at 07:19 AM.
17th April 2014, 04:27 AM   |  #2  
bsined's Avatar
OP Senior Member
Flag Washington, DC
Thanks Meter: 95
 
211 posts
Join Date:Joined: Mar 2013
More
Sign FAQ
Will it work with Android 4.2/4.3/4.4 or an older version of recovery?

So far I have tested with the versions mentioned in the guide. You can test whether this method will work for your setup without jeopardizing any data by completing step 7 of requirements and executing the following commands in ADB shell after booting into your recovery:
Code:
parted /dev/block/mmcblk0
print *wait for output*
quit
cd /storage/sdcard1 *change if your physical sdcard is sdcard0*
tune2fs *no parameters*
e2fsck *no parameters*
No errors indicate the method works for you. Please make sure to tell me about your setup in the comments - I'll update the compatibility list.

Last edited by bsined; 17th April 2014 at 07:17 AM.
17th April 2014, 04:27 AM   |  #3  
bsined's Avatar
OP Senior Member
Flag Washington, DC
Thanks Meter: 95
 
211 posts
Join Date:Joined: Mar 2013
More
Phone Tested devices
Did it work on your device or did you fail? Leave a comment and I'll update the list!

Barnes & Noble
- Nook Tablet 16GB

Sony
- Xperia T/TL/TX
Last edited by bsined; 17th April 2014 at 07:10 AM.
17th April 2014, 07:19 AM   |  #4  
bsined's Avatar
OP Senior Member
Flag Washington, DC
Thanks Meter: 95
 
211 posts
Join Date:Joined: Mar 2013
More
Links to tools and recoveries
Reserved
20th September 2014, 01:49 PM   |  #5  
derpotato's Avatar
Member
Thanks Meter: 12
 
81 posts
Join Date:Joined: May 2012
Sorry for bumping an old thread, but is there any way to remove the emulated SD card ? Or, at least point the physical SD Card as the primary SD Card.

I have searched everywhere but I can't seem to do it. If you know a way, it will help a LOT of people, because a lot of people have this problem and the solutions is not working. I tried to use the app from playstore, didn't work. Tried to find vold.fstab, no vold.fstab available in CM11. My device is XIaomi Redmi 1s running CM11.
Last edited by derpotato; 20th September 2014 at 01:52 PM.
25th September 2014, 08:14 AM   |  #6  
bsined's Avatar
OP Senior Member
Flag Washington, DC
Thanks Meter: 95
 
211 posts
Join Date:Joined: Mar 2013
More
Quote:
Originally Posted by derpotato

Sorry for bumping an old thread, but is there any way to remove the emulated SD card ? Or, at least point the physical SD Card as the primary SD Card.

I have searched everywhere but I can't seem to do it. If you know a way, it will help a LOT of people, because a lot of people have this problem and the solutions is not working. I tried to use the app from playstore, didn't work. Tried to find vold.fstab, no vold.fstab available in CM11. My device is XIaomi Redmi 1s running CM11.

As far as I could understand in Xperia environment settings, "internal storage" is a required location for OS. I think it's possible to emulate that access on an SD card but it would require decompiling and recompiling environment data or something else with a high risk of failing since you'd need to modify the OS instead of just the partition table.
25th September 2014, 08:20 AM   |  #7  
derpotato's Avatar
Member
Thanks Meter: 12
 
81 posts
Join Date:Joined: May 2012
Quote:
Originally Posted by bsined

As far as I could understand in Xperia environment settings, "internal storage" is a required location for OS. I think it's possible to emulate that access on an SD card but it would require decompiling and recompiling environment data or something else with a high risk of failing since you'd need to modify the OS instead of just the partition table.

Oh I see.. that's too bad. Well, thanks for the information
Last edited by derpotato; 25th September 2014 at 08:22 AM.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes