6

I am trying to install busybox on an android emulator.

I downloaded and compiled busybox and have the busybox binary on my pc.

i then did adb push busybox /data/local/tmp

then did adb shell, then #cd /data/local/tmp , then #chmod 777 busybox, then tried #./busybox --install it says busybox command not found.

I also copied the file to /system/busybox. but ./busybox --install says busybox command not found.

Santhosh
  • 9,965
  • 20
  • 103
  • 243

4 Answers4

6

First do adb push busybox /data/local/busybox to copy the busybox into the android phone system then go to the android shell by doing adb shell. Get the superuser by typing su from you android phone grant superuser request then back to the shell and type

cd /data/local
chmod 755 busybox
./busybox
mount -o remount,rw -t yaffs2 /dev/block/mtdblock4 /system
mkdir /system/xbin
cp /data/local/busybox /system/xbin
cd /system/xbin
busybox --install .
mount -o ro,remount -t yaffs2 /dev/block/mtdblock4 /system
sync
reboot

Note: /dev/block/mtdblock4 may not be the /system partition on every device or emulator. It's best to execute the 'mount' command without parameters first in the shell, and look which device or partition is mounted as /system.

gregko
  • 5,642
  • 9
  • 49
  • 76
hayder Jawad
  • 71
  • 1
  • 4
  • Can you explain this better? – Russia Must Remove Putin Oct 15 '14 at 03:18
  • The answer by @hayder Jaward helped me, but the /system was not mounted at /dev/block/mtdblock4 in my emulator. In the system shell, type 'mount' and press enter, look at the listing until you find /system in the 2nd column. The first column will have the device, in my case it was /dev/block/sda2. Reboot was not necessary. – gregko Jan 08 '16 at 22:17
  • @Aaron Hall - I don't understand your edit "in case of cp command not working try using cat"... The 'cp' command is for copying files, any Unix/Linux derived system (including Android) has it. Similarly, 'cat' is the command for just listing the content of text files in the shell window, so how would cat replace cp? – gregko Jan 08 '16 at 22:20
  • ALSO: an easier way to remount the /system partition as read-write is just using 'adb remount' command, not in the Android shell, but on your host computer of course. – gregko Jan 08 '16 at 22:28
  • 1
    @AaronHall - sorry about that, indeed I should have read the edit history first. Don't know why I had an impression this addition came from you, apologies again. Guess I'll edit the post and delete this sentence, as it's just wrong and confusing. – gregko Jan 10 '16 at 13:01
5

On a rooted phone, install this apk: https://f-droid.org/en/packages/ru.meefik.busybox/

f-droid is a good option as it is open source and officially allows downloading APKs, unlike the play store, which may not be available on test devices.

That app also has a simple install GUI, but the most reliable way to install it is to do simply:

adb shell
cp /data/data/ru.meefik.busybox/files/bin/busybox /system/xbin/
busybox ls
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
1

There are a couple of small changes to gregko and hayder Jawad's answer to get this working on the Pixel 2 emulator.

You have to start the emulator using the -writable-system flag as per this answer, otherwise you won't be able to remount the /system directory with the rw flag.

On the Pixel 2 emulator, /system is mounted at /dev/block/vda and /system/xbin already exists.

Thus, assuming you've pushed the binary to /data/local/busybox as per the first half of the answer, the shell commands to install busybox into the Pixel 2 emulator are

su
cd /data/local
chmod 755 busybox
./busybox
mount -o rw,remount -t ext4 /dev/block/vda /system
cp /data/local/busybox /system/xbin
cd /system/xbin
busybox --install .
mount -o ro,remount -t ext4 /dev/block/vda /system
sync
reboot

The busybox download page might be a bit unclear for beginners (like me). For 32-bit x86 processors, you'll want to use the i686 binary file.

John Haire
  • 121
  • 2
0

I did the following very simple steps:

  1. Download busybox apk to my laptop from here
  2. Install apk using: adb install <apk file path>
  3. Run busybox shell: busybox ash

Once in shell you can use busybox commands.

Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54