2014年7月27日星期日

树莓派自动挂载u盘

LXDE 下是自动挂载的,命令行下需要弄一下。
纯按照 http://www.axllent.org/docs/view/auto-mounting-usb-storage/ 的步骤来的。
建立文件 /etc/udev/rules.d/11-media-by-label-auto-mount.rules 内容如下
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
# Exit
LABEL="media_by_label_auto_mount_end"
保存之后执行 udevadm control --reload-rules 就生效了。
ps:真心不是我崇洋媚外,搜到中文的,比如 http://www.raspicn.com/thread-70-1-1.htmlhttp://rpi.linux48.com/usbstorage.html ,挂载之后 ls -l 用户是 root ,文件权限都是 rwxrwxrwx ,看着不难受吗……
--
≋ὥ≋
触手什么的最有爱了~

没有评论:

发表评论