Thursday, August 19, 2010

NFS on Solaris 10

NFS is to share files across different Unix and Linux computers and is a nice way to get your feet wet with Solaris. To set this up, I am running two different Solaris 10 boxes using Virtualbox.

1. The server has the hostname of "server" and the IP address of 192.168.0.200.
2. The client has the hostname of "client" and the IP address of 192.168.0.201.

We're going to share "nfs_share" on the server and then mount it to "nfs_share" on the client.

To set up NFS, on your server make sure the NFS services are running, specifically the NFS service:

svcs –a | grep nfs

online Mar_30 svc:/network/nfs/status:default
online Mar_30 svc:/network/nfs/mapid:default
online Mar_30 svc:/network/nfs/cbd:default
online Mar_30 svc:/network/nfs/nlockmgr:default
online Mar_30 svc:/network/nfs/client:default
online Mar_30 svc:/network/nfs/rquota:default
online Mar_30 svc:/network/nfs/server:default

If the NFS server is not online, use svcsadm enable /network/nfs/server to turn it online.

Next is to create a directory to share:

mkdir nfs_share
chmod 700 nfs_share

For a temporary share of the nfs_share folder, use:

share –F nfs –o rw nfs_share

For a permanent share (it will persist across reboots), edit /etc/dfs/dfstab with vi and add a line to the bottom of the file:

share –F nfs –o rw –d “This is a comment” /nfs_share
  • -o is the options that are used, rw is for read and write, ro is for read only
  • -d is a comment of the share
Use the command “shareall” to share the nfs_share folder.

Your NFS server is setup and is ready to share files, just need to setup the NFS client.

On the NFS client, double check to make sure the NFS services are running, most importantly the client service.

svcs –a | grep nfs
online Mar_30 svc:/network/nfs/status:default
online Mar_30 svc:/network/nfs/mapid:default
online Mar_30 svc:/network/nfs/cbd:default
online Mar_30 svc:/network/nfs/nlockmgr:default
online Mar_30 svc:/network/nfs/client:default
online Mar_30 svc:/network/nfs/rquota:default
online Mar_30 svc:/network/nfs/server:default

If the NFS client is not online, use svcsadm enable /network/nfs/server to turn it online.

Create a directory to mount the shared folder on the server

mkdir nfs_share
chmod 700 nfs_share

For a temporary mount of the shared folder use:

mount –F nfs –o rw 192.168.0.200:/nfs_share nfs_share
  • -F is for the filesystem
  • -o is options
  • You can use the hostname or IP address of the NFS server, depending on if you have DNS setup or not, the IP address will always work though. So you’re specifying the share on the server and then where you want to mount that share on your own system.

For a permanent fix, open /etc/vfstab with vi and add this as a new line at the end of the file.

192.168.0.200:/nfs_share - /nfs_share nfs – yes rw

You should then be able to write files to the directory from both the NFS server and the client.

No comments:

Post a Comment

 
Google Analytics Alternative