How to install LineageOS in TWRP using `adb push`?


Question

Question (TL;DR)


How can one (manually) sideload a LineageOS zip file that is pushed on the phone using TWRP?


Context


while installing this lineage-17.1-20210430-nightly-FP2-signed.zip, with the following command:


adb sideload lineage-17.1-20210430-nightly-FP2-signed.zip

I observed that the lineageOS hangs in the loading screen for several hours. So first I verified that the zip file is correctly downloaded, using the sha256, which it is. Next, I noticed that the cause might be that the zip is streamed directly from the host to phone. So I learned an alternative option might be to use:


adb push lineage-17.1-20210430-nightly-FP2-signed.zip /sdcard/

Followed by a command to sideload the zip from the phone.


adb sideload method


For completeness, the direct adb sideload lineage-17.1-20210430-nightly-FP2-signed.zip was performed using the following steps:First, I wiped the system using Wipe>Advanced Wipe> select: Dalvik, System, Cache, Data, and swiping right, then manually activated sideload mode by pressing (and swiping): Advanced>ADB Sideload>Swipe to Start Sideload which outputted:



Updating partition details...
... done
RescueParty
Full SELinux support is present
MTP Enabled
? Starting ADB sideload feature...



An observation is made here that the loading indicator keeps on loading without any progress. This might also be a reason the sideload does not yield a successful boot up of LineageOS.


Next, I tried I first tried the CLI approach:


adb sideload /sdcard/lineage-17.1-20210430-nightly-FP2-signed.zip

Which outputs:



Installing zip file /sideload/package.zip
Unmounting System
Warning: no file_contexts
Target: Fairphone/FP2/FP2:6.0.1/FP2-gms-18.04.01/FP2-gms-18.04.01:user/release-keys
Patching system image unconditionally
Script succeeded: result was [1.000000]
Formatting Cache using make_ext4fs...
Wiping Cache & Dalvik...
Cleaned: /data/dalvik-cache...
-- Dalvik Cache Directories Wipe Complete!



And I pressed Reboot System. This results in the (seemingly) endless booting of the LineageOS loading screen.


adb push method


Before I tried other builds for the FP2, I was mainly curious to learn how the sideloading would work using adb push. Hence, I tried:


adb push lineage-17.1-20210430-nightly-FP2-signed.zip /sdcard/

And started looking for ways to sideload that zip from the phone. The first thing I tried was, after starting the sideload mode manually and verifying that the TWRP was in sideload mode with command adb devices:


adb sideload /sdcard/lineage-17.1-20210430-nightly-FP2-signed.zip

Which returns:



adb: failed to stat file /sdcard/lineage-17.1-20210430-nightly-FP2-signed.zip: No such file or directory



Next, I tried exploring the TWRP options manually. One of the options could possibly be: Install>browse to /sdcard> and tap the: lineage-17.1-20210430-nightly-FP2-signed.zip. However that yields a warning:


This operation may install incompatible software and render your device unusable

And I think installing might be something else than sideloading, hence I think this might brick the device/not be what I am looking for.


Note


This is not about the xy-problem of making LineageOS boot on the Fairphone, it is about how to load LineageOS using TWRP from the phone instead of from the host.


Answer

To answer the headline only:


only block partition images can be flashed with adb push



  • extract zip file



  • convert sparse file into partition image


    brotli --decompress --in system.new.dat.br --out system.new.dat
    python sdat2img.py system.transfer.list system.new.dat system.img


  • flash partition images from adb in TWRP recovery


    adb push boot.img /dev/block/platform/msm_sdcc.1/by-name/boot
    adb push system.img /dev/block/platform/msm_sdcc.1/by-name/system





Don't forget to factory reset / format the whole user data



  • can be done from adb shell


    adb shell
    mke2fs -t ext4 /dev/block/platform/msm_sdcc.1/by-name/cache
    mke2fs -t ext4 /dev/block/platform/msm_sdcc.1/by-name/userdata





For more alternative methods to manually install OTA flashable zip

Is it possible to flash a custom ROM without a custom recovery image


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