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

Search This thread

rkhat

Senior Member
Apr 29, 2017
50
69
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:

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.

klJAY8w.png


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:D

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
 
Last edited:

k23m

Senior Member
Jan 3, 2016
1,009
606
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.
 
Last edited:

rkhat

Senior Member
Apr 29, 2017
50
69
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.
 

navcar

Senior Member
Jun 9, 2010
199
86
Sydney
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 ;)
 

Trunone

Member
May 3, 2010
5
0
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.
 

RedBullet

Senior Member
Mar 31, 2010
707
46
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?
 

rkhat

Senior Member
Apr 29, 2017
50
69
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:

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.
 

RedBullet

Senior Member
Mar 31, 2010
707
46
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
 

rkhat

Senior Member
Apr 29, 2017
50
69
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.
 

theistus

Senior Member
Mar 27, 2010
371
123
would it not be easier/safer to use parted's resize command to shrink the userdata partition, and then use the move command to move partition 23-29, and then use the resize command again to increase the size of the system partition?
 

rkhat

Senior Member
Apr 29, 2017
50
69
would it not be easier/safer to use parted's resize command to shrink the userdata partition, and then use the move command to move partition 23-29, and then use the resize command again to increase the size of the system partition?

I don't think you can do it with parted's move command because according to move's documentation, these are the only supported formats:

  • ext2 (provided the destination partition is larger than the source partition)
  • fat16, fat32
  • linux-swap
  • reiserfs (if libreiserfs is installed)

Partitions 24-29 don't use a file system supported by parted. They definitely contain data (for example recovery partition has your twrp recovery image ).

I think there is a way to do what you are suggesting. In fact, the solution in my 2nd post was about moving the partitons. However, the solution had a mistake which is why I removed it. I had to use dd command to move all the bytes from the old partition to the new partition.

Also, it is somewhat risky. If you do any mistake with the recovery partition (not sure about the other 5 partitions), you pretty much bricked the tablet. If I had anyway to unbrick it, I would do it. Since not, better lose the 840MB.
 

theistus

Senior Member
Mar 27, 2010
371
123
I don't think you can do it with parted's move command because according to move's documentation, these are the only supported formats:



Partitions 24-29 don't use a file system supported by parted. They definitely contain data (for example recovery partition has your twrp recovery image ).

I think there is a way to do what you are suggesting. In fact, the solution in my 2nd post was about moving the partitons. However, the solution had a mistake which is why I removed it. I had to use dd command to move all the bytes from the old partition to the new partition.

Also, it is somewhat risky. If you do any mistake with the recovery partition (not sure about the other 5 partitions), you pretty much bricked the tablet. If I had anyway to unbrick it, I would do it. Since not, better lose the 840MB.

Yeah, that's the one that scares me. That recovery partition is smack dab in the middle, and it's very ... inconvenient.
 

Magendanz

Senior Member
Mar 25, 2008
987
1,071
Issaquah, WA
www.Vote4Chad.com
Rather than move the system partition, I just moved the cache partition ahead of userdata and extended my system partition by 587MB. This allowed me to keep the same partition numbers and have no unused space.

And after flashing an image if you want to extend the logical drive to fill the partition manually, the command is:

Code:
resize2fs -f /dev/block/mmcblk0p22
 
Last edited:
  • Like
Reactions: frankquattrone

wline

Member
Aug 3, 2015
6
1
Rather than move the system partition, I just moved the cache partition ahead of userdata and extended my system partition by 587MB. This allowed me to keep the same partition numbers and have no unused space.
Could you explain a bit more how to do that ?
I have read on a few websites that Android Oreo doesn't use the cache partition anymore. If this is true, could it also be simply removed instead of moved ?
 

k23m

Senior Member
Jan 3, 2016
1,009
606
Non-destructive repartition script

The only issue with Nexus 7 is that the recovery partition is between the system and cache partitions in the partition table.
Code:
Number  Start        End          Size         File system  Name      Flags
22      671088640B   1551892479B  880803840B   ext2         system
23      1551892480B  2139095039B  587202560B   ext4         cache
24      2147483648B  2148532223B  1048576B                  misc
25      2214592512B  2225078271B  10485760B                 recovery
Have another look at the table - recovery is not between the system and cache partitions.

I wrote it a year ago, but now we do have a way to unbrick the tablet, so read on and feel free to experiment :cowboy:

I have read on a few websites that Android Oreo doesn't use the cache partition anymore. If this is true, could it also be simply removed instead of moved ?
Good point. N7's cache is oversized anyway, all my relatively new Xiaomi phones use only 256MB cache. There is no need for complex re-partitioning if we opt for decreased cache. I just did this...
Code:
Number  Start     End       Size      File system  Name      Flags
22      640MiB    1780MiB   1140MiB   ext2         system
23      1780MiB   2040MiB   260MiB    ext4         cache
24      2048MiB   2049MiB   1.00MiB                misc
25      2112MiB   2122MiB   10.0MiB                recovery

Code:
Filesystem                Size      Used Available Use% Mounted on
/dev/block/mmcblk0p30
                         26.4G      7.0G     19.4G  27% /data
