[ONE General] ilmich:
WARNING!!!​

Everyone is responsible for the proper functioning of their device. This guide is the result of personal experiments and I'm not responsible for any damage caused to your device as a result of improper use of its contents.

Introduction

Stock partitions layout has a 1.3Gb /system partition that is too small for users that flash modern custom roms + some kinds of google apps.

This is a step by step guide to change the layout of the partitions table with a bigger /system partition.

How

On OnePlus One, stock partition table looks like the following

... ... ...
/dev/block/mmcblk0p14 : start= 294912, name="system"
/dev/block/mmcblk0p15 : start= 3006464, name="persist"
/dev/block/mmcblk0p16 : start= 3072000, name="cache"
... ... ...
/dev/block/mmcblk0p28 : start= 4521984, name="userdata"
/dev/block/mmcblk0p29 : start= 121552896, name="grow"

With this layout, resizing the /system partition may seem difficult because it's close to other very important partitions.

So I've experimented with another approach. By resizing userdata partition, and relocate the /system partition at the beginning of the resulting free space, other partitions are left untouched.

There are mainly two (little) issues

almost all custom roms out of there assume that /system partition is 1.3gb of size

on internal storage the old area of /system partition are unused.

For the first point, the solution is to resize the filesystem when you first flash a custom rom. To automatically resize filesystem at every update there is an addon.d script.

For the second point the new free space available (the old 1.3G /system partition) can be used as a new /cache partition.

And, again, the new free space available (the old /cache partition) can be the famous /vendor partition (that is out of the scope of this guide).

This guide uses the sfdisk tool from util-linux. In my opinion, it's more powerful than parted and it's easy to use via script.

IMPORTANT - Before you start

Obviously, this method is destructive regarding userdata partition, so make a full backup of your data.

Manually resizing filesystem of /system partition is needed only once because the addon.d script will ensure that everything works as expected. The only exception is when you wipe /system and flash a new rom

Prerequisites

a working TWRP recovery installed on device

knowledge of adb tools

a statically cross compiled sfdisk tool (you can self compile, or use the one attached below)

this addon.d script (thanks to @osmosis)

flashable zip of a custom rom (and optionally gapps, magisk etc etc etc)

flashable zip bacon-resize-system.zip (attached on this post)

Let's go

enter TWRP recovery and connect phone on a PC

push sfdisk into a temporary dir and ensure is executable

adb push sfdisk-arm /tmp
adb shell
cd /tmp
chmod 755 sfdisk-arm

make and pull a backup of your partition table (there is also the 64Gb stock layout in attachments)

./sfdisk-arm -d /dev/block/mmcblk0 > bacon.gpt
exit
adb pull /tmp/bacon.gpt

looking into the partition table you see that userdata partition starts at sector 4521984.

So in order to resize partition (for example 53G instead of 55,8G).

adb shell
cd /tmp
umount /data
umount /sdcard
echo "4521984,53G" | ./sfdisk-arm --no-reread -N 28 /dev/block/mmcblk0

. Scrolling down the output of this command the new userdata partition is

Device Start End Sectors Size Type
/dev/block/mmcblk0p28 4521984 115671039 111149056 53G unknown

so the start sector of /system partition will be 115671040 (115671039+1)

relocating system partition at the end of the new userdata partition(size now will be 2,8G)

echo "115671040,+" | ./sfdisk-arm --no-reread -N 14 /dev/block/mmcblk0

reboot recovery (kernel need to reload partition table)

reboot recovery

format userdata with TWRP(no wipe... full format)

push custom rom with adb and flash with TWRP (without rebooting)

flash bacon-resize-system.zip

finish.. you can now reboot or continue with flashing gapps, magisk etc etc (but now with a bigger system partition)

Rollback

TODO

Nice to have

flashable zip for addon.d script (WIP)(DONE)