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

Search This thread

bsined

Senior Member
Mar 22, 2013
229
134
Washington, DC
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*
 

Attachments

  • fs-utils.zip
    431.3 KB · Views: 1,269
Last edited:

bsined

Senior Member
Mar 22, 2013
229
134
Washington, DC
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:

bsined

Senior Member
Mar 22, 2013
229
134
Washington, DC
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:

derpotato

Senior Member
May 26, 2012
105
14
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:

bsined

Senior Member
Mar 22, 2013
229
134
Washington, DC
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.
 

derpotato

Senior Member
May 26, 2012
105
14
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:

sourabhp

Senior Member
Jan 29, 2013
644
91
does this method work on Xperia ZR stock 4.4.4 with NUT's dual recovery installed?
in the step where phone has to be booted in recovery mode n connected to pc via USB, nothing happens as I connect. when I type adb shell, error message returns as device not found.

Is there any work around or guide for this?
 

bsined

Senior Member
Mar 22, 2013
229
134
Washington, DC
does this method work on Xperia ZR stock 4.4.4 with NUT's dual recovery installed?
in the step where phone has to be booted in recovery mode n connected to pc via USB, nothing happens as I connect. when I type adb shell, error message returns as device not found.

Is there any work around or guide for this?

I think there are separate drivers for ADB to work in recovery mode. Sorry that I forgot about them and I'm not sure whether they're included with FlashTool. My best suggestion is to search the forums.
 

sourabhp

Senior Member
Jan 29, 2013
644
91
I think there are separate drivers for ADB to work in recovery mode. Sorry that I forgot about them and I'm not sure whether they're included with FlashTool. My best suggestion is to search the forums.

I searched with google for ADB drivers in recovery mode and found one but even after that device was not detected in recovery mode.
I tried uninstalling and re-installing drivers but no luck. may be need more research
 

akthakur84

Member
Jan 8, 2014
48
8
Manali

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.​
[/code][/hide]
[/size]

Thanx bro. I have successfully partitioned my device (Xperia L).
But when I checked the file system, it is ext3 not ext4.
Still my device is running well.
Will it effect the performance of my device?
 
Last edited:

jjiiaa

New member
Feb 11, 2010
2
0
Is it possible using this method to shirk down the size of SYSTEM partition too?
Any extra caution need to take k?
 

bsined

Senior Member
Mar 22, 2013
229
134
Washington, DC
Is it possible using this method to shirk down the size of SYSTEM partition too?
Any extra caution need to take k?

First off, SYSTEM partition isn't that big - less than 1GB, so you won't gain much from shrinking it. Secondly, I'm not sure where recovery is written. You're risking bricking your phone. Lastly, if you shrink the partition too tightly, you'll effectively remove the ability to upgrade your device's firmware because all ROMs have various sizes.
 

israfild

Member
Nov 18, 2010
5
0
I have installed Bliss Pop Lollipop 5.0.2 ROM on my Xperia L, will this make any difference? Should this work?
 

bsined

Senior Member
Mar 22, 2013
229
134
Washington, DC
I have installed Bliss Pop Lollipop 5.0.2 ROM on my Xperia L, will this make any difference? Should this work?

I think Android 4.4+ utilizes the entire internal storage as a single block, so the guide is pointless. If that's not the case on your device and you're willing to be the guinea pig, please do attempt the repartitioning and report on the results.

Sent from my LT30p using XDA Free mobile app
 

zero995

Senior Member
Apr 4, 2013
197
61
@bsined i follow the steps but now i stay with a corrupt table and ia cant start my phone XPERIA L i follow the step i dont know what i did bad can you help me?
 

zero995

Senior Member
Apr 4, 2013
197
61
i try with 4.1 and 4.2.2 by ftf but no my phone doesnt start now i'm tired i got leave that perhaps i'm gonna buy a new phone pfff :c
 

bsined

Senior Member
Mar 22, 2013
229
134
Washington, DC
i try with 4.1 and 4.2.2 by ftf but no my phone doesnt start now i'm tired i got leave that perhaps i'm gonna buy a new phone pfff :c

If the phone doesn't start at all, that doesn't sound like it's related to partition tables. If the screen, the vibrator, and the LED turn on, the phone is in a soft brick and should be recoverable. You should ask in the FTF threads if you get any errors in flashtool.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    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*