How to repartition Google Nexus 4 (aka. LG E960)?


Question

Over a month ago, LineageOS rolled out Oreo (I think) update for the Nexus 4 (mako), but there's a catch - the system now takes up so much space, that even the nano version of open-gapps package can no longer be installed without manually removing application in-between the installations. I thought, rather than shooting down apps from default LineageOS, I would rather bump the system partition's size by another 200 MiB.



I haven't attempted anything yet, as information how to achieve this on a snapdragon device seems to be very sparse - is it even possible? I've done repartitioning on a Mediatek device, where doing so involved hand-editing an MBR-like partition table and uploading it to the device using SP-flashtool. Is there a similar, or perhaps an easier-to-use tool for Snapdragon devices?



P.S. - I've read the answers/suggestions to question 65781, and none of them are helpful to my question.


Answer

As mentioned above, the Nexus 4 uses plain GPT on its storage to split it up into partitions. Any tool able to modify GPT should work. By far the biggest problem for me was getting an appropriate tool - the fdisk bundled with TWRP can only list partitions on a GPT disk, without making any changes. I prefer not to use parted (available from Termux), due to its inability to display/modify partition GUIDs (may have changed since the last time I checked).



Looking back, it may be possible to dump the entire storage to a computer, make changes there, and put the whole thing back, but I specifically wanted to avoid writing over critical partitions (loaders, kernel, etc.), so I set out to get gdisk for android.



I eventually found this thread, where the author prepared an archive with gdisk and a few other tools.



Requirements:





Overview



The relevant partitions (system and userdata) are 21st and 23rd on the storage. The 22nd partition is just cache, so there's no harm nuking it, and making a new one after data from the other 2 are in place.



The TL;DR version of the procedure is:




  • pull the data partition to computer



    [PC] adb pull /dev/block/mmcblk0p23 userdata.img

  • put gdisk on the phone, and use it to modify the partition table - grow system while retaining its starting sector, shrink userdata by the same amount, and re-create cache between them



    [PC] adb push gdisk /tmp/
    [adb-shell] /tmp/gdisk /dev/block/mmcblk0
    ...

  • use resize2fs on the phone with the system partition to grow it


  • use resize2fson the computer with the userdata partition's image to shrink it to appropriate size

  • push the modified data image to the phone



    [PC] adb push userdata.img /dev/block/mmcblk0p23

  • format the cache partition, reboot into system



Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes