123456789101112131415
  1. #!/bin/bash
  2. #for more detial to determine which sd is usb
  3. #http://unix.stackexchange.com/questions/60299/how-to-determine-which-sd-is-usb
  4. grep -Hv ^0$ /sys/block/*/removable | \
  5. sed s/removable:.*$/device\\/uevent/ | \
  6. xargs grep -H ^DRIVER=sd | \
  7. sed s/device.uevent.*$/size/ | \
  8. xargs grep -Hv ^0$ | \
  9. cut -d / -f 4 | \
  10. while read line ;do
  11. if [ "$(mount | grep "$line" | wc -l)" != "$(mount | grep "$line.*noexec" | wc -l )" ];then
  12. exit 1
  13. fi
  14. done