0

TLDR:
When booted into TWRP (not the Android OS), is there a difference between running a command on an ADB shell and running it in TWRP's terminal? Specifically something that messes with partitions? Is it safe? Are different results to be expected?

Background:
I'm having a problem with my OnePlus One. It seemingly randomly reboots or turns off instantly. Sometimes refusing to start again unless the power button is pressed for about 30 seconds or the battery connector is disconnected and connected again. According to this article, the issue might be a corrupted partition. It suggests running:

`make_ext4fs /dev/block/mmcblk0p15

over ADB. Unfortunately it is impossible for me to get ADB to recognize my device properly. I did everything that this article suggested, but it didn't help. I tried to scan for ADB devices while in booted into TWRP (no devices showed up) and I tried to scan for devices while booted into Android, but as soon as I enable USB debugging the phone constantly disconnects like multiple times per second. I tried using a powered USB extension as suggested here, but it didn't help. I also measured the current draw and it constantly switched between ~230mA and ~270mA (the PSU would have allowed up to 5100mA). Also, I refuse to do ADB over WiFi for security reasons. It would also most likely be a pain to get the firewalls to allow it.

I also wonder if there is a way to find out if any of the other partitions are corrupted (there are like 50 devices listed under /dev/block/).

1

I wouldn't tamper with partitions currently in use – which would be the case when the system is booted up. While booted into recovery, they are not in use unless you explicitly mount them (or if they'e auto-mounted, you can unmount them and still have a system running).

So things like repartitioning or formatting are better done from recovery. Same applies to imaging (dd) where you want to be sure the contents don't change while you create that "disk image", as you want it to be consistent (not an issue with partitions mounted read-only of course).

And again this applies if you want to repair the file system: the corresponding partition must be unmounted for that, which cannot be done e.g. for the /data partition while booted up normally – fsck (File System ChecK) requires exclusive access to it.


As for your underlying problem: I'd recommend to boot into recovery and run a file system check first to see if any partition is corrupted. In most cases, fsck is also able to repair the corruption, and you'll keep your data that way. If fsck finds issues it cannot solve (or you want to be "absolutely sure and clean"), you still can run that make_ext4fs – which of course would mean "all data lost". If you do that on /system it also means you need to flash a ROM afterwards, as your OS would be gone. And if you do it to any partition other than /system, /data or /cache (or the SD card), you might brick your device as you wouldn't know what to put there to bring it to live again. Oh, and also make sure the partition you want to "format" is really using ext4 before running make_ext4fs against it. While it should be transparent, an unexpected file system might confuse the OS :)

  • @iBug I didn't say it is, please read again: "make sure the partition you want to "format" is really using ext4 before running make_ext4fs against it." As the SD card is unlikely to use it, according to my answer you shouldn't format it that way (there are other mkfs commands there for FAT: mkfs.vfat and mkfs.exfat). – Izzy Nov 25 '17 at 13:45
0

Nope. When booted into TWRP all commands are executed with root privileges, shell commands are mostly the same but TWRP added a twrp command documented here, which I think is most convenient and hard to get things wrong.

I have no idea about frequent reboot but I suggest you check the power connector.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.