Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.

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...........
share|improve this answer
Thanks for the detailed information! – Nitin Garg Jan 29 '13 at 6:21

Your Answer


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.