神马 - 云代码空间
—— 任何傻瓜都能写出计算机可以理解的代码,好的程序员能写出人能读懂的代码。
一、修改vold.fstab
/etc link到system/etc,需要修改/etc/vold.fstab,但vold.fstab为只读,在命令行下无法修改
使用adb来实现更改的目的,步骤:
1. 获取root权限,adb root(若终端上后台有运行adbd,则插上usb至PC时,终端命令行下会打印出android_usb gadget: high speed config #1: android)
2. 更改system为读写,adb remount(此命令后,终端命令行下会打印EXT4-fs (mmcblk0p2): re-mounted. Opts: (null))
3. 通过adb下载/system/etc/vold.fstab到PC本地,adb pull /system/etc/vold.fstab vold.fstab
4. 在PC本地修改vold.fstab
5. 通过adb上传vold.fstab至终端/system/etc目录,adb push vold.fstab /system/etc/vold.fstab
以上则可完成后,重启即可见到修改后的效果
二、调测vold.fstab
调试自动加载U盘时,需要配置vold.fstab,原来的vold.fstab如下:
## Vold 2.0 Generic fstab ## - San Mehat (san@android.com) ## ####################### ## Regular device mount ## ## Format: dev_mount <label> <mount_point> <part> <sysfs_path1...> ## label - Label for the volume ## mount_point - Where the volume will be mounted ## part - Partition # (1 based), or 'auto' for first usable partition. ## <sysfs_path> - List of sysfs paths to source devices ###################### ## Example of a standard sdcard mount for the emulator / Dream # Mounts the first usable partition of the specified device dev_mount sdcard /mnt/sdcard auto /devices/platform/mxsdhci.0/mmc_host/mmc1 #used for usb host dev_mount udisk /mnt/udisk auto /devices/platform/fsl-ehci.0/usb ## Example of a dual card setup # dev_mount left_sdcard /sdcard1 auto /devices/platform/goldfish_mmc.0 /devices/platform/msm_sdcc.2/mmc_host/mmc1 # dev_mount right_sdcard /sdcard2 auto /devices/platform/goldfish_mmc.1 /devices/platform/msm_sdcc.3/mmc_host/mmc1 ## Example of specifying a specific partition for mounts # dev_mount sdcard /sdcard 2 /devices/platform/goldfish_mmc.0 /devices/platform/msm_sdcc.2/mmc_host/mmc1
dev_mount disk /data/udisk auto /devices/platform/fsl-ehci.0/usb1
dev_mount udisk /mnt/udisk auto /devices/platform/fsl-ehci.1/usb2
(PS:手动加载在命令行下直接运行mount -t vfat /dev/block/sda1 /mnt/udisk -o rw,dmask=0000,fmask=0000,noatime)
这样,分别插入两个usb端口后,使用mount查看到自动mount的节点,如下:
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
tmpfs /sqlite_stmt_journals tmpfs rw,relatime,size=4096k 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/shm tmpfs rw,relatime,size=1024k,mode=775,uid=1000,gid=1003 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
/dev/block/mmcblk0p2 /system ext4 ro,relatime,barrier=1,data=ordered 0 0
/dev/block/mmcblk0p5 /data ext4 rw,nosuid,nodev,relatime,barrier=1,nodelalloc,data=ordered 0 0
/dev/block/mmcblk0p6 /cache ext4 rw,nosuid,nodev,relatime,barrier=1,data=ordered 0 0
/dev/block/mmcblk0p7 /auth ext4 rw,relatime,barrier=1,data=ordered 0 0
/dev/block/mmcblk0p8 /soft ext4 rw,relatime,barrier=1,data=ordered 0 0
/dev/block/mmcblk0p11 /inand vfat rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
/dev/block/vold/8:1 /mnt/udisk vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/8:1 /data/udisk vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
注意:可能由于system/bin/vold的bebug,如果同时mount两个节点于同一个目录,好像只能自动加载第一个mount点,而第二个节点没法自动加载