[G2 General] GK_222:
Resizing LG G2 partition size​

Must have: Latest TWRP Recovery, ADB experience and gdisk for arm in attached zip.

Clean /system partition (unused apps, bloatware, garbage and so on...)

Backup everything important from /sdcard.

Reboot to TWRP and connect ADB (if "ADB devices" fails, check windows "Device Management" and install "Android Sooner Single ADB Interface" for your unrecognized phone).

In TWRP backup /system and /data and download /sdcard/TWRP folder via MTP to your PC.

Now it's ADB time:

[B]# check /system used space (in Mb) and remember it, as we should cut no more than "Available" space:[/B]
adb shell "mount /system"
adb shell "df -m /system"
[B]# un-mount partitions:[/B]
adb shell "umount /system"
adb shell "umount /data"
adb shell "umount /sdcard"
adb shell "umount /cache"
[B]# unzip gdisk in your ADB folder and install it:[/B]
adb push gdisk /sbin
adb shell "chmod 0755 /sbin/gdisk"
[B]# check partitions info:[/B]
adb shell "/sbin/gdisk -l /dev/block/mmcblk0" >gpt.txt
[B]# open new gpt.txt file in your ADB folder
# now you should recalculate your new partitions (30-36) size and position (in sectors)
# partition start-sector should be even, end-sector should be odd
# to make it simplier, use formula: (new size in MB) * 2048 + 1 = (new size in sectors)[/B]

Check my examples:

default (4.4.2 firmware):
30 819200 6488063 2.7 GiB 0700 system
31 6488064 7733247 608.0 MiB 0700 cache
32 7733248 7897087 80.0 MiB 0700 tombstones
33 7897088 7929855 16.0 MiB 0700 spare
34 7929856 8028159 48.0 MiB 0700 cust
35 8028160 60948479 25.2 GiB 0700 userdata
36 60948480 61071326 60.0 MiB 0700 grow

my mod v1:
(30) 800000 3526297 1.3 GiB system
(31) 3526298 3853977 160 MiB cache
(32) 3853978 3858073 2 MiB tombstones
(33) 3858074 3862169 2 MiB spare
(34) 3862170 3866265 2 MiB cust
(35) 3866266 61067229 27.2 GiB userdata
(36) 61067230 61071326 2 MiB grow

my_mod_v2:
(30) 800000 2897153 1 GiB system
(31) 2897154 3122433 110 MiB cache
(32) --- --- deleted tombstones
(33) --- --- deleted spare
(34) 3122434 3126531 2 MiB cust
(35) 3126532 61071326 27.6 GiB userdata
(36) --- --- deleted grow

Important! It's only mine D802 4.4.2 example. You should calculate your own values, because of your /system used size, /cust size for unlock, etc.

/spare and /grow partitions unused on our phones. /tombstones is obesolete since it mounts from /data, anyway.

After all checks and calculations, let's do the magic:

[B]# run gdisk:[/B]
adb shell
cd /sbin
gdisk /dev/block/mmcblk0
[B]# no real changes applied to the phone, before "w" command.
# if you did something wrong, exit by "q" command
# you can check youreself with "p" command (partition list with virtual changes you made).
# OK, let's delete our old partitons and create them anew:[/B]
"d" command > enter partition number (for all 30-36 partitons).
"n" command > enter partition number > start > end > code (start & end = new values in sectors, code = 0700)
"c" command > enter partition number > name (system, cache, etc.)
[B]# if all seems fine, and you're pretty sure of youreself:[/B]
"w" command > "Y" answer
[B]# there is no FS on new partitions, so format them:[/B]
mke2fs -t ext4 /dev/block/mmcblk0p30
mke2fs -t ext4 /dev/block/mmcblk0p31
mke2fs -t ext4 /dev/block/mmcblk0p34
mke2fs -t ext4 /dev/block/mmcblk0p35
[B]# there is no point to format others, because they have no fs by default.
# if using kernel with F2FS support (like Dorimanx), you can format some of them as F2FS:[/B]
mkfs.f2fs /dev/block/mmcblk0p35
[B]# to make TWRP realise, horrors we just did - reboot it:[/B]
reboot recovery
[B]# after reboot, we can optimize /userdata a bit (ext4 only), with this:[/B]
adb shell "tune2fs -m 0 /dev/block/platform/msm_sdcc.1/by-name/userdata"
[B]# bring backups from PC to /sdcard via MTP and restore them, as usual
# now you can reboot to your system with custom-sized partitions!
# P.S. If you notice your /sdcard permissions glith a bit after all this - flash "sdcard Fix Permissions script" from [URL="http://xdaforums.com/showthread.php?t=2239421"]this[/URL] thread.[/B]

Good luck.