openwrt自动挂载U盘【信息过时】
2016-06-06 14:26
896 查看
首先要往/etc/config/fstab加入
config 'mount'
option device '/dev/sda'
option target '/mnt/share'
option enbaled '1' //表示开机自动挂载
改完后运行/etc/init.d/fstab
然后修改/etc/hotplug.d/usb/10-motion为
#!/bin/sh
# Copyright (C) 2009 OpenWrt.org (C) 2010 OpenWrt.org.cn
logger -t INFO "hotplug usb: action='$ACTION' devicename='$DEVICENAME' devname='$DEVNAME' devpath='$DEVPATH' product='$PRODUCT' type='$TYPE' interface='$INTERFACE'"
blkdev=`dirname $DEVPATH`
if [ `basename $blkdev` != "block" ]; then
device=`basename $DEVPATH`
case "$ACTION" in
add)
mkdir -p /mnt/$device
# vfat & ntfs-3g check
if [ `which fdisk` ]; then
isntfs=`fdisk -l | grep $device | grep NTFS`
isvfat=`fdisk -l | grep $device | grep FAT`
isfuse=`lsmod | grep fuse`
isntfs3g=`which ntfs-3g`
else
isntfs=""
isvfat=""
fi
# mount with ntfs-3g if possible, else with default mount
if [ "$isntfs" -a "$isfuse" -a "$isntfs3g" ]; then
ntfs-3g -o nls=utf8 /dev/$device /mnt/$device
elif [ "$isvfat" ]; then
mount -t vfat -o iocharset=utf8,rw,sync,umask=0000,dmask=0000,fmask=0000 /dev/$device /mnt/$device
else
mount /dev/$device /mnt/$device
fi
if [ -f /dev/${device}/swapfile ]; then
mkswap /dev/${device}/swapfile
swapon /dev/${device}/swapfile
fi
;;
remove)
if [ -f /dev/${device}/swapfile ]; then
swapoff /dev/${device}/swapfile
fi
umount /dev/$device
;;
esac
fi
config 'mount'
option device '/dev/sda'
option target '/mnt/share'
option enbaled '1' //表示开机自动挂载
改完后运行/etc/init.d/fstab
然后修改/etc/hotplug.d/usb/10-motion为
#!/bin/sh
# Copyright (C) 2009 OpenWrt.org (C) 2010 OpenWrt.org.cn
logger -t INFO "hotplug usb: action='$ACTION' devicename='$DEVICENAME' devname='$DEVNAME' devpath='$DEVPATH' product='$PRODUCT' type='$TYPE' interface='$INTERFACE'"
blkdev=`dirname $DEVPATH`
if [ `basename $blkdev` != "block" ]; then
device=`basename $DEVPATH`
case "$ACTION" in
add)
mkdir -p /mnt/$device
# vfat & ntfs-3g check
if [ `which fdisk` ]; then
isntfs=`fdisk -l | grep $device | grep NTFS`
isvfat=`fdisk -l | grep $device | grep FAT`
isfuse=`lsmod | grep fuse`
isntfs3g=`which ntfs-3g`
else
isntfs=""
isvfat=""
fi
# mount with ntfs-3g if possible, else with default mount
if [ "$isntfs" -a "$isfuse" -a "$isntfs3g" ]; then
ntfs-3g -o nls=utf8 /dev/$device /mnt/$device
elif [ "$isvfat" ]; then
mount -t vfat -o iocharset=utf8,rw,sync,umask=0000,dmask=0000,fmask=0000 /dev/$device /mnt/$device
else
mount /dev/$device /mnt/$device
fi
if [ -f /dev/${device}/swapfile ]; then
mkswap /dev/${device}/swapfile
swapon /dev/${device}/swapfile
fi
;;
remove)
if [ -f /dev/${device}/swapfile ]; then
swapoff /dev/${device}/swapfile
fi
umount /dev/$device
;;
esac
fi
相关文章推荐
- linux基础(34)--REHL7基本配置--RHEL7
- Centos 7 之 systemctl
- NGINX 长字符串被截断的问题
- arm linux下使用 qextserialport 编写串口小程序
- 校园网、教育网 如何纯粹访问 IPv6 网站避免收费
- linux fd dup 使用
- Nginx vs Apache
- PHP7.0与Apache相应配置
- Linux 下系统调用的三种方法
- shell 自定义函数
- JAVA网站之Tomcat使用域名与域名解析详解
- linux运维中,如何打印进程消耗内存占比(排序)
- Nginx问题定位之监控进程异常退出
- 用crontab命令实现每天定时的病毒扫描
- 25个简单shell例子
- 深入理解Nginx之调试优化技巧
- linux echo命令的-n、-e两个参数
- Linux下JDK、Tomcat的安装及配置
- Nginx 和 Apache
- Linux软连接和硬链接