You are here: User Guide > Using LifeKeeper Linux > Advanced Tasks > Sample Remove Script

Sample Remove Script

The following example provides the functional processing section of a file system remove script:

72 if f=`sed -n "\?^.* $FSNAME ?p" /etc/mnttab`

73 then

74 if [ "$f" != "" ]

75 then

76 # Check if the file system is being used by a process;

77 # if so, kill the process

78 pl "LifeKeeper: must kill off any processes accessing file system $FSNAME before it can be unmounted."

79

80 # A timing window exists here -- additional users could

81 # access the FS after fuser issues the kill. In this

82 # case the umount would fail. So, we try 3 times or

83 # until fuser reports no processes

84 for try in 1 2 3

85 do

86 if [ `fuser -k -c "${FSNAME}" 2>/dev/null | wc -c` -eq 0 ]

87 then

88 # No more processes... (we have to be quick now!) Unmount

89 # the file system. The umount is done immediately -- this

90 # might mess up the log files if an error occurs, but if

91 # we issue the messages first, it just lengthens the timing

92 # window.

93 if umount "${FSNAME}" 2>/tmp/UM$$

94 then

95 # umount worked... issue the messages now (better late

96 # than not at all!)

97 pl "LifeKeeper: unmounting file system $FSNAME"

98 pl "\tumount ${FSNAME}"

99 pl "LifeKeeper: file system $FSNAME successfully unmounted"

100 err=0

101 exit 0

102 else

103 pl "LifeKeeper: unmounting file system $FSNAME"

104 pl "\tumount ${FSNAME}"

105 cat /tmp/UM$$ >&2

106 pl "LifeKeeper: *ERROR* file system $FSNAME failed unmount; will try again"

107 fi

108 fi

109 sleep 3 # processes might be slow to die, so wait a bit

110 done

111 else

112 pl "LifeKeeper: File system ${FSNAME} is not mounted."

113 err=0

114 exit 0

115 fi

116 else

117 exit 1

118 fi

119

120 #

121 # If we get here, the fuser above failed to kill all the active processes.

122 # The unmount of the file system will most likely fail, but what can we

123 # do?

124

125 sleep 5

126

127 pl "LifeKeeper: unmounting file system $FSNAME"

128 pl "\tumount ${FSNAME}"

129 if umount "${FSNAME}"

130 then

131 pl "LifeKeeper: file system $FSNAME successfully unmounted"

132 err=0

133 exit 0

134 else

135 pl "LifeKeeper: *ERROR* file system $FSNAME failed unmount"

136 exit 1

137 fi

© 2012 SIOS Technology Corp., the industry's leading provider of business continuity solutions, data replication for continuous data protection.