The mount command in linux requires -t nfs4 in order to mount version 4 NFS shares, so I need to know beforehand which version it is.

  • Have you tried rpcinfo servername? – ott-- Jan 24 '13 at 16:41

Per: NFS version 3 and 4 with TCP/IP protocols, you could enter either of these commands:

rpcinfo -p <hostname> |grep nfs

rpcinfo -s <hostname> |grep nfs 

Note: All flavours of the command appear to support the -p argument, while the Solaris and GNU linux variants also support the -s variant.

You could include some logic, based around the enquiry, into a shell script that instantiates a variable that could be pluged into a mount command e.g.

ARRAY=`rpcinfo -p $nfsHost |grep nfs |sed -e "s/ [\s ]*/ /g" -e "s/^ //" |cut -f2 -d" "`
for i in $ARRAY ; do if [ "$i" -gt $Ver ] ; then Ver=$i;fi;done
if [ $Ver -gt 0 ]
    echo "Host: $nfsHost supports NFS version $Ver"; 
    mount -o vers=$Ver...........

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.