5
# checking proper invocation and if we have the tools to work.
6
# sfdisk is part of util-linux (Essential: yes)
7
if [ -z "$device" ] || ! which sg_start > /dev/null; then
11
# wait maximum 1 minute for a device to appear in /dev
13
while [ ${slumber} -gt 0 -a ! -b /dev/$device ]; do
15
slumber=$(( ${slumber} - 1 ))
18
# if the device finally exists start it.
19
if [ -b /dev/$device ]; then
20
if ! sg_turs /dev/$device > /dev/null 2>&1; then
21
# start the device and wait for it
22
sg_start --imm=0 --start /dev/$device
26
echo 1 > /sys/block/$device/device/rescan
27
# rescan partition table
28
if which sfdisk > /dev/null; then
29
sfdisk -R /dev/$device
31
# this is harsh but multipathd needs a hard restart
32
kill -9 $(pidof /sbin/multipathd) || true
33
multipath -v 0 /dev/$device
34
invoke-rc.d multipath-tools start > /dev/null 2>&1 || true