3
0

mdev.conf.change_blockdev.sh 625 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. # Seconds to try to reread partition table
  3. cnt=60
  4. exec </dev/null
  5. exec >"/tmp/${0##*/}.$$.out"
  6. exec 2>&1
  7. (
  8. echo "Running: $0"
  9. echo "Env:"
  10. env | sort
  11. while sleep 1; test $cnt != 0; do
  12. echo "Trying to reread partition table on $DEVNAME ($cnt)"
  13. cnt=$((cnt-1))
  14. # If device node doesn't exist, it means the device was removed.
  15. # Stop trying.
  16. test -e "$DEVNAME" || { echo "$DEVNAME doesn't exist, aborting"; exit 1; }
  17. #echo "$DEVNAME exists"
  18. if blockdev --rereadpt "$DEVNAME"; then
  19. echo "blockdev --rereadpt succeeded"
  20. exit 0
  21. fi
  22. echo "blockdev --rereadpt failed, exit code: $?"
  23. done
  24. echo "Timed out"
  25. ) &