【LEDE】树莓派上玩LEDE终极指南-73-按UUID挂载分区

依赖blkid

opkg install blkid


#!/bin/sh

# Copyright (C) 2015 OpenWrt.org
# 修改:[email protected]

# 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
        mntpnt=`blkid -s UUID /dev/$device | awk '{print $2}' | sed 's/UUID=\"//g' | sed 's/\"//g'`
        case "$ACTION" in
                add)
                        mkdir -p /mnt/by-uuid/$mntpnt
                        chmod 777 /mnt/by-uuid/$mntpnt
                        # Try to be gentle on solid state devices
                        mount -o rw,noatime,discard /dev/$device /mnt/by-uuid/$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
                        rm -rf /mnt/by-uuid/$mntpnt
                ;;
        esac
fi

发布了86 篇原创文章 · 获赞 21 · 访问量 18万+

猜你喜欢

转载自blog.csdn.net/wang805447391/article/details/81019761