Tuesday 16 October 2012

Export NFS Shares From Command Line

Exporting NFS shares can be painful when you are trying to export the shares through the command line as the syntax's have to be 100% correct and i think altogether confusing so here is what i think is the simplest way to export NFS shares via the command line.

run rdfile /vol/vol0/etc/exports

The output you get should look something like this


#Auto-generated by setup Wed Oct 14 09:35:11 GMT 2012
/vol/vol0 -sec=sys,rw,anon=0,nosuid
/vol/vol0/home -sec=sys,rw,nosuid

To add in an export the easiest way is to write it directly to the file then run exportfs -a

So to add an NFS share for /vol/nfs_vol1 with Read, Write and Root access for host 1, host 2 and host 3 then add the following lines to the exports file

/vol/nfs_vol1     -sec=sys,rw
/vol/nfs_vol1      -sec=sys,rw,root=host1:host2:host3

So now you will need to write this to the exports file you can do this on the command line or by opening the exports file with wordpad to do this from the command line copy the old and new exports contents and  run wrfile /vol/vol0/etc/exports like below

wrfile /vol/vol0/etc/exports

#Auto-generated by setup Wed Oct 14 09:35:11 GMT 2012
/vol/vol0 -sec=sys,rw,anon=0,nosuid
/vol/vol0/home -sec=sys,rw,nosuid
/vol/nfs_vol1     -sec=sys,rw
/vol/nfs_vol1      -sec=sys,rw,root=host1:host2:host3

hit enter
then ctrl-c



the file will now have been updated so running wrfile /vol/vol0/etc/exports will now show


#Auto-generated by setup Wed Oct 14 09:35:11 GMT 2012
/vol/vol0 -sec=sys,rw,anon=0,nosuid
/vol/vol0/home -sec=sys,rw,nosuid
/vol/nfs_vol1     -sec=sys,rw
/vol/nfs_vol1      -sec=sys,rw,root=host1:host2:host3


Now all you will have to do is run the command exportfs -a and the share will have been exported and you will be able to mount the share on the host.

No comments: