[Tutorial] How to resize partitions on an android phone using Parted
[Tutorial] How to resize partitions on an android phone using Parted
Follow the steps below to resize partitions on an android phone using Parted
cd C:\Users\X3non\Desktop\part
adb push parted /sbin
adb push mkfs.ext4 /sbin
adb shell
chmod 777 /sbin/parted
chmod 777 /sbin/mkfs.ext4
parted /dev/block/mmcblk0
print
or
p free
rm 21
rm 20
rm 19
rm 18
rm 17
mkpart system ext4 43 2141
name 17 system
set msftdata on
quit
mkfs.ext4 /dev/block/mmcblk0p21
Quote:In this video tutorial, i'm going to be showing how to resize partitions on an android device using parted tool. Now parted tool is a command line tool
Now i've connected my device and it's currently connected in TWRP recovery
Now before we begin i want to resize my system partition and reduce it's size from 3GB to 2GB, take the extra 1gb and add it into userdata partition to increase my internal storage
Now i've made my TWRP backup and saved it on my PC
Now this is parted tool right here, saved on my PC as well
So i'm going to quickly open a CMD prompt and type adb devices, so my device is detected
Another thing you need to note is that my device is also detected in mtp storage so i can transfer files while in recovery mode
So let me quickly begin, we'll need to transfer this two files into the phone
We'll do this by changing directory, cd, enter
Now i'm in this folder, so adb push parted which is the name of the file i want to copy to /sbin folder, enter
Successful
I'll repeat the same thing for the second file
Now, i'll open shell, adb shell
I'm going to give permisssion to the files i just copied into sbin folder
Once that's done, we'll launch parted by typing parted /dev/block/mmcblk0
Now this is the mount point for internal storage on android devices, Enter
now parted will give me a welcome message, Welcome to parted, type help to view a list of commands
you can just type help if you need to view the list of commands you can run on parted tool
Now, i'm going to do print, this will show me a list of all the partitions currently on my phone now, their start address and end address, the sizes, the file systems
So since i want to reduce the size of system which is here, you can see the size says 3GB, basically this is 3GB and it's at 17
I need to delete all the partitions till i get to system
So to do this, the command in parted is
RM remove 21, so i'll remove 21 first
am i sure i want to continue? yes, okay, cancel
So now we actually need to do something in TWRP before begin and that is Mount, untick system, untick data and untick cache
So we go to twrp mount and untick every item listed there
now we can return back to parted, lets try removing again
RM 21, hold on that is strange, okay so it has actually removed 21 for us and so we remove 20
Okay before we move further, let me quickly highlight these items, we'll need to store these items somewhere so that we can use while calculating the new values
I'm going to quickly paste them in notepad++
Now lets proceed, we remove 20, we remove 19, we remove 18, remove 17
so let me quickly go to print again, and so here we've seen that there's no extra partition outside this one
So it's time to create new partitions, the command for creating new partitions is mkpart partition name is system, the file system is ext4, now the start address will be the end address for this one, then the end address since we want 2GB, this is 1GB
hold on, so this is the size of 3GB, all we need to do is open a calculator, 3147 / 3
so this is the size for 1GB, we want to make it 2GB, so this is the new size we want but to get the end address, end address will be the same thing as this plus the start address
So i hope you understand, that to get end address, we'll add this 2GB to this start address, so plus 43 is equals to 2141
so here we'll type 2141 and press enter
now we'll name 17 going to name this partition, it'll be 17 already so we'll name 17 system which is the last partition we deleted
now set the flag back to what it was, so set 17 msftdata, on
now lets quickly type print again to show us what we've done, and so you can see system partition starts where boot stopped, ends here and the size is 2GB, file system is ext4 so basically we've created system partition
Now all we need to do is repeat the same commands for all the other partitions while making necessary calculations
So cache is the next partition, we'll go to., mkpart cache, now cache also has ext4 so ext4, the start address will be the end address of system, now the size for cache is 157 so all we need to do is add 157 to the start address, plus 157, 2298, so end address is 2298, enter
so we'll name 18 to cache
we'll set 18 to msftdata, on
and if we print, here we go, this is cache, so next is recovery
so mkpart recovery, now recovery has no file system so we'll press an empty space as the name, so there are 3 empty spaces here
so the first empty space, then the empty space for the name then an extra empty space so 3 empty spaces then the start address will be 2298 which is the end address for cache, add 14.7
plus 14.7, okay hold on, let me make it a standard calculator, 2298 + 14.7 , so i'm just going to approximate this to 2313. So 2313
So we name 19 to recovery, set 19 msftdata, just type on and enter
Now when we print, we have recovery, no file system
So we make partition for the next which is misc, also misc does not have any file system so 3 spaces, then start address 2313, misc is 1mb, just add 1mb is 2314 because 1000 plus kb is 1mb and so enter
Now name 20 to be misc, set 20 msftdata on
Now we print, that's misc for you
Now the last partition is userdata. mkpart userdata ext4, you can see it here it's ext4, so the start address is 2314, the end address will be the size of the disk itself so that it'll use up all the free space it can get, so which is 7650, this is it here, this is the full disk length, so the end address will be the end
So name 21 to userdata, lastly set 21 msftdata on and when we print again
Now we have here, internal storage which is userdata 5GB plus, but initially we had 4GB plus
So what you'll realize now is that the system has no operating system , no recovery mode and no userdata so once i reboot from the current twrp i'm going to get stuck on bootlogo
So we are already done with partitioning the device, all we need to do now is flash something into these partitions, before we do that we'll quickly exit parted tool
To exit parted tool, we'll type quit. So this has taken us back to shell
It'll tell you that you need to edit etc/fstab, just ignore this for now. Now we need to format userdata before we proceed
To format userdata, we're going to use the second file we copied. what was the name of the file again, mkfs
So now we type mkfs, now userdata partition is 21 so what we'll do now is /dev/block/mmcblk0p21 then hit enter
so it's currently formatting userdata, okay it's all done now
we can now close this tool, close this, well we don't need this as well
Now what we need now is to goto TWRP, mount cache, okay hold on, you can see there's no internal storage
So all we need to do now is goto TWRP, goto wipe, advanced wipe, wipe cache, data and system then swipe to wipe
okay hold on, so we're going to do repair / change file system
we'll do for data first, repair / change file system, change file system to ext4 then swipe, so it's done formatting data to ext4
back, back
Now we'll do the same thing for system, change file system, ext4, swipe, back, back
We'll do the same thing for cache, change file system to ext4
Now once this is done, we'll go back to TWRP mount and you can see all 3 items can now be mounted, now all we'll need to do is when you come over here, you can see the internal storage is now available
So i'm simply going to copy my twrp backup into the internal storage, my twrp backup contain the exact same partitions that we just wiped and made again, which is cache, userdata, misc, recovery and system
Okay, so copying is complete, i can now disconnect the phone
Now all i'll need to do is restore backup, click on the backup, select all the partitions i need to restore then swipe to restore
So basically this is how resize partitions on an android device using parted tool
Ensure to subsribe for more video tutorials
(17-07-2020, 04:10 AM)Pius Oblie Hi. How to solve permission denied when I typed chmod 777 /sbin/parted
(22-07-2020, 05:50 PM)muhd90 0mb internal storage host.
(21-09-2020, 01:39 PM)amey.adhalikar@gmail.com Hi,
Very good article.
However, while partitioning my Redmi Note 5 Pro, the phone was restarted accidently, and the system partition is deleted from the device, i.e. the partition table doesn't contain the system partition.
Now the phone is stuck on fastboot, and I am not even able to flash recovery or system image to the phone using fastboot.
Could you please help me in this case?
Thanks,
Amey
(22-09-2020, 09:12 AM)X3non(21-09-2020, 01:39 PM)amey.adhalikar@gmail.com Hi,
Very good article.
However, while partitioning my Redmi Note 5 Pro, the phone was restarted accidently, and the system partition is deleted from the device, i.e. the partition table doesn't contain the system partition.
Now the phone is stuck on fastboot, and I am not even able to flash recovery or system image to the phone using fastboot.
Could you please help me in this case?
Thanks,
Amey
create a new thread for your device issue by clicking "Ask Question" at the top
in the new thread, list all the partitions you removed without creating them back
(09-11-2020, 10:42 PM)vikas14 i am getting an error Kernel too old Fatal error and no welcome message. Please suggest what to do. I am using Nexus 7 Grouper