/dev/block/mmcblk0p22
                          1.1G    607.0M    517.3M  54% /system
/dev/block/mmcblk0p23
                        258.8M     19.0M    226.7M   8% /cache
Now I have 1.1GB non-destructively resized system and 260MB cache. No changes to other partitions and original OS still works without any backup/restore. It was only a test because personally I have no need for larger system partition. I install LineageOS with pico gapps and later add other Google apks as non-system in the data partition space. I attached a script for the 1.1GB/260MB re-partition. While it is non-destructive, you should do a backup and copy it to your PC first.

Use the latest TWRP and just install sysrepart.zip. The script will create a backup of your original gpt partition table and a log file in the root of internal storage. If you have any issues, post the log.

If you wish to restore original partitioning, install sysrepartundo.zip. This script will attempt to non-destructively resize system again but if you installed some mega-gapps, it will obviously fail. In this case, use TWRP and manually format the system partition, then restore system's backup.

:good:
 

Attachments

  • sysrepart.zip
    764.6 KB · Views: 14,294
  • sysrepartundo.zip
    764.6 KB · Views: 8,203

rkhat

Senior Member
Apr 29, 2017
50
69
Have another look at the table - recovery is not between the system and cache partitions.

That was a typo. It should be between system and userdata because I am taking from userdata to increase the system partition. I'll edit the main post.

I wrote it a year ago, but now we do have a way to unbrick the tablet, so read on and feel free to experiment

Is your guide for soft-unbrick only?

I don't think fastboot can resize or rename a partition. So if you resized the recovery partition to a smaller size or forgot to name a partition "recovery", will your solution be able to handle these situations?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 38
    Non-destructive repartition script

    The only issue with Nexus 7 is that the recovery partition is between the system and cache partitions in the partition table.
    Code:
    Number  Start        End          Size         File system  Name      Flags
    22      671088640B   1551892479B  880803840B   ext2         system
    23      1551892480B  2139095039B  587202560B   ext4         cache
    24      2147483648B  2148532223B  1048576B                  misc
    25      2214592512B  2225078271B  10485760B                 recovery
    Have another look at the table - recovery is not between the system and cache partitions.

    I wrote it a year ago, but now we do have a way to unbrick the tablet, so read on and feel free to experiment :cowboy:

    I have read on a few websites that Android Oreo doesn't use the cache partition anymore. If this is true, could it also be simply removed instead of moved ?
    Good point. N7's cache is oversized anyway, all my relatively new Xiaomi phones use only 256MB cache. There is no need for complex re-partitioning if we opt for decreased cache. I just did this...
    Code:
    Number  Start     End       Size      File system  Name      Flags
    22      640MiB    1780MiB   1140MiB   ext2         system
    23      1780MiB   2040MiB   260MiB    ext4         cache
    24      2048MiB   2049MiB   1.00MiB                misc
    25      2112MiB   2122MiB   10.0MiB                recovery

    Code:
    Filesystem                Size      Used Available Use% Mounted on
    /dev/block/mmcblk0p30
                             26.4G      7.0G     19.4G  27% /data
    /dev/block/mmcblk0p22
                              1.1G    607.0M    517.3M  54% /system
    /dev/block/mmcblk0p23
                            258.8M     19.0M    226.7M   8% /cache
    Now I have 1.1GB non-destructively resized system and 260MB cache. No changes to other partitions and original OS still works without any backup/restore. It was only a test because personally I have no need for larger system partition. I install LineageOS with pico gapps and later add other Google apks as non-system in the data partition space. I attached a script for the 1.1GB/260MB re-partition. While it is non-destructive, you should do a backup and copy it to your PC first.

    Use the latest TWRP and just install sysrepart.zip. The script will create a backup of your original gpt partition table and a log file in the root of internal storage. If you have any issues, post the log.

    If you wish to restore original partitioning, install sysrepartundo.zip. This script will attempt to non-destructively resize system again but if you installed some mega-gapps, it will obviously fail. In this case, use TWRP and manually format the system partition, then restore system's backup.

    :good:
    15
    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:

    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.

    klJAY8w.png


    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:D

    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
    4
    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.
    3
    Edit: Deleted
    3
    Also I'm interested in the ability to undo the sysrepart-flox. Will it undo its changes with your first sysrepartundo.zip?
    EDIT: It seems like it doesn't matter whether I undoed the previous repartition before sysrepart-flox. And also I didn't find any flashable analogues of sysrepart-flox.

    Please use sysrepart-stock.zip to undo more complex changes. The new sysrepart-ultimate.zip is designed to work around any other repartitions.


    Nexus 7'13 TWRP repartition scripts (update):

    sysrepart.zip - 1.1GB system, data is not wiped

    sysrepart-max.zip - 1.3GB system, data is not wiped

    sysrepart-flox.zip - 1.5GB system, data is wiped, 'vendor' partition is added

    sysrepart-ultimate.zip - 4GB system, data is wiped, 'vendor' partition is added, 'recovery' is enlarged to 64MB in-place and your current TWRP continues to function

    sysrepart-stock.zip - data is wiped, original partitions are restored