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