How to run e2fsck on Android, can't get "adb shell" with unmounted partitions? 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?
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:

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

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.