树莓派设置USB存储设备自动挂载

2016-08-12 22:26:33 +0800


树莓派的系统一般都装有usbmount,已经可以实现插上USB存储设备时自动挂载,但当需要将USB存储设备中的文件进行共享时,就会遇到读写权限的问题,本文介绍如何配置usbmount,使其自动挂载USB存储设备时配置合适的挂载参数。

usbmount的配置文件在/etc/usbmount/usbmount.conf,使用root权限对其进行编辑。

下面是一个典型的配置文件:

# Configuration file for the usbmount package, which mounts removable
# storage devices when they are plugged in and unmounts them when they
# are removed.
# 改为0可以禁用usbmount
ENABLED=1
# 是否启动UDisks守护进程
STARTUDISKS=0
# 自动挂载的文件系统类型
FILESYSTEMS="btrfs ntfs vfat ext2 ext3 ext4 hfsplus exfat msdos iso9660 xfs jfs"
# 挂载目录
MNTPNTDIR="/media"
# 是否包含分区UUID
UUIDNAME=no 
# 创建USBx符号链接的目录
LINKDIR="/media"
# 是否通过samba共享
SHARESMB=yes
# samba共享读写权限
SHARERW=yes
SHARELT=no
# 空闲时关闭硬盘
SPINDOWN=0
#############################################################################
# WARNING!                                                                  #
#                                                                           #
# The "sync" option may not be a good choice to use with flash drives, as   #
# it forces a greater amount of writing operating on the drive. This makes  #
# the writing speed considerably lower and also leads to a faster wear out  #
# of the disk.                                                              #
#                                                                           #
# If you omit it, don't forget to use the command "sync" to synchronize the #
# data on your disk before removing the drive or you may experience data    #
# loss.                                                                     #
#                                                                           #
# It is highly recommended that you use the pumount command (as a regular   #
# user) before unplugging the device. It makes calling the "sync" command   #
# and mounting with the sync option unnecessary---this is similar to other  #
# operating system's "safely disconnect the device" option.                 #
#############################################################################
# Mount options: Options passed to the mount command with the -o flag.
# See the warning above regarding removing "sync" from the options.
# 设置通用的挂载参数,rw是读写权限,noexec是禁止运行程序
# 如果需要在USB存储设备上运行或者编译程序,需要将noexec删除
MOUNTOPTIONS="sync,noexec,nodev,noatime,rw"
# Filesystem type specific mount options: This variable contains a space
# separated list of strings, each which the form "-fstype=TYPE,OPTIONS".
#
# If a filesystem with a type listed here is mounted, the corresponding
# options are appended to those specificed in the MOUNTOPTIONS variable.
#
# For example, "-fstype=vfat,gid=floppy,dmask=0007,fmask=0117" would add
# the options "gid=floppy,dmask=0007,fmask=0117" when a vfat filesystem
# is mounted.
# 针对某些文件系统设置挂载参数
FS_MOUNTOPTIONS="-fstype=ntfs,gid=xbian,uid=xbian,umask=0,big_writes,allow_other \
 -fstype=vfat,gid=xbian,uid=xbian,umask=0 \
 -fstype=hfsplus,gid=xbian,uid=xbian,umask=0,force \
 -fstype=exfat,gid=xbian,uid=xbian,umask=0 \
 -fstype=btrfs,compress=lzo,subvol=/"
 
# 是否输出详细日志
VERBOSE=no
# 是否使用内存交换区
USESWAPS=no

另外/etc/usbmount/目录下还有三个文件夹,分别储存挂载和卸载USB设备时的配置文件。

附上配置文件打包

usbmount.tgz


上一篇:安装树莓派GPIO驱动wiringPi

下一篇:使用树莓派建立Http公共代理服务器