Featured

How To: Re-partition Your Android Tablet Or Smartphone? (All Options Included: Change Size, FS Type, Etc…)

Updated 10 Nov, 2016

Example

Let’s pretend you want to resize your partitions in order to lend some space from your internal storage to the System and Data partitions.

Note: the images below also include errors I got so that you could learn from my mistakes as well.

1. So, the first thing you should do is reboot your device into “Recovery mode“.

Android repartition: Go into Recovery mode

Go into Recovery mode

2. Once there, open up your CLI (Command Line Interface) tool such as Terminal or CMD and issue:

adb root” – in order to start adb as root user.

Then, “adb shell” – in order to access the device shell.

Note: as mentioned on the previous page, you may need to specify the full path to adb, e.g: C:\Program Files(x86)\Android\android-sdk\platform-tools\adb root.

Android repartition: Start adb in root and go inside its shell

Start adb in root and go inside its shell

3-a. Next, use “ls” command to see the files inside the root file-system directory, and then check whether parted is installed by issuing parted command.

In my case (image below), upon issuing “parted” I got a “not found” error. However, since partitioning my device in the past, I know that my partition table uses GPT label – therefore parted is a necessity for me.

Android repartition: parted not found error

parted not found error

3-*. It may be a good idea to also check what tools are available to you on the device itself, so you might want to list the files inside sbin directory: ls sbin.

Android repartition: Found two important partitioning tools

Found two important partitioning tools

3-b. In case you don’t have parted pre-installed on your device, you may download parted from this guide (see previous page), then exit the shell by typing exit.

After downloading and extracting parted, use adb push to get parted inside your device like so: adb push PATH/TO/PARTED /.

Enter the shell again using adb shell.

Android repartition: Pushing parted into device

Pushing parted into device

Issue ls again to make sure parted is there.

Android repartition: make sure parted is there

make sure parted is there

* Tip: If you’re unsure about your device partition names, you can use a command that shows them: cat /proc/partitions.

Android repartition: Print partitions

Print partitions

As you can see, there’s mmcblk0 – which is the main block where all the partitions are stored.

And there are 12 partitions in total which uses the name format “mmcblk0” plus “p” and a number that represent them, such as: mmcblk0p1, mmcblk0p2, etc…

Blocks lie inside /dev directory in Linux. We will use the block we’ve found in order to re-partition the device.

4. In order to make sure you give parted the right parameter, go inside /dev directory: cd /dev.

And use find command to find the exact location of mmcblk0: find -iname mmcblk0.

Don’t forget to change parted user permissions by issuing: chmod 764 /parted – which gives you a permission to execute the program.

Android repartition: Change parted permissions

Change parted permissions

5. Finally, issue: /parted block/mmcblk0 to start the partitioning tool. (If you’re not inside /dev directory then use absolute path: /parted /dev/block/mmcblk0)

Use “p” to list the partitions inside parted.

Type “help” to see the commands available to you.

Android repartition: parted print partitions table

parted print partitions table

Android repartition: parted help

parted help

6. Since parted executes commands on the fly, from now on be super-careful regarding any command you issue!

Warning: the following procedure might break your device partition table if done improperly, and may render it non-bootable. Do NOT engage unless you know what you’re doing.

A short explanation regarding the relevant partitions:

  • Partition number 9 labeled FACTORYFS – is the “system” partition where all the operating system files are stored in.
  • Number 10 – DATAFS – is the “data” partition where all applications usually save their data.
  • Number 11 – UMS (USB Mass Storage) – is the internal storage partition where all the stuff such as: pictures, videos, etc, are stored in.

To resize those, you’ll have to delete them all and then assign different sizes – this is where a backup might become handy (I recommend copying all the files to your computer prior to erasing any partition).

After erasing and re-partitioning the available space, you should re-label the partitions with the same names (for compatibility sake) and create file systems (I prefer using ext4, however, if your device came with other specific file systems, it might be a good idea to stick to those).

So, how do we do it?

Here’s the sequence of commands with a following explanation:

(parted) rm 9
(parted) rm 10
(parted) rm 11

Will delete FACTORYFS, DATAFS and UMS respectively.

Parted: rm 9

Parted: rm 9

(parted) unit b

Change the unit to bytes in order to be accurate as possible (for optimum sake).

(parted) p

Redisplay the partition table, this time showing size in bytes.

Parted: Change unit to bytes

Parted: Change unit to bytes

(parted) mkpart primary 176160768 2071986687 [the first number is one byte bigger then the ending number of the previous partition which in this case is 8, the second number minus the first will determine the final size of the partition]
(parted) mkpart primary 2071986688 4456448511
(parted) mkpart primary 4456448512 15216934911

Creating the three partitions again after deleting them previously.

Parted: recreating the partitions

Parted: recreating the partitions

Note the above numbers are just examples, you should use consecutive numbers between each new partition, under the limits of your device space of course.

(parted) name 9 FACTORYFS
(parted) name 10 DATAFS
(parted) name 11 UMS

Will re-label the partitions.

Parted: renaming the partitions

Parted: renaming the partitions

(parted) unit mb

(parted) p

Check to see that your partitions are having the size you wanted and then quit.

(parted) quit

Exit parted.

mke2fs -t ext4 /dev/block/mmcblk0p9
mke2fs -t ext4 /dev/block/mmcblk0p10
mke2fs -t ext4 /dev/block/mmcblk0p11

Assign ext4 file system type to each of the newly created partitions.

Assign ext4 file system type

Assign ext4 file system type

7. Lastly, while still in “recovery mode”, re/install the system files (using the device recovery options) and only then it should be safe to reboot the device.

Tip: adb sideload command might be useful at this point.

  • PAGE
  • 1
  • 2

The comment section is temporarily closed due to remodeling.