As always, do this at your OWN risk. I am not responsible for bricking your Nexus 4. I will simply list the process which I used to increase my Nexus 4's system partition (by taking a big ol' chunk from the cache partition). Remember, any sort of modification to your device of this caliber WILL void any warranty you might still have.
parted (Uploaded to my Google Drive. If it downloads as a .txt, rename it to remove the extension and make it a plain file)
adb and fastboot, and preferably knowledge on how they work
Step 1: Install TWRP onto your Nexus 4 and reboot into it.
Step 2: Open up command prompt / terminal and check to see if your Nexus 4 is connected properly with "adb devices".
Step 3: Once you've confirmed that adb is fully working and your Nexus 4 is properly connected to your PC, download parted and use adb to push it to your Nexus 4 using the command:
adb push parted /
chmod +x parted
Now run the command
./parted /dev/block/mmcblk0 p
This is the partition layout on my device. It will probably be the same on your device, though the size of userdata may vary depending on whether you have the 8gb or 16gb Nexus 4.
~ # ./parted /dev/block/mmcblk0 p Model: MMC 016G92 (sd/mmc) Disk /dev/block/mmcblk0: 15.8GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 524kB 67.6MB 67.1MB fat16 modem 2 67.6MB 68.2MB 524kB sbl1 3 68.2MB 68.7MB 524kB sbl2 4 68.7MB 70.8MB 2097kB sbl3 5 70.8MB 71.3MB 524kB tz 6 71.3MB 94.4MB 23.1MB boot 7 94.4MB 117MB 23.1MB recovery 8 117MB 118MB 799kB m9kefs1 9 118MB 119MB 799kB m9kefs2 10 119MB 120MB 799kB m9kefs3 11 120MB 121MB 524kB rpm 12 121MB 121MB 524kB aboot 13 121MB 122MB 524kB sbl2b 14 122MB 124MB 2097kB sbl3b 15 124MB 124MB 524kB abootb 16 124MB 125MB 524kB rpmb 17 125MB 125MB 524kB tzb 18 125MB 126MB 524kB metadata 19 126MB 143MB 16.8MB misc 20 143MB 159MB 16.8MB ext4 persist 21 159MB 1040MB 881MB ext2 system 22 1040MB 1627MB 587MB ext4 cache 23 1627MB 15.8GB 14.1GB ext4 userdata 24 15.8GB 15.8GB 524kB DDR 25 15.8GB 15.8GB 507kB grow
Now run the following three commands:
umount /data umount /sdcard umount /cache
You'll want to run these two next commands. These commands will essentially "remove" the two partitions.
./parted /dev/block/mmcblk0 rm 21 ./parted /dev/block/mmcblk0 rm 22
./parted /dev/block/mmcblk0 mkpart primary 159 1590 ./parted /dev/block/mmcblk0 mkpart primary 1590 1627
./parted /dev/block/mmcblk0 p
./parted /dev/block/mmcblk0 name 21 system ./parted /dev/block/mmcblk0 name 22 cache
mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p21 mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p22
Step 12: Now we are pretty much done. We've extended the system partition from approx. 881mb to 1431mb, which is a nice large chunk of memory. In the future, we could always mess with the partitions more to add even more space by stealing from userdata, but until we reach that point, I think we are pretty well set for now!
You'll want to reboot TWRP, and flash a new ROM. You can now use a much bigger Google Apps package, without any worries.
Do note, however, that flashing a ROM will "resize" system to be smaller, but this isn't a huge deal. After flashing a ROM, while still in TWRP, you'll want to go to Wipe > Advanced Wipe > check "system" then head to "Repair or Change File System", > then tap on "Resize File System." If you encounter any errors while trying to resize, try remounting system or rebooting TWRP. Afterwards, you should be able to flash your Google Apps package. I'm not sure if you need to repeat these steps after flashing things other than ROMs, but repeating this process within TWRP should work just as well.
I hope I helped y'all out and feel free to post if this guide worked for you or if you have any other comments!
@surfrock66 for his Nexus 5 guide here.
@rkhat for his Nexus 7 2013 guide here.