2013-03-30 20:53:12 +05:30
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Seconds to try to reread partition table
|
|
|
|
cnt=60
|
|
|
|
|
|
|
|
exec </dev/null
|
|
|
|
exec >"/tmp/${0##*/}.$$.out"
|
|
|
|
exec 2>&1
|
|
|
|
|
|
|
|
(
|
|
|
|
echo "Running: $0"
|
|
|
|
echo "Env:"
|
|
|
|
env | sort
|
|
|
|
|
|
|
|
while sleep 1; test $cnt != 0; do
|
2013-04-02 16:56:24 +05:30
|
|
|
echo "Trying to reread partition table on $DEVNAME ($cnt)"
|
2013-03-30 20:53:12 +05:30
|
|
|
: $((cnt--))
|
2013-04-02 16:56:24 +05:30
|
|
|
# If device node doesn't exist, it means the device was removed.
|
|
|
|
# Stop trying.
|
2013-03-30 20:53:12 +05:30
|
|
|
test -e "$DEVNAME" || { echo "$DEVNAME doesn't exist, aborting"; exit 1; }
|
|
|
|
#echo "$DEVNAME exists"
|
2013-04-02 16:56:24 +05:30
|
|
|
if blockdev --rereadpt "$DEVNAME"; then
|
|
|
|
echo "blockdev --rereadpt succeeded"
|
|
|
|
exit 0
|
|
|
|
fi
|
2013-03-30 20:53:12 +05:30
|
|
|
echo "blockdev --rereadpt failed, exit code: $?"
|
|
|
|
done
|
2013-04-02 16:56:24 +05:30
|
|
|
echo "Timed out"
|
2013-03-30 20:53:12 +05:30
|
|
|
) &
|