Shell utterly borked, toolbox claims "no such tool" HTC Magic, rooted with CyanogenMod 5. Tried to install busybox using "Busybox Installer" from the Market, ended up with a strangely borked system. Android does not boot, freezes on the splash screen. ADB shell, however, works. On the other hand, almost none of the commands work.

The busybox file is in /system/xbin, it seems. However, whenever I call it, I get "Permission denied". Even after sudo.

Running common commands like ls, cp, ln gives the same error message: "permission denied". Seems like those are symlinks to busybox, which is borked, see above.

/system/bin/toolbox is there, but it refuses to do most useful commands with a uniform message "No such tool". Ls, cp, mount, chmod, chown - "No such tool". Experimentally I found that set, ps, kill, reboot work. Is there a list of toolbox commands out there?

The only message of relevance in logcat is "02-02 01:36:38.280: E/logwrapper(61): executing /system/xbin/busybox failed: Permission denied". I kinda knew that.

I can write to the SD card. Is there a way to reflash the busybox while making it executable?

Is there an executable file anywhere on /data, so that I could push a copy of busybox there?

I can reboot into recovery mode, which is Android's own recovery mode.

Any ideas how to bring the system back to usable state? The phone is a scratch phone, so data loss is not an issue - there's no good data there.

It seems like making busybox executable somehow would bring everything back. I'm utterly lost, however, how to do that. And I'm rather surprised toolbox won't support chmod.

EDIT: funny data point. When I boot into recovery, I still can do ADB shell. And I get a completely different environment - there's command line with ls, busybox (!) and stuff. /system is almost empty. From that environment, can I somehow go back to the regular /system? The mount command is available.
Yay, the phone boots again.

Here's the magic recipe.

Boot into recovery.
adb shell
mkdir /data/s
mount -o rw -t yaffs2 /dev/block/mtdblock3 /data/s
chmod 755 /data/s/xbin/busybox
Reboot the phone.


My shell is back. There's a weird quirk now - ls (from the busybox, one assumes) thinks ADB is an ANSI terminal and tries to emit ANSI escape sequences. Still, yay.