Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
Have you tried rpcinfo servername? –  ott-- Jan 24 '13 at 16:41
add comment

1 Answer 1

up vote 2 down vote accepted

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.

nfsHost="11.22.33.44"
ARRAY=`rpcinfo -p $nfsHost |grep nfs |sed -e "s/ [\s ]*/ /g" -e "s/^ //" |cut -f2 -d" "`
Ver=0
for i in $ARRAY ; do if [ "$i" -gt $Ver ] ; then Ver=$i;fi;done
if [ $Ver -gt 0 ]
then 
    echo "Host: $nfsHost supports NFS version $Ver"; 
    mount -o vers=$Ver...........
fi
share|improve this answer
    
Thanks for the detailed information! –  Nitin Garg Jan 29 '13 at 6:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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