Android busybox command to gain root and umount

Mick0311 picture Mick0311 · Dec 17, 2012 · Viewed 8.4k times · Source

So, I have a device in which I need to unmount a dir. I wanted to run something like:

Runtime.getRuntime().exec("system/bin/busybox/ umount /mydir/subdir");

The issue is that I need root to unmount. Can I gain root through busybox in a one line command with the umount command?

EDIT: Sorry, The device is already rooted. I can go shell through ADB: adb shell...umount /mydir/subdir

This is two commands to achieve. I need to be able to do this through one line, and was thinking that using busybox is the way to achieve it. I'm thinking something like:

Runtime.getRuntime().exec("system/bin/busybox/"gain shell as above here" umount /mydir/subdir");

Am I way off base here?

Answer

Juan Gomez picture Juan Gomez · Dec 17, 2012

No, you can't.

Rooting a locked device is not something that can be achieved by a simple Unix command. You need to find an exploit on your device's firmware to be able to obtain root privileges.

You can certainly find a way to root your device if you try to google it, but the procedure varies by device and by firmware version. When you find it, it would probably be a script and/or executable that takes advantage of an specific exploit on your device, and not just a generic command.