FORUMS
Remove All Ads from XDA

[Guide] Repartition Nexus7(2013) to increase system partition - Extra Space for Rom

50 posts
Thanks Meter: 58
 
By rkhat, Member on 2nd May 2017, 02:46 AM
Post Reply Email Thread
Hi, this is my first time posting here. I noticed there is no guide to increase the system partition size in Nexus 7 (2013). The system partition is only around 880MB making it impossible to flash new ROMs and large package of GApps. This guide is for Nexus 7 (2013) wifi 32GB but it should work for other Nexus 7 (2013) editions and even Nexus 7 (2012) with some numbers changed.

My guide is based on this guide for Nexus 5. Check it out. The only issue with Nexus 7 is that the recovery partition is between the system and userdata partitions in the partition table. So deleting the partitions (which includes recovery partition) and then recreating them with offsets might leave your tablet bricked. If you have a way to unbrick the tablet or you are manly enough, you can try the guide written in the next comment. I haven't tested it. Leave a comment if it works. Anyway from the Nexus 5 guide:

Quote:

The high-level procedure here is, since filesystems must be contiguous and in order so they can be addressed properly, we need to delete every partition inclusively from system to userdata, then recreate them with new storage offsets.

This part is not very accurate. I am not sure about Nexus 5 but in Nexus 7, I have changed the order with great success. Only thing is that you need to restart at the end so that the recovery mode updates the mounting configuration. I am not sure if it works with the stock ROM but it definitely works with a custom ROM.

The downside of my way is that you end up with around 880MB unused memory. You can give it to the cache partition. Otherwise, you have to do the untested one in the next comment.

Before we start, I am not liable if it doesn't work or makes your device unusable. The tested guide below works for me.

Nexus 7 2.9GB system partition proof

Tested Guide starts here:

Prerequisite:
1. PC (any OS) with adb and fastboot
2. Nexus 7 with TWRP recovery connected to the PC via USB.
3. Get parted from iwf1.com/iwf-repo/parted.rar and extract it into any directory
4. (Optional) System and userdata partitions are wiped out. So backup system and/or data partitions using TWRP recovery

Steps:
1. Open TWRP recovery mode in Nexus 7. Make sure to have the system partition read/write.
2. Go to mount and unmount all partitions you are going to modify (for now system and data).
3. Open PC's command line in parted's directory
4. The next steps are on the command line unless stated:

Code:
adb push parted /
adb shell
~ # chmod +x parted
~ # /parted /dev/block/mmcblk0
(parted): unit b
(parted): p
I used unit b to get partition sizes in bytes. So you can resize accurately this way. You will get the following partition table by default. Keep a copy of this partition table (and one with unit compact for easy readability) as reference if you mess up or want to restore to default.

Code:
Number  Start        End          Size         File system  Name      Flags
 1      67108864B    156745727B   89636864B    fat16        radio
 2      201326592B   204472319B   3145728B                  modemst1
 3      204472320B   207618047B   3145728B                  modemst2
 4      268435456B   283795455B   15360000B    ext4         persist
 5      335544320B   336343039B   798720B                   m9kefs1
 6      336343040B   337141759B   798720B                   m9kefs2
 7      402653184B   403451903B   798720B                   m9kefs3
 8      403451904B   406597631B   3145728B                  fsg
 9      469762048B   471298047B   1536000B                  sbl1
10      471298048B   472834047B   1536000B                  sbl2
11      472834048B   474931199B   2097152B                  sbl3
12      474931200B   480174079B   5242880B                  aboot
13      480174080B   480698367B   524288B                   rpm
14      536870912B   553648127B   16777216B                 boot
15      603979776B   604504063B   524288B                   tz
16      604504064B   604505087B   1024B                     pad
17      604505088B   606041087B   1536000B                  sbl2b
18      606041088B   608138239B   2097152B                  sbl3b
19      608138240B   613381119B   5242880B                  abootb
20      613381120B   613905407B   524288B                   rpmb
21      613905408B   614429695B   524288B                   tzb
22      671088640B   1551892479B  880803840B   ext2         system
23      1551892480B  2139095039B  587202560B   ext4         cache
24      2147483648B  2148532223B  1048576B                  misc
25      2214592512B  2225078271B  10485760B                 recovery
26      2281701376B  2281709567B  8192B                     DDR
27      2281709568B  2281717759B  8192B                     ssd
28      2281717760B  2281718783B  1024B                     m9kefsc
29      2348810240B  2348843007B  32768B                    metadata
30      2415919104B  31272713727B 28856794624B  ext4        userdata
5. Rename the system partition to disable it
Code:
(parted): name 22 unused1
6. Now you need to delete userdata partition:
Code:
(parted): rm 30
7. You need to create 2 primary partitions in place of userdata. First one will be the system partition. Second one will be the userdata partition. I recommend to have the system partition to start with the same byte userdata started and size divisible by 4096 bytes. Leave some space between the 2 divisible by 4096 bytes (block-size). Then have userdata partition start with a number divisible by 4096 bytes, size divisible by 512 bytes and ends where user data ended. I increased my system partition to around 2.93GiB (you can resize it whatever you want). I don't really need a lot of userdata. So my configuration would be:
Code:
(parted): mkpart primary 2415919104B  5570068479B
(parted): mkpart primary 5637144576B 31272713727B
8. Now you need to rename these 2 partitions:
Code:
(parted): name 30 system
(parted): name 31 userdata
(parted): p
9. Finally you need to create ext4 filesystem for system and userdata.
Code:
(parted): quit
~ # mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p30
~ # mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p31
~ # /parted /dev/block/mmcblk0 p
10. Have a final look at the partition table to see if everything is correct. Then Reboot into Recovery. This is a very important step. The mount configuration (/etc/fstab) doesn't update until you reboot.
Code:
~ # exit
adb reboot recovery
Done! You have a new system partition with a larger size ready for a ROM. The Size of the ROM will shrink after flashing a new ROM, Using TWRP, Wipe -> Advanced Wipe -> select system -> Resize File System -> Swipe.

