[LG Optimus L90] Floating Point:
So, here I describe how I resize the partitions and CM13 images. Not for the faint-hearted, do it at your own risk. I made this many times and never faced a brick, Tejas Jedi also made this a few times and didn't have any issues. Make sure to read carefully. Some people will ask "why you do this if you have a 32GB microSD card?". Well, because I can. I saw a huge space unused in system partition after flashing CM13 and gapps pico, and a useless cache partition and saw a potential to maximize userdata partition and won a few more GBs from them. Also, internal SD is much faster than external, even owning a class 10 microSDXC.

This procedure erase all your data. Make sure to make backups before playing with your partition layout. Also make a backup of vital partitions.

It's a long read, I may have made some mistakes, but I tried to describe as close as possible to what I have been doing for months.

How to resize CM13 or any other Android Marshmallow images to fit in a custom partition layout:

You'll need make_ext2fs and rimg2sdat binaries, sdat2img.py script and python installed. rimg2sdat binaries and sdat2img.py script can be downloaded in this thread. Make sure to use make_ext2fs from android-tools-fsutils and not from the topic, otherwise it will fail.

[YOUTUBE]wwXDe-zndrc[/YOUTUBE]

00:00 - Create a folder to work with the binaries and the flashable zip and open as root.

00:06 - Extract flashable zip contents to a folder.

00:27 - Copy file_contexts, system.new.dat and system.transfer.list to the upper folder (where rimg2sdat and sdat2img.py are).

00:37 - Open terminal at your workfolder.

00:41 - Convert the sparsed system image system.new.dat with "python sdat2img.py system.transfer.list system.new.dat system.img". The output will be a system.img.

00:59 - Create a system folder.

01:07 - Mount system.img at system folder with "mount -o loop system.img ./system".

01:22 - Convert the mounted system.img at ./system to a new image file with custom partition size. In this example I'll convert the stock 2.00 GiB to fit in a custom 1.00 GiB system partition. The command line is "make_ext4fs -T -1 -S file_contexts -l 1073741824 -L system -a system system_new.img ./system/". The output will be system_new.img.

02:04 - Convert the system_new.img to a compatible flashable sparsed image with "./rimg2sdat system_new.img". The output will be a new system.new.dat, overwriting the previous one.

02:33 - Copy file_contexts, system.new.dat and system.transfer.list back to the flashable zip rom folder you extracted at 00:06.

02:42 - Navigate to META-INF\com\google\android and open updater-script with a text editor.

02:55 - Comment out lines 22 to 31 to remove SHA-1 verification (by making any changes to the original image, original checksums becomes invalid). Save the changes.

03:12 - Go back to the rom folder, select all files and compress in zip format.

You are ready to flash as long as you resized system partition in your phone to 1 GiB (1073741824 bytes) in a perfect 1:1 fit.

Note 1: Flashing a bigger image in a smaller partition will always fail. Flashing a smaller image in a bigger partition will make the overhead in the partition not usable and waste space.

Note 2: You can't use CM updater to update your system since you are using a new partition layout and official CM uses stock partition layout. Make sure to disable CM updater or even consider deleting it after mounting the system.img image at 01:07 (other stuff can be deleted to free space as long as you know exactly what you are doing).

How to calculate the new partition layout and edit repartition script in Bigmajster Repartition Tool

BigMajster made this very nice Repartition Tool altough there are some glitches (explained later). His tool can be edited to make any partition layout you want.

When opening his tool in recovery, you face two choices, one for Internationals variants LG L90 and other for T-Mobile LG L90, each one with three kinds of repartitioning layouts. This tutorial is only for the Internationals variants LG L90! DO NOT TRY IN T-Mobile LG L90 because it has a different partition layout. Unless someone provide me a log of a full parted print of T-Mobile LG L90 partitions in 512 bytes sector, I repeat, do not use it in this variant or you'll end with a hard brick.

Extract his tool in a folder and open tmp folder. You'll see six repartition scripts, they reference can be found at \META-INF\com\google\android\aroma-config.

D405/D405n/D410/D410hn - Internationals variants LG L90

Maximal - System: 1.32GB Cache: 64MB Data: 5,43GB ---> repartition1.sh

Optimal - System: 928MB Cache: 64MB Data: 5,98GB ---> repartition2.sh

Stock - System: 2GB Cache: 900MB Data: 3,94GB ---> repartition3.sh

D415 - T-Mobile LG L90

Maximal - System: 730MB Cache: 190MB Data: 6,1GB ---> repartition4.sh

