diff --git a/xCAT-server/share/xcat/ib/scripts/Mellanox/mlnxofed_ib_install.v2 b/xCAT-server/share/xcat/ib/scripts/Mellanox/mlnxofed_ib_install.v2 index 3388abf21..efc81f1d3 100644 --- a/xCAT-server/share/xcat/ib/scripts/Mellanox/mlnxofed_ib_install.v2 +++ b/xCAT-server/share/xcat/ib/scripts/Mellanox/mlnxofed_ib_install.v2 @@ -168,35 +168,63 @@ function hack_uname() function cleanup() { + local -i i=0 + local -i max_retry=99 + if [ "$NODESETSTATE" != "genimage" ]; then - if mount |grep "/tmp/ofed/mountpoint"; then - umount /tmp/ofed/mountpoint + if mount | grep "/tmp/ofed/mountpoint"; then + while ! umount "/tmp/ofed/mountpoint" + do + (( ++i > max_retry )) && echo "Umount /tmp/ofed/mountpoint failed" >&2 && break + sleep 1 + done fi if [ -d "/tmp/ofed" ]; then rm -rf -- /tmp/ofed fi else - if mount |grep "$IMGROOTPATH/tmp/ofed/mountpoint"; then - umount "$IMGROOTPATH/tmp/ofed/mountpoint" + # Clean up the uname hacking + if [ -f "$IMGROOTPATH/bin/uname.save" ]; then + mv -f "$IMGROOTPATH/bin/uname.save" "$IMGROOTPATH/bin/uname" fi - if mount |grep "$IMGROOTPATH/dev"; then - umount "$IMGROOTPATH/dev" - fi - if mount |grep "$IMGROOTPATH/sys"; then - umount "$IMGROOTPATH/sys" - fi - if mount |grep "$IMGROOTPATH/proc"; then - umount "$IMGROOTPATH/proc" + + # Clean up the ofed iso + if mount | grep "$IMGROOTPATH/tmp/ofed/mountpoint"; then + while ! umount "$IMGROOTPATH/tmp/ofed/mountpoint" + do + (( ++i > max_retry )) && echo "Umount $IMGROOTPATH/tmp/ofed/mountpoint failed" >&2 && break + sleep 1 + done fi if [ -d "$IMGROOTPATH/tmp/ofed" ]; then rm -rf -- "$IMGROOTPATH/tmp/ofed" fi - # Clean up the uname hacking - if [ -f "$IMGROOTPATH/bin/uname.save" ]; then - mv "$IMGROOTPATH/bin/uname.save" "$IMGROOTPATH/bin/uname" - fi + + i=0 + if mount | grep "$IMGROOTPATH/sys"; then + while ! umount "$IMGROOTPATH/sys" + do + (( ++i > max_retry )) && echo "Umount $IMGROOTPATH/sys failed" >&2 && break + sleep 1 + done + fi + i=0 + if mount | grep "$IMGROOTPATH/proc"; then + while ! umount "$IMGROOTPATH/proc" + do + (( ++i > max_retry )) && echo "Umount $IMGROOTPATH/proc failed" >&2 && break + sleep 1 + done + fi + i=0 + if mount | grep "$IMGROOTPATH/dev"; then + while ! umount "$IMGROOTPATH/dev" + do + (( ++i > max_retry )) && echo "Umount $IMGROOTPATH/dev failed" >&2 && break + sleep 1 + done + fi fi - } trap 'cleanup' 0