Validation of mounting and unmounting

Hi folks,

I have below code for unmounting, but i need validation filesystem is unmounted or not, if not it give us error. Please confirm below code or need modification. Please suggest.


umount /oradata

if [ $? -eq 0 ]

then
     echo "/oradata Unmounted Successfully"

else
     echo "Problem in umounting /oradata Please Check."
fi

Same is for mounting purpose. Please suggest.


mount /dev/xxx/vol1 /oradata

if [ $? -eq 0 ]

then
     echo "/oradata mounted Successfully"

else
     echo "Problem in mounting /oradata Please Check."
fi

df -k /oradata

or

mount  |grep oradata

It is for mounting or unmounting?

You might want to use fuser -ck /mountpoint before executing umount.

That way fuser will kill the pids which are potentially holding the mountpoint and umount will work fine.

As for mounting, you can use return code ($?) to verify the mount is successful (should return zero if mount is success).