Note: You might need to wipe cache/dalvik (might need wipe system too for mount to work), then unmount and remount system/cache/data for everything to work (for example, I had tablet's internal storage not showing on PC initially). But once everything works, it will always work

Final partition table looks like this:
Code:
Number  Start   End     Size    File system  Name      Flags
 1      67.1MB  157MB   89.6MB  fat16        radio
 2      201MB   204MB   3146kB               modemst1
 3      204MB   208MB   3146kB               modemst2
 4      268MB   284MB   15.4MB  ext4         persist
 5      336MB   336MB   799kB                m9kefs1
 6      336MB   337MB   799kB                m9kefs2
 7      403MB   403MB   799kB                m9kefs3
 8      403MB   407MB   3146kB               fsg
 9      470MB   471MB   1536kB               sbl1
10      471MB   473MB   1536kB               sbl2
11      473MB   475MB   2097kB               sbl3
12      475MB   480MB   5243kB               aboot
13      480MB   481MB   524kB                rpm
14      537MB   554MB   16.8MB               boot
15      604MB   605MB   524kB                tz
16      605MB   605MB   1024B                pad
17      605MB   606MB   1536kB               sbl2b
18      606MB   608MB   2097kB               sbl3b
19      608MB   613MB   5243kB               abootb
20      613MB   614MB   524kB                rpmb
21      614MB   614MB   524kB                tzb
22      671MB   1552MB  881MB   ext2         unused1
23      1552MB  2139MB  587MB   ext4         cache
24      2147MB  2149MB  1049kB               misc
25      2215MB  2225MB  10.5MB               recovery
26      2282MB  2282MB  8192B                DDR
27      2282MB  2282MB  8192B                ssd
28      2282MB  2282MB  1024B                m9kefsc
29      2349MB  2349MB  32.8kB               metadata
30      2416MB  5570MB  3154MB  ext2         system
31      5637MB  31.3GB  25.6GB  ext4         userdata
To increase cache size:
You have 880MB unused storage from the old system partition. You can keep it the way it is as you have the old system partition here which can be re-enabled quickly in the future. OR You can give this unused partition to the cache partition without messing around a lot. I recommend keeping a small unused partition in place of the old system partition to avoid messing with the order of recovery partition.

Code:
adb push parted /
adb shell
~ # chmod +x parted
~ # /parted /dev/block/mmcblk0
(parted): unit b
(parted): p
(parted): rm 22
(parted): rm 23
(parted): mkpart primary 671088640B 671096831B
(parted): mkpart primary 671096832B 2139095039B
(parted): name 22 unused1
(parted): name 23 cache
(parted): p
(parted): quit
~ # mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p23
~ # quit
The Following 6 Users Say Thank You to rkhat For This Useful Post: [ View ] Gift rkhat Ad-Free
 
 
2nd May 2017, 02:50 AM |#2  
rkhat's Avatar
OP Member
Thanks Meter: 58
 
More
Edit: Deleted
The Following 3 Users Say Thank You to rkhat For This Useful Post: [ View ] Gift rkhat Ad-Free
2nd May 2017, 11:00 AM |#3  
k23m's Avatar
Senior Member
Thanks Meter: 289
 
More
Quote:
Originally Posted by rkhat

If you have a way to unbrick the tablet or you are manly enough, you can try the guide...

I haven't tested it. Leave a comment if it works.

No, there is no way to unbrick the tablet.

Here is a likely comment "So I took the jump in the name of exploration, and bricked my tablet"

Now, are you manly enough to try your own guide?

/EDIT 1
2018 - Unbricking method is available.

/EDIT 2
Here is a Non-destructive repartition script which you can simply 'install' from TWRP.
The Following User Says Thank You to k23m For This Useful Post: [ View ] Gift k23m Ad-Free
2nd May 2017, 12:24 PM |#4  
rkhat's Avatar
OP Member
Thanks Meter: 58
 
More
Quote:
Originally Posted by k23m

No, there is no way to unbrick the tablet.

Here is a likely comment "So I took the jump in the name of exploration, and bricked my tablet"

Now, are you manly enough to try your own guide?

If you checked the comment write below the second link, you will see a link to a repair option with RIFF JTAG box (costs >100$). I am not going to invest into a repair kit on a device that is probably worth less than the box, but hopefully someone who has the box and tablet can test the solution in the "name of exploration" and help others

Anyway, I am going to buy a chromebook in a year. Tablet market is dead. I might try the second solution on the N7 if some realtive doesn't steal it.
22nd May 2017, 03:09 PM |#5  
Senior Member
Flag Sydney
Thanks Meter: 72
 
More
Didn't know that parted on works on android partitions in the way you describe.
My n7 2013 is in pretty bad shape, it has severe touch screen problems which sucks (its gone back to ASUS three times! pretty much gave up... haha they don't want to see it again).
So maybe I'll be game enough to try out the guide someday, but not today
27th May 2017, 04:30 AM |#6  
Junior Member
Thanks Meter: 0
 
More
There are something strange after I follow this guide.
If I copy files to /system and /system usage space is over 1GB.
/system will become read-only and mount as ro.
I try to remount /system as rw. But if I copy files into /system, it will become ro again.
Only I can do is format /system. Anyone can help?
Thanks.
25th August 2017, 09:16 PM |#7  
Senior Member
Thanks Meter: 46
 
More
I assume to do this you only need custom recovery and root?
27th August 2017, 10:22 PM |#8  
Senior Member
Thanks Meter: 46
 
More
OK, I've done the repartitioning. Looks good.

But, I can't seem to flash via TWRP. I try to side-load ROM and I see:
detecting filesystem ext4 for ...
Patching system image unconditionally...
E1001: Failed to update system image.
Updater process ended with error: 7

Any ideas?
29th August 2017, 05:44 AM |#9  
rkhat's Avatar
OP Member
Thanks Meter: 58
 
More
Quote:
Originally Posted by RedBullet

OK, I've done the repartitioning. Looks good.

But, I can't seem to flash via TWRP. I try to side-load ROM and I see:
detecting filesystem ext4 for ...
Patching system image unconditionally...
E1001: Failed to update system image.
Updater process ended with error: 7

Any ideas?

Which ROM did you use? I don't think it works with stock ROM. I use lineageOS.

Btw if you attempt to update the ROM instead of reinstalling it, the system partition will shrink back and you can't use the following step to fix it:

Quote:

The Size of the ROM will shrink after flashing a new ROM, Using TWRP, Wipe -> Advanced Wipe -> select system -> Resize File System -> Swipe.

I found a solution to skip this whole resizing step. I am going to post it after some testing.
29th August 2017, 03:37 PM |#10  
Senior Member
Thanks Meter: 46
 
More
Quote:
Originally Posted by rkhat

Which ROM did you use? I don't think it works with stock ROM. I use lineageOS.

Btw if you attempt to update the ROM instead of reinstalling it, the system partition will shrink back and you can't use the following step to fix it:



I found a solution to skip this whole resizing step. I am going to post it after some testing.

Yea, I was flashing lineage. I eventually got it. I wonder if my partition shrunk back also... What's easiest way to check?

Oh and what do you mean by update vs re-install? I am just flashing via sideload
29th August 2017, 07:23 PM |#11  
rkhat's Avatar
OP Member
Thanks Meter: 58
 
More
Quote:
Originally Posted by RedBullet

Yea, I was flashing lineage. I eventually got it. I wonder if my partition shrunk back also... What's easiest way to check?

Oh and what do you mean by update vs re-install? I am just flashing via sideload

Use parted to print the partition table. First four steps in my guide. Then check the system partition. If it's like the original size, it shrank.

LineageOS supports updating. Let's say you are now on LineageOS 20170801. You want to update to 20170829. When you sideload the newer version, it will attempt to update the previous version (basically only update the differences between the 2 versions). You retain any modification to the system partition (like gapps). Reinstalling means you wipe the system partition then sideload the ROM.

So when updating LineageOS, the system partition will shrink again and I wasn't able to resize it back. Thus corrupting the system partition.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes