Android: how to increase system partition and decrease data partition?


Question

A very bad situation
I want to install the Lineage 16 OS on Nexus 5
Without apps it install Ok
With google apps(I select pico package arm, wich is under 100 MB) not and give error system partition space not sufficient.
This is the actual situation



Filesystem

  1K-blocks

Used Available Use% Mounted on
tmpfs 949772 28 949744 0% /dev
tmpfs 949772 44 949728 0% /tmp
/dev/block/mmcblk0p28
28061148 643132 27418016 2% /data
/dev/block/mmcblk0p28
28061148 643132 27418016 2% /sdcard
/dev/block/mmcblk0p27
706392 13084 693308 2% /cache
/dev/block/mmcblk0p25
1045804 899652 146152 86% /system


I have tried a parted binary for resize but said ext4 is not supported!
And with fdisk allow me to delete only the gpt partition(!) number 1
How to resize the partition n25 /dev/block/mmcblk0p25?
My idea is to decrease sdcard of 2GB and increase system with 2GB
is possible?


Answer

I have followed this method: shrink data and recreate system partition; which is not too "kind" but works.


Warning: this method is ok for a fresh installation from scratch. You will lose all data, so follow it only if you're sure of what you're doing. I'm not responsible for data lost, bricked devices, etc. You have been warned.


You must have TWRP installed, a USB connected smartphone and ADB, fastboot on PC:



  1. Get parted and gdisk from here



  2. Reboot in recovery mode


    adb reboot recovery


  3. Push gdisk and parted


    adb push parted /
    adb push gdisk /


  4. With parted, resize the data partition. In my case, it is 28 and we resize from 30G to 27G


    adb shell
    umount /data
    parted /dev/block/mmc0blk0
    resizepart 28 27G


  5. Now exit from parted and open gdisk


    umount /system
    gdisk /dev/block/mmc0blk0
    d #delete, select the system partition, in my case is 25
    n #new,I select the new size of 3G for my system partition and 0700 as fsid
    w #write


  6. Now, reopen with parted and rename the partition 25 as system



  7. Reboot in recovery mode from TWRP or ADB


    adb reboot recovery


  8. The command


    fdisk -l /dev/block/mmc0blk0

    must report correct sizes



  9. Now, create the ext4fs


    make_ext4fs /dev/block/mmc0blk0p25


  10. Resize the fs


    umount /system||echo ok
    e2fsck -f /dev/block/mmcblk0p25
    resize2fs /dev/block/mmcblk0p25


  11. Eventually, correct the /etc/fstab. The command mount /system must complete successfully. With TWRP, try to wipe the partitions data, system, etc. The command must complete successfully.



  12. Install Android ROM or recover from a backup.






I see my Lineage OS image resize automatically the partition to 1G (sic!)
so I'm trying this workaround:



  1. Install Lineage OS

  2. Reboot and wait for Android OS

  3. Reboot in TWRP

  4. Resize the partition

  5. Install the other zips


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