Rooting ICS emulator; pushing su fails with "Out of memory" - android

I'm trying to root my ICS AVD, and have tried this:
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system
adb push su /system/xbin/su
adb shell chmod 06755 /system
adb shell chmod 06755 /system/xbin/su
It fails with the following error:
failed to copy 'su' to '/system/xbin/su': Out of memory
How can I fix this?

This blog explains the problem:
To avoid the "Out of memory" error when trying to copy the su-executable to /system/bin, you need to start the emulator manually with a large –partion-size argument:
$ emulator -avd MYNAME -partition-size 300
Then:
$ adb remount
$ adb push su /system/bin/su
$ adb shell chmod 06755 /system/bin/su
Note that MYNAME above is the name of the emulator. Also note that if you are using snapshots, you will need to start the emulator without it due to the change in hardware configuration. Append -no-snapshot-load to do so.

With this you'll have 512MB of size on /system
ICS is the name I gave to my android emulator:
android-sdk-linux/tools$ emulator -avd ICS -partition-size 512

Related

How Do I Make System Writeable in Android Studio Emulator?

I want to be able to write to /system in my Android Studio Emulator. I've made sure to use a rootable, non-Google Play Services AVD. I'm currently using the Pixel 2 - API 28 AVD (targets Android 9.0).
I've made sure to run adb root and that works, though adb remount gives remount of the / superblock failed: Permission denied as an error. (I also tried running adb disable-verity and rebooting before remounting, but I still get the same remount error.)
I've tried adb shell mount -o rw,remount /system, but I get mount: '/system' not in /proc/mounts.
I've also tried
adb shell
su
mount -o rw,remount /system
but get the same mount: '/system' not in /proc/mounts error
(I've tried it without /system too. It appears to work, but if I then try to write to /system, I get mv: /system: Read-only file system)
I've tried emulator -avd -writeable-system but I get 'emulator' is not recognized as an internal or external command, operable program or batch file.
Can someone please help me figure out how to run the emulator in such a way that I can write to /system?
On Windows open a command prompt/power shell in C:\Users\YourUser\AppData\Local\Android\Sdk\tools and execute
.\emulator.exe -writable-system -avd Pixel_2_API_28
In another command prompt/power shell in C:\Users\YourUser\AppData\Local\Android\Sdk\platform-tools execute
.\adb.exe remount
On Linux you can use the the following commands:
$ANDROID_HOME/tools/emulator -writable-system -avd Pixel_2_API_28
adb remount

Edit marshmallow hosts file

I'm trying to edit the hosts file on the Marshmallow emulator, but I can't do it. I use ADB tool:
I start emulator using emulator.exe
adb mount
adb pull /system/etc/hosts c:\temp
Then I edit hosts file
ADB push c:\temp\hosts /system/etc (this step doesn't work, because I get error - "read-only file system").
Also, I tried to do adb shell and then SU commands and then mount -o rw,remount /system. But every time when I try to edit hosts file, I get the error that file system is read only.
Any ideas?
Try this for the remount:
adb shell
setenforce 0
mount -o rw,remount /system
setenforce 1
These steps work for me (Windows 8.1 and Android Studio emulator (qemu))
Open a Command Prompt
cd %localappdata%\Android\sdk\tools
Run the emulator from the command line with -writable-system flag, e.g.
emulator -avd (your AVD name) -writable-system
While the emulator is booting (wait until the Android splash appears):
cd %localappdata%\Android\sdk\platform-tools
adb root (do not proceed until this command has been successful)
adb remount
adb push c:\temp\hosts /system/etc/hosts

Android Run script in ADB shell

I am trying to fallow this tutorial in order to install SSL certificate on Android emulator.
I need to start the emulator from command line, so I run
emulator -avd myDevice -http-proxy myIp:8888
After device is started I want to copy my certificate file from PC to the device, so I run those commands
mount -o remount,rw /system
cp /sdcard/5ed36f99.0 /system/etc/security/cacerts/
cd /system/etc/security/cacerts/
chmod 644 5ed36f99.0
I bundle them all together using this suggestion
The final command looks like this:
adb shell su -c 'mount -o remount,rw /system; cp /sdcard/5ed36f99.0 /system/etc/security/cacerts/; cd /system/etc/security/cacerts/; chmod 644 5ed36f99.0'
But I am getting an error:
su: invalid uid/gid '-c'
If I do it from the shell it works, but then when I restart the emulator it restore the system to previous state without saving my changes.
How can I solve those two problems?

Cannot change android system directory to rw

I am trying to remount the /system as a rw file system so I can push some files into /system/framework. It is an android emulator running Android 6.0 x86 image.
$ mount
...
/dev/block/vda /system ext4 ro,seclabel,relatime,data=ordered 0 0
...
Then I do
su
mount -o rw,remount /system
mount
...
/dev/block/vda /system ext4 rw,seclabel,relatime,data=ordered 0 0
...
At this time I am thinking I am ok. Then I am doing on host:
adb push test.jar /system/framework/
However I see:
failed to copy 'test.jar' to '/system/framework/test.jar': Read-only file system
Then I go back to adb:
mount
...
/dev/block/vda /system ext4 ro,seclabel,relatime,data=ordered 0 0
...
It goes back to ro again.
When I trying to do remount again, it doesn't even let me do it this time:
mount: Read-only file system
255|root#generic_x86:/ #
So where I am doing wrong? Thanks!
___ Edit____
restarting adbd as root via adb root command solves my issue.
based on #raed-hosny answer I solve the problem with
$ emulator -writable-system -netdelay none -netspeed full -avd Nexus_5X_API_25
In your log you will have something like this
sh: 1: glxinfo: not found
emulator: WARNING: System image is writable
sh: 1: glxinfo: not found
emulator: Listening for console connections on port: 5554
emulator: Serial number of this emulator (for ADB): emulator-5554
try to start emulator from terminal using -writable-system so you can mount /system as writable in the old way
The other answer was close for me, but was missing some steps. You have to first start the server if it's not already running:
adb start-server
emulator -writable-system -avd Pixel_2_API_24
Then you can mount as writable:
adb root
adb remount
https://docs.mitmproxy.org/stable/howto-install-system-trusted-ca-android

Android emulator error: 'Not enough memory in emulator'

I'm trying to install rsyncdroid app in my emulator using the following steps:
$ ./adb push rsync /sdcard/rsync
$ ./adb shell mount -o remount,rw /system
$ ./adb shell "cat /sdcard/rsync > /system/bin/rsync"
$ ./adb shell chmod 755 /system/bin/rsync
$ ./adb shell mount -o remount,ro /system
I'm getting stuck on step 2, which results in the error:
cannot create /system/bin/rsync : not enough memory in emulator
The System partition of the standard avd's have not much free space. You can start the emulator on the command line, adding the following parameter:
-partition-size <size>
alternatively you can also declare the partition size in the command line options of your android run/debug configuration in eclipse.
Have you created new AVD ?? Use SDKManager to create new AVD. and assign 1000 MB to SDCard

Categories

Resources