自定义热插拔存储挂载脚本 10-mount
root@ACU:~# root@ACU:~# cat /etc/hotplug.d/block/10-mount #!/bin/ash case "$ACTION" in add) # for i in $(ls /dev/ | grep 'sd[a-z][1-9]') # do # mkdir -p /mnt/$i # mount -o rw /dev/$i /mnt/$i # done # INFO: Mount only the last block partition device MOUNT_DEV=`ls /dev/ | grep 'sd[a-z][1-9]' | tail -n 1` MOUNT_DIR='sda1' umount /dev/$MOUNT_DEV mkdir -p /mnt/$MOUNT_DIR mount -o rw /dev/$MOUNT_DEV /mnt/$MOUNT_DIR ;; remove) MOUNT=`mount | grep -o '/mnt/sd[a-z][1-9]'` for i in $MOUNT do umount $i if [ $? -eq 0 ] then rm -r $i fi done ;; esac root@ACU:~# root@ACU:~# MOUNT_DEV=`ls /dev/ | grep 'sd[a-z][1-9]' | tail -n 1` root@ACU:~# root@ACU:~# MOUNT_DIR='sda1' root@ACU:~# root@ACU:~# echo /dev/$MOUNT_DEV /dev/sda2 root@ACU:~# root@ACU:~# root@ACU:~# echo /mnt/$MOUNT_DIR /mnt/sda1 root@ACU:~# root@ACU:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 8.5M 8.5M 0 100% /rom tmpfs 61.1M 600.0K 60.5M 1% /tmp /dev/mtdblock4 5.8M 396.0K 5.4M 7% /overlay overlayfs:/overlay 5.8M 396.0K 5.4M 7% / tmpfs 512.0K 0 512.0K 0% /dev /dev/sda2 447.0G 243.7G 203.3G 55% /mnt/sda1 root@ACU:~# root@ACU:~# fdisk -l /dev/sda Disk /dev/sda: 480.1 GB, 480103981056 bytes 255 heads, 63 sectors/track, 58369 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 267350 2147483647+ ee EFI GPT root@ACU:~# root@ACU:~# fdisk -l /dev/sda1 Disk /dev/sda1: 134 MB, 134217728 bytes 255 heads, 63 sectors/track, 16 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sda1 doesn't contain a valid partition table root@ACU:~# root@ACU:~# fdisk -l /dev/sda2 Disk /dev/sda2: 479.9 GB, 479967838208 bytes 256 heads, 63 sectors/track, 58124 cylinders Units = cylinders of 16128 * 512 = 8257536 bytes Device Boot Start End Blocks Id System /dev/sda2p1 ? 266306 266306 2147483647+ ff Unknown /dev/sda2p2 ? 266306 266306 2147483647+ ff Unknown /dev/sda2p3 ? 266306 266306 2147483647+ ff Unknown /dev/sda2p4 ? 266306 158686 1279637119+ ff Unknown root@ACU:~# root@ACU:~#
# 正确的硬盘格式为 ( MBR引导 + exfat分区 )
root@ACU:~# df -Th Filesystem Type Size Used Available Use% Mounted on /dev/root squashfs 8.5M 8.5M 0 100% /rom tmpfs tmpfs 61.1M 100.0K 61.0M 0% /tmp /dev/mtdblock4 jffs2 5.8M 328.0K 5.4M 6% /overlay overlayfs:/overlay overlay 5.8M 328.0K 5.4M 6% / tmpfs tmpfs 512.0K 0 512.0K 0% /dev /dev/sda1 exfat 59.8G 1.0M 59.7G 0% /mnt/sda1 root@ACU:~# root@ACU:~# fdisk -l Disk /dev/sda: 64.1 GB, 64160400896 bytes 255 heads, 63 sectors/track, 7800 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 7801 62655488 7 HPFS/NTFS root@ACU:~# root@ACU:~# fdisk -l /dev/sda1 Disk /dev/sda1: 64.1 GB, 64159219712 bytes 256 heads, 63 sectors/track, 7769 cylinders Units = cylinders of 16128 * 512 = 8257536 bytes Device Boot Start End Blocks Id System /dev/sda1p1 ? 266306 266306 2147483647+ ff Unknown /dev/sda1p2 ? 266306 266306 2147483647+ ff Unknown /dev/sda1p3 ? 266306 266306 2147483647+ ff Unknown /dev/sda1p4 ? 266306 158686 1279637119+ ff Unknown root@ACU:~#
============= End