After flashing TWRP, device no longer boots


Question

I just got a device running Android 7.1.1 (an BQ Aquaris X5 Plus to be precise). Fine device, and all – unlocking the bootloader was as easy as enabling bootloader unlock in settings, and running fastboot oem unlock. As I like complete backups and other features custom recoveries provide, I flashed . Woked fine, could boot into it – but then, the device no longer boots up into Android itself – it simply gets stuck on the boot screen.



Things I've tried:




  • wiping /cache and /data (via TWRP's advanced wipe)

  • performing a factory reset via TWRP



No dice. What could that be, and how to solve the issue?


Answer

Searching the web gave me a clue: While before Android 7 one could easily flash a custom recovery without fearing side-effects, starting with Android 7 the system enforces DM Verity. That is, at a very early stage in the boot process, the system checks whether any partition was "tampered" with – which in my case meant the /recovery partition. As far as I could figure, in such a case a warning should be shown to the user and asked whether to continue anyway. In my case, there was no such thing.



So what to do to fix it? Actually, it is the boot image requiring a fix – namely, the verify option must be removed from the entries of affected partitions. The following options exist for this:




  • adb disable-verity is mentioned, but it isn't a good solution because it cannot be issued in TWRP and it requires the ROM to be a userdebug build or an engineering build (it doesn't work on user builds).

  • Manually disabling dm-verity in the boot.img describes how to modify the boot image (i.e. change the fstab file removing the verify option). That requires extracting the boot image, modifying it, repacking it, flashing it back. Can be done using SuperR's Kitchen – which is available for Linux, Mac and Windows. Should definitely work, but is quite a bit of work itself.

  • LazyFlasher offers a flashable ZIP (no-verity-opt-encrypt-6.0.zip) which should do the trick. Should be fine for those who want avoid to root their device for one reason or the other. It will disable forced encryption along.

  • Flashing SuperSU did the trick for me: SuperSU detected that DM-Verity was active, extracted the boot image, patched it accordingly, and flashed back the patched version – which then also includes SuperSU itself.



So after flashing SuperSU, the device booted up normally again – issue solved for me. You might chose one of the other approaches (feedback welcome then).



Note that these two (SuperSU and LazyFlasher) are just examples. As iBug correctly points out, "SuperSU is dead" – so you'd better use Magisk, which in this context does the same: flashing itself systemlessly and disabling DM-Verity.


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