Usually through the/etc/fstab to handle the mount settings, and then use Mount-a to reconfirm the mount, preferably in the scheduling program used to mount the directory also perform a mount-a, mount directory in the disconnection is not automatically reply, mount-a Timeout actually quite a long time , especially when the server does not exist, it is a good idea to use the corresponding client to first confirm that the server exists.
The client that checks for NFS can be treated with showmount and installed on Ubuntu in the following way:
Copy Code code as follows:
sudo aptitude install Nfs-common
The client of SAMBA, however, uses smbclient, which is installed on Ubuntu as follows:
Copy Code code as follows:
sudo aptitude install smbclient
procedures for checking for NFS Server presence
Check in the Shell way
Copy Code code as follows:
# First confirm server presence with Client
/sbin/showmount 192.168.0.6 >/dev/null 2>&1
If ["j$"!= "J0"]; Then
echo "NFS Server is not exist"
Exit 1
Fi
# Re-confirm Mount
Mount-a >/dev/null 2>&1
If ["j$"!= "J0"]; Then
echo "NFS Server Mount Failed"
Exit 1;
Fi
Check in PHP mode
Copy Code code as follows:
/* First to confirm server presence by client * *
$state = Shell_exec ('/sbin/showmount 192.168.0.6 >/dev/null 2>&1; echo $? ');
if (Trim ($state)!= ' 0 ') {
echo "NFS Server is not exist";
Exit
}
/* Re-check mount * *
if (shell_exec (' mount-a 2>&1 ')) {
echo "NFS Server Mount Failed"
Exit
}
To check if the SAMBA Server exists
Check in the Shell way
Copy Code code as follows:
# First confirm server presence with Client
SMBCLIENT-NL//192.168.0.6 >/dev/null 2>&1
If ["j$"!= "J0"]; Then
echo "SAMBA Server is not exist"
Exit 1
Fi
# Re-confirm Mount
Mount-a >/dev/null 2>&1
If ["j$"!= "J0"]; Then
echo "SAMBA Server Mount Failed"
Exit 1;
Fi
Check in PHP mode
Copy Code code as follows:
/* First to confirm server presence by client * *
$state = Shell_exec (' smbclient-nl//192.168.0.6 >/dev/null 2>&1; echo $? ');
if (Trim ($state)!= ' 0 ') {
echo "SAMBA Server is not exist";
Exit
}
/* Re-check mount * *
if (shell_exec (' mount-a 2>&1 ')) {
echo "SAMBA Server Mount Failed"
Exit
}