Open-E Knowledgebase
Search:     Advanced search

How can I mount NFS shares in the linux console?

Article ID: 88
Last updated: 07 Oct, 2008
Views: 10166
How can I mount NFS shares in the linux console? Rating: 7.2500 / 10
Votes: 4
Posted: 28 Sep, 2008
by:
Updated: 07 Oct, 2008
by:
1. Log in as root in your linux server with the command "sudo -i"
2. Create a local mounting directory, e.g., /mnt/my-share. Use this command syntax:
   "mkdir /mnt/my-share"
3. Go to the GUI:  CONFIGURATION -> NAS settings -> NFS settings 
   and mark the checkbox "Use NFS".
4. Go to CONFIGURATION -> NAS resources -> Shares and select a share to be accessed 
   via NFS.
   Select the option "NFS share access".
5. Go to your linux console and issue the following command:
   mount -t nfs 192.168.1.2:/your-nfs-share-on-dss/mnt/my-share
   You should now be able to browse files on NFS using the local directory /mnt/my-share.
 
Explanation:
 
Option "-t" means "file system type". This lets the system know which file system 
you want to mount.  If you don't type "-t", the system will attempt to mount EXT3, the default 
file system in linux.  If the system does not support NFS, you need to install a packet called 
"nfs-common".  Here are root command examples from the various Linux flavors:

On Red Hat/Fedora/CentOS: yum install nfs-common
On Debian/Ubuntu: apt-get install nfs-common
On Mandriva urpmi nfs-common
On Gentoo emerge nfs-common

The command syntax depends on the system installer.
You can specify here any other file system, such as EXT3 or EXT4.
Below is sample code to automate mounting (for Debian/Ubuntu).
Save the code as "mounting.sh" and run this command code from the root account:
sh /path/to/script/mounting.sh


#!/bin/bash
# Author: Open-E suport team

ls /etc/init.d | grep nfs-common >>/dev/null
	returncode=$?
if [ "$returncode" = "0" ]; then
	echo "Package \"nfs-common\" is installed"
	echo "Please specify local mounting point without full path e.g. \"my-share\""
	read directory
if [ "`ls /mnt | grep $directory`" ]; then
	echo "Directory already exist"
	echo "Please specify NFS server address with resource e.g. 192.168.1.2:/nfs"
	read resource
	mount -t nfs $resource /mnt/$directory
	echo "You are mounted"
else
	mkdir /mnt/$directory
	echo "Directory \"/mnt/$directory\" successful created"
	echo "Please specify NFS server address with resource e.g. 192.168.1.2:/nfs"
	read resource
	mount -t nfs $resource /mnt/$directory
	echo "You are mounted"
fi
else
	echo "Package \"nfs-common\" is not installed..."
	sleep 1
	echo "Do you want to install nfs-common package? usage: [y/n]"
	read installyesorno
	if [ "$installyesorno" = "y" ]; then
	"`apt-get install nfs-common`"
	echo "Please specify local mounting point without full path e.g. \"my-share\""
	read directory
if [ "`ls /mnt | grep $directory`" ]; then
	echo "Directory already exist"
else
	mkdir /mnt/$directory
	echo "Directory \"/mnt/$directory\" successful created"
	echo "Please specify NFS server address with resource e.g. 192.168.1.2:/nfs"
	read resource
	mount -t nfs $resource /mnt/$directory
	echo "You are mounted"
fi
	else
	echo "Operation aborted"
fi
	exit
fi

This article was:   Excellent | Very Good | Good | Fair | Poor
External links
Monut - manual

Prev   Next
Where is the information about shares stored?     Will my Logical Volumes still be usable when I convert my NAS...

The Knowledge base is managed by Open-E data storage software company.
RSS