Why can't I push sqlite into Android using adb command? - android

I have a rooted Nexus S and it doesn't have Sqlite installed so I googled it and found I need to use
this command:
adb push sqlite3 /sdcard/
However it gave me this error:
failed to copy 'sqlite3' to '/sdcard//sqlite3': Read-only file system
So that means the /system is read only. Then I searched it and found that I need to remount my /system folder as rw. I used this command in the adb shell:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock5 /system
I still cannot push Sqlite3 and it produces the same error as before in the command line window.
I then typed
root#android:/ # mount
But all I can see is the /system is mounted differently:
/dev/block/platform/s3c-sdhci.0/by-name/system /system ext4 rw,relatime,barrier=
1,data=ordered 0 0
How can I mount my system folder as "rw" and push the sqlite3 into my Android phone?

Maybe you can try another location. The script I used to root my phone was placing its stuff on the /data/local/ after creating a tmp folder:
adb shell "cd /data/local && mkdir tmp"
adb push sqlite3 /data/local/tmp/.
adb shell "chmod 755 /data/local/tmp/sqlite3"
adb shell "cp /data/local/tmp/sqlite3 /system/bin/sqlite3"
adb shell "cd /data/local/tmp && rm *"

In fact, the two answers are mandatory. If we set only
adb shell "cd /data/local && mkdir tmp"
adb push sqlite3 /data/local/tmp/.
adb shell "chmod 755 /data/local/tmp/sqlite3"
adb shell "cp /data/local/tmp/sqlite3 /system/bin/sqlite3"
adb shell "cd /data/local/tmp && rm *"
We have the same error
Read-only file system
So, before copy the sqlite3 to /system/bin/sqlite3, we must add the following line :
mount -o rw,remount -t yaffs2 /dev/block/mtdblock5 /system

Related

Can't move file from /sdcard/ to /system/app/ with shell, even with su.

Note: I am running this on a rooted device.
From my application, if I try to move a file from /sdcard/ to /system/app/ it fails. The following shell script does not work:
su
mount -o remount,rw /system
mv /sdcard/file.apk /system/app/file.apk
Whereas the following will work:
su
mount -o remount,rw /system
mv /system/app/file.apk /system/app/file.apk.bak
Why doesn't it work when copying from /sdcard/? (or any other file location I've tried).
I can't see the output from the location I'm running this however if I try from ADB then it gives me an error that the source file was not found even though it definitely exists.
adb root
adb remount
adb push my-app.apk /sdcard/
adb shell
su
cd /sdcard
mv my-app.apk /system/priv-app
cd /system/priv-app
chmod 777 my-app.apk
This worked for me on a rooted device
adb root
adb remount
adb push [local-file.apk] /system/app/file.apk
adb reboot

Android Emulator Won't Let Me Mount And Copy A File To It

I am trying to follow the tutorial :
http://borkweb.com/story/setting-etchosts-on-an-android-emulator-using-a-mac
But when I type:
adb -s emulator-5554 remount
All I get is remount of /system failed: Read-only file system
So then I try this..
MAC-M-N20B:~ user$ adb shell
root#generic_x86:/ # su
root#generic_x86:/ # mount -o rw,remount,rw /system
And then I get this...
mount: Read-only file system
Any ideas how I can make the system folder writeable?

How can I remount my Android/system as read-write in a bash script using adb?

For info
adb remount
returns "remount failed: Operation not permitted"
adb shell 'su -c mount -o rw,remount /system'
returns unknown option -- o
My device is rooted.
Probable cause that remount fails is you are not running adb as root.
Shell Script should be as follow.
# Script to mount Android Device as read/write.
# List the Devices.
adb devices;
# Run adb as root (Needs root access).
adb root;
# Since you're running as root su is not required
adb shell mount -o rw,remount /;
If this fails, you could try the below:
# List the Devices.
adb devices;
# Run adb as root
adb root;
adb remount;
adb shell su -c "mount -o rw,remount /";
To find which user you are:
$ adb shell whoami
I could not get the mount command to work without specifying the dev block to mount as /system
#cat /proc/mounts returns ( only the system line here )
/dev/stl12 /system rfs ro,relatime,vfat,log_off,check=no,gid/uid/rwx,iocharset=utf8 0 0
so my working command is
mount -o rw,remount -t rfs /dev/stl12 /system
Otherwise... if
getenforce
returns
Enforcing
Then maybe you should call
setenforce 0
mount -o rw,remount /system
setenforce 1
The following may help (study the impacts of disable-verity first):
adb root
adb disable-verity
adb reboot
I had the same problem and could not mount system as read/write. It would return
Usage: mount [-r] [-w] [-o options] [-t type]
device directory
Or
operation not permitted. Access denied
Now this works on all rooted devices.
DO THE FOLLOWING IN TERMINAL EMULATOR OR IN ADB SHELL
$ su
#mount - o rw,remount -t yaffs2 /system
Yaffs2 is the type of system partition. Replace it by the type of your system partition as obtained from executing the following
#cat /proc/mounts
Then check where /system is appearing from the lengthy result
Extract of mine was like
mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0/dev/block/platform/msm_sdcc.3/by-num/p10 /system ext4 ro,relatime,data=ordered 0 0
/dev/block/platform/msm_sdcc.3/by-num/p11 /cache ext4 rw,nosuid,nodev,relatime,data=ordered 0 0
So my system is ext4. And my command was
$ su
#mount -o rw,remount -t ext4 /system
Done.
Get "adbd insecure" from google play store, it helps give write access to custom roms that have it secured my the manufacturers.
In addition to all the other answers you received, I want to explain the unknown option -- o error: Your command was
$ adb shell 'su -c mount -o rw,remount /system'
which calls su through adb. You properly quoted the whole su command in order to pass it as one argument to adb shell. However, su -c <cmd> also needs you to quote the command with arguments it shall pass to the shell's -c option. (YMMV depending on su variants.) Therefore, you might want to try
$ adb shell 'su -c "mount -o rw,remount /system"'
(and potentially add the actual device listed in the output of mount | grep system before the /system arg – see the other answers.)
mount -o rw,remount $(mount | grep /dev/root | awk '{print $3}')
this does the job for me, and should work for any android version.

