adb shell常见错误

1. 提示read-only file system

当使用adb shell时,向/system目录及其子目录写文件时经常提示“read-only file system”。其实产生该提示的原因很简单:/system是以ro模式挂载的,因此我们所要做的就是以读写模式(rw)重新挂载需要修改的目录(本例中为/system),具体流程如下:

1). 进入adb shell并查看当前挂在情况

命令号下输入:adb shell
#mount

这时候看到当前挂载情况

rootfs on / type rootfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
none on /acct type cgroup (rw,relatime,cpuacct)
tmpfs on /mnt/asec type tmpfs (rw,relatime,mode=755,gid=1000)
tmpfs on /mnt/obb type tmpfs (rw,relatime,mode=755,gid=1000)
none on /dev/cpuctl type cgroup (rw,relatime,cpu)
/dev/block/mmcblk0p25 on /system type ext4 (ro,relatime,barrier=1,data=ordered)
/dev/block/mmcblk0p26 on /data type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc)
/dev/block/mmcblk0p27 on /cache type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered)
/dev/block/mmcblk0p28 on /devlog type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered)
/data/d on /data/d type debugfs (rw,relatime)
/sys/kernel/debug on /sys/kernel/debug type debugfs (rw,relatime)
/dev/block/vold/179:65 on /mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:65 on /mnt/secure/asec type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
tmpfs on /mnt/sdcard/.android_secure type tmpfs (ro,relatime,size=0k,mode=000)

我们感兴趣的是

dev/block/mmcblk0p25 on /system type ext4 (ro,relatime,barrier=1,data=ordered)

可以看到system是以只读权限挂载的

2). 重新挂载需要修改权限的目录

#mount -o remount -o rw /system

具体的可以看下mount的参数。

3). 查看修改后的结果

# mount
rootfs on / type rootfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
none on /acct type cgroup (rw,relatime,cpuacct)
tmpfs on /mnt/asec type tmpfs (rw,relatime,mode=755,gid=1000)
tmpfs on /mnt/obb type tmpfs (rw,relatime,mode=755,gid=1000)
none on /dev/cpuctl type cgroup (rw,relatime,cpu)
/dev/block/mmcblk0p25 on /system type ext4 (rw,relatime,barrier=1,data=ordered)
/dev/block/mmcblk0p26 on /data type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc)
/dev/block/mmcblk0p27 on /cache type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered)
/dev/block/mmcblk0p28 on /devlog type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered)
/data/d on /data/d type debugfs (rw,relatime)
/sys/kernel/debug on /sys/kernel/debug type debugfs (rw,relatime)
/dev/block/vold/179:65 on /mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:65 on /mnt/secure/asec type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
tmpfs on /mnt/sdcard/.android_secure type tmpfs (ro,relatime,size=0k,mode=000)
# 

大功告成。其他目录同理。尽情adb push/pull 啥的吧

 

2. 使用chmod修改权限提示bad mode

一般修改权限会用:

chmod +x hello

但是我发现会提示 badmode,尝试后发现,使用数字形式的权限修改成功:

chmod 755 hello

 

 3. 在执行mv命令时提示“-cross-device link”

这种情况下,可以使用cat将文件重定向到指定位置,然后根据需要,修改权限即可。

cat /mnt/sdcard/test.apk > /system/app/test.apk

 

 

posted on 2013-01-29 00:51  rainduck  阅读(16407)  评论(0编辑  收藏  举报

导航