Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A terminal command for a rooted Android to remount /System as read/write

I'm writing an android app that needs to copy a file to the "/system" partition at runtime. I've got the commands to run "su" and can successfully request SuperUser permissions and run commands as root. But I don't know how to make this app universal across multiple devices, because the mount command can differ depending on where the /system is actually mounted. Here's the command that's used most offen:

mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system 

But I know that mtdblock3 could be different on some devices (and for that matter, i guess so could yaffs2). So, my question is: Is there a universal command that will work on all phones? Or is there a way to find out at runtime what the correct parameters are?

like image 966
user496854 Avatar asked Mar 29 '11 04:03

user496854


People also ask

What is adb remount command?

adb remount put /system partition in writable mode. By default /system is only readable. It could only be done on rooted device. It must be done before pushing file on /system partition. adb remount corresponding to: adb shell mount -o rw,remount,rw /system.


2 Answers

I use this command:

mount -o rw,remount /system 
like image 165
Gussoh Avatar answered Oct 06 '22 00:10

Gussoh


You can run the mount command without parameter in order to get partition information before constructing your mount command. Here is an example of the mount command without parameter outputed from my HTC Hero.

$ mount mount rootfs / rootfs ro 0 0 tmpfs /dev tmpfs rw,mode=755 0 0 devpts /dev/pts devpts rw,mode=600 0 0 proc /proc proc rw 0 0 sysfs /sys sysfs rw 0 0 tmpfs /sqlite_stmt_journals tmpfs rw,size=4096k 0 0 none /dev/cpuctl cgroup rw,cpu 0 0 /dev/block/mtdblock3 /system yaffs2 rw 0 0 /dev/block/mtdblock5 /data yaffs2 rw,nosuid,nodev 0 0 /dev/block/mtdblock4 /cache yaffs2 rw,nosuid,nodev 0 0 /dev/block//vold/179:1 /sdcard vfat rw,dirsync,nosuid,nodev,noexec,uid=1000,gid= 1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,s hortname=mixed,utf8,errors=remount-ro 0 0 
like image 45
Bao Le Avatar answered Oct 06 '22 01:10

Bao Le