Attempting to gain r/w access to android /system

Working on a root script for the Nexus 4 with the latest stock rom .img for google (occam) and I have the following code snippet:
./adb wait-for-device
echo "remounting system"
./adb shell "mount -o remount,rw /system"
./adb push su /system/bin/
echo "pushing super user"
./adb push Superuser.apk /system/app/
echo "pushing busybox"
./adb push busybox /system/xbin/
./adb shell "chmod 06755 /system/bin/su"
./adb shell "chmod 0644 /system/app/Superuser.apk"
./adb shell "chmod 04755 /system/xbin/busybox"
./adb shell "cd /system/xbin"
./adb shell "busybox --install /system/xbin/"
I keep getting the error
mount: Operation not permitted
failed to copy 'su' to '/system/bin//su': Read-only file system
pushing super user
failed to copy 'Superuser.apk' to '/system/app//Superuser.apk': Read-only file system
pushing busybox
failed to copy 'busybox' to '/system/xbin//busybox': Read-only file system
Unable to chmod /system/bin/su: No such file or directory
Unable to chmod /system/app/Superuser.apk: No such file or directory
Unable to chmod /system/xbin/busybox: No such file or directory
/system/bin/sh: busybox: not found
I've tried using multiple methods of obtaining r/w access, but nothing seems to be working. I have to automate this process due to the fact that other people will use the script so it needs to be automation friendly, but I just can't figure this out.
I've also tried the
#su
#mount
#mount | grep system
followed by inputting the partition with the system mount and changing it to r/w access, but that also hasn't worked.
Really frustrated at this point. Can anyone help?
It gives the error because you aren't root. The system partition is mounted read-only. You can try to push the binary to /data/local/tmp. Then you can make su executable and eventual run it. But it doesn't mean you can have root. To become root you need to push an exploit like psneuter to /data/local/tmp and run it. It crashes the shell and reopen a new one with root rights. Then you can remount the system-partition read-write and install su.
Try the commands below
adb shell "su -c mount -o remount,rw /system"
adb shell "su -c chmod 06755 /system/bin/su"
and so on.

Executing shell commands programmatically

I want to execute this shell commands by program. How can I do it?
cd C:\android-sdk\platform-tools
adb shell
su
mount -t rfs -o remount,rw /dev/block/stl9 /system
cp /sdcard/MyApp.apk /system/app/MyApp.apk
We can execute shell comands by using Runtime class.
Runtime.getRuntime().exec("ls");
The above piece of code will create a native process for given command ls, will return same process as a Process object.
For more details about it Check here
You Should write the exact syntax you used here in a .bat file, and then just execute it.
It seems you are on a Microsoft station so considering using batch would give you this :
1st method : Stay on your station and send usefull commands
cd C:\android-sdk\platform-tools
adb shell "su -c 'mount -o rw,remount /system'"
adb shell "su -c 'cp /sdcard/MyApp.apk /system/app/MyApp.apk'"
adb shell "su -c 'mount -o ro,remount /system'"
The only thing is you will launch and close 3 shells but its not really and issue.
2nd method : Stay on your station send a sh script on sdcard and execute it
cd C:\android-sdk\platform-tools
adb push myscript.sh /sdcard/
adb shell "su -c 'sh /sdcard/myscript.sh'"
with "myscript.sh" containing :
#!/system/bin/sh
mount -o rw,remount /system
cp /sdcard/MyApp.apk /system/app/MyApp.apk
mount -o ro,remount /system
Remember that Android shell scripts created on Microsoft station have CRLF line ending !
You need to get LF only ending your lines on UNIX like systems !

Categories

Resources