How to run e2fsck on Android, can't get "adb shell" with unmounted partitions?


Question

I can access the Huawei P9 on Win10 with adb, and shell into it, but that is with the phone booted into OS. I want to run a filesystem scan (e2fsck), but need un-mounted partitions for that.


I read a thread where someone was running e2fsck from recovery on his phone using adb shell.


If I boot the phone into recovery using adb, I get Reboot / Factory reset / Wipe Cache on menu, but phone is inaccessible on PC (adb or fastboot). Booting phone into bootloader via adb or directly on phone, also inaccessible via adb or fastboot. Shell seems only to be accessible when Android is booted.


Any ideas?


Answer

Usually you don't need to run filesystem checks manually. Android runs this on every boot before mounting the filesystem (ref). So is the case with external storage (see this answer). However exceptions may exist:



"Some system images do not have e2fsck for licensing reasons (e.g. recent SDK system images). Detect these and skip the check."



So you can check if /system/bin/e2fsck (or /system/bin/fsck.f2fs, whatever applicable) exits on your device. Or check logcat after some repeated reboots to confirm if filesystem check was run (usually in vold or fs_mgr log).



If I boot the phone into recovery using adb, I get Reboot / Factory reset / Wipe Cache on menu, but phone is inaccessible on PC (through adb or fastboot).



You are booting into stock recovery provided by your OEM. But in order to run commands (including fsck) on adb shell or terminal emulator you need a custom recovery (like TWRP). Note that flashing custom recovery requires unlocking bootloader which is not supported on many devices (including all of the recent Huawei devices).

fastboot protocol is only available in bootloader mode (on supported devices), so not relevant here.


If you are sure that filesystem check is not being run on your device but it's required (due to filesystem errors), you can do a factory reset which recreates the /data filesystem.


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