Optimal - System: 1,5GB Cache: 190MB Data: 5,3GB ---> repartition5.sh

Stock - System: 2GB Cache: 890MB Data: 4,0GB ---> repartition6.sh

We are going to play only with the first three scripts.

In this example I'll resize system partition to 1.00 GiB (or 1024.00 MiB) since I resized CM13 system image to 1 GiB too, which is enough to fit CM13 + Gapps Pico and still have room to flash Quickremote mod, SuperSU, Adaway to maintain hosts file, etc.

Using the Excel spreadsheet. Download here.

32 - System.

Select 1024.00 MiB size.

33 - Cache.

You can select whatever you want. From personal experience, I reduced cache partition from the stock 900 MiB to 32 MiB without facing any errors, you can make it even smaller but I don't know if this can cause problems. I'll just move the slider to 32.00 MiB.

34 - Userdata

This is automatically calculated, it's here just for the user to have a preview on how much room we are going to have after repartitioning. In this example you'll end with a 5.78 GiB userdata.

35 - Grow

I'll explain this later. For now we'll leave it enabled.

If you made everything right, the new partition table will look like this in sectors of 512 bytes:

New Partition Table
No. Start End Size FS Label
32 933888 3031039 2097152 ext4 system
33 3031040 3096575 65536 ext4 cache
34 3096576 15223807 12127232 ext4 userdata
35 15237120 15269854 32735 grow

Below this table, you'll see this text:

make_ext4fs value in bytes to be used in system sparsed image resize: 1073741824

1073741824 bytes is 1.00 GiB - the selected system partition size. This is the value to be used in make_ext4fs in the tutorial above at 1:22.

The Stock Partition Alignment table is just for reference. This is the stock layout of LG.

On the right side you have a Script table. Now you have to edit the repartition1, 2 or 3 scripts at tmp folder. Let's say I want to edit the second choice (Optimal - System: 928MB Cache: 64MB Data: 5,98GB), I'll have to edit repartition2.sh. Open it in a text editor and change lines 8 to 10 and 14 to 16 from:

parted -s /dev/block/mmcblk0 mkpart primary ext4 478 2142
parted -s /dev/block/mmcblk0 mkpart primary ext4 2142 2247
parted -s /dev/block/mmcblk0 mkpart primary ext4 2247 7795

To the script generated by the spreadsheet. It will look like this:

#!/sbin/sh
make_ext4fs /dev/block/mmcblk0p32
make_ext4fs /dev/block/mmcblk0p33
make_ext4fs /dev/block/mmcblk0p34
parted -s /dev/block/mmcblk0 rm 32
parted -s /dev/block/mmcblk0 rm 33
parted -s /dev/block/mmcblk0 rm 34
parted -s /dev/block/mmcblk0 unit s mkpart primary ext4 933888 3031039
parted -s /dev/block/mmcblk0 unit s mkpart primary ext4 3031040 3096575
parted -s /dev/block/mmcblk0 unit s mkpart primary ext4 3096576 15223807
parted -s /dev/block/mmcblk0 rm 32
parted -s /dev/block/mmcblk0 rm 33
parted -s /dev/block/mmcblk0 rm 34
parted -s /dev/block/mmcblk0 unit s mkpart primary ext4 933888 3031039
parted -s /dev/block/mmcblk0 unit s mkpart primary ext4 3031040 3096575
parted -s /dev/block/mmcblk0 unit s mkpart primary ext4 3096576 15223807
parted -s /dev/block/mmcblk0 name 32 system
parted -s /dev/block/mmcblk0 name 33 cache
parted -s /dev/block/mmcblk0 name 34 userdata
dd if=/sd/ptt.img of=/dev/block/mmcblk0p17
echo 'device=0' >> /cache/recovery/device.prop

Now you may want to edit aroma-config to relabel the choices. Open \META-INF\com\google\android\aroma-config and edit line 40 to properly identify the changes you made. It will look like this:

..."System: 1GiB Cache: 32 MiB Data: 5,78 GiB"...

The same applies to the other three choices. I recomend you to leave the stock layout untouched if you ever need to go back to the original layout.

Now just zip everything and use in TWRP.

Note 1: Sometimes the tool fails and leaves system, cache and userdata partitions unmountable. Don't worry, just run the tool again.

Note 2: Sometimes after the tool runs successfully, it will boot back into CWM. If you are using TWRP, have a flashable recovery zip ready to be flashed from CWM. Download it here.

Screenshots:

I use a *very custom* CM13 based ROM, that's why it shows 5,74 GB userdata (note that GB and GiB are different).