forked from lon91ong/OpenWRT_B70_SPI_16M
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmount.hotplug
34 lines (30 loc) · 1.24 KB
/
mount.hotplug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
# Copyright (C) 2015 OpenWrt.org
# 0 yes blockdevice handles this - 1 no it is not there
blkdev=`dirname $DEVPATH`
basename=`basename $blkdev`
device=`basename $DEVPATH`
skip=`block info | sed 's/\(.*\): .*/\1/' | grep -q $device ; echo $?`
path=$DEVPATH
if [ $basename != "block" ] && [ -z "${device##sd*}" ] && [ $skip -eq 1 ]; then
islabel=`blkid /dev/$device | grep -q LABEL ; echo $?`
if [ $islabel -eq 0 ] ; then
mntpnt=`blkid /dev/$device |sed 's/.*LABEL="\(.*\)" UUID.*/\1/'`
else
mntpnt=$device
fi
case "$ACTION" in
add)
mkdir -p /export/$mntpnt
# Set APM value for automatic spin down
/sbin/hdparm -B 127 /dev/$device
# Try to be gentle on solid state devices
mount -o rw,noatime,discard /dev/$device /export/$mntpnt
;;
remove)
# Once the device is removed, the /dev entry disappear. We need mountpoint
mountpoint=`mount |grep /dev/$device | sed 's/.* on \(.*\) type.*/\1/'`
umount -l $mountpoint
;;
esac
fi