Advertisement
OldManRiver

mount-drives.sh

Jun 4th, 2014
268
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/bash
  2. # Author: Nyle Davis Created 14-05-26
  3. # Purpose: Find and mount USB/Flash drive(s), returning size of each
  4. # File: mount-drives.sh
  5. # CRON: This script is CRON compatible and executable
  6. # Background: The script is Background compatible and executable
  7.  
  8. function usbscan {
  9. for DEV in /sys/block/sd*; do
  10. if readlink $DEV | grep -q usb; then
  11. DEV=`basename $DEV`;
  12. if [ -d /sys/block/${DEV}/${DEV}1 ]; then
  13. devdrv=$DEV[0-9]*;
  14. echo "Has partitions " /sys/block/$DEV/${devdrv};
  15. MOUNT=`df | grep $DEV | awk '{print $6}'`;
  16. if [ -z ${MOUNT} ]; then
  17. # Use hardcode for next 3 line to mount the flash on Aspire
  18. mkdir /mnt/flash;
  19. mkdir /mnt/flash/64Gig;
  20. mount /dev/${devdrv} /mnt/flash/64Gid;
  21. MOUNT=`df | grep $DEV | awk '{print $6}'`;
  22. fi
  23. echo "Mount ==> " ${MOUNT};
  24. else
  25. echo "Has no partitions"
  26. fi
  27. fi
  28. done }
  29.  
  30. usbscan;
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement