how to... nfs

If you are new to Linux or new to Sabayon Linux and just not sure where to post, here ya go. Post without fear of being told to RTFM :-)

Moderator: Moderators

how to... nfs

Postby hor410 » Sun Nov 10, 2013 21:11

Sorry my english...

I have problem with configure nfs in sabayon (daily xfce).

I am install nfs
Code: Select all
equo install nfs-utils
and configure
Code: Select all
/etc/exports
:

Code: Select all
/mnt/dat 10.0.0.2/40(rw)
in server (desktop pc)

In client (laptop) I am install nfs-utils too. But when mount:
Code: Select all
mount -t nfs 10.0.0.3:/mnt/dat /mnt/dat
attempt to error message:

Code: Select all
mount.nfs: Connection timed out.


Please anyone know what is the problem?
hor410
Baby Hen
 
Posts: 1
Joined: Sun Nov 10, 2013 20:49

Re: how to... nfs

Postby heindsight » Tue Nov 12, 2013 13:20

It looks like the nfs server daemon is not running on your desktop pc.
How to fix this will depend on whether you're running openrc or systemd. If you're not sure which you're using do:
Code: Select all
eselect init list

Look for the * in the output, if it's next to the sysvinit line then you're using openrc, if it's by the systemd line then you're running systemd.

If you're running systemd you need to start the rpc-mountd service (that will pull in everything you need to run an nfs server). As root, do the following:
Code: Select all
systemctl start rpc-mountd

If you want the nfs server to start automatically at boot, you need to enable the service (as root):
Code: Select all
systemctl enable rpc-mountd


For openrc I'm not 100% sure (I'm on systemd so I can't test it), but I think you just need to start the nfs service. As root do:
Code: Select all
rc-service nfs start

If you want the nfs server to start automatically at boot, you need to add nfs to the default runlevel (as root):
Code: Select all
rc-update add nfs default
User avatar
heindsight
Baby Hen
 
Posts: 17
Joined: Wed Jun 19, 2013 16:46
Location: London

Re: how to... nfs

Postby linuxfluesterer » Tue Nov 12, 2013 13:25

Hard topic...
So, here some questions:
- Did you run
Code: Select all
systemctl start nfsd.service
(temporary use) or
Code: Select all
systemctl enable nfsd.service
(always start on boot)?
Next thing is:
- Did you bind your export directories?
- Then, did you run rpc.mountd on your server? This seems to be forgotten often!
On your server you can check function of nfs server is fine with:
Code: Select all
showmount -e
Export list for mylaptop:
/srv/nfs4/sda3 192.168.0.0/16
/srv/nfs4      192.168.0.0/16

On your client, you must also run:
Code: Select all
systemctl start nfsd.service
rpc.mountd


Hope, that will help you.

-Linuxfluesterer (I love KDE ...)
I really hope, that by the Brexit (poor Britain), TTIP will be finally prevented. But don't get tired to talk to your local politician to open eyes for danger to democracy because of TTIP
User avatar
linuxfluesterer
Old Dear Hen
 
Posts: 725
Joined: Thu Sep 20, 2012 19:47
Location: Germany

Re: how to... nfs

Postby heindsight » Tue Nov 12, 2013 13:44

hor410 wrote:
Code: Select all
/mnt/dat 10.0.0.2/40(rw)
in server (desktop pc)


Oh, by the way, I just noticed the netmask in your /etc/exports looks wrong. The
Code: Select all
/40
at the end of your network address indicates a 40 bit network prefix but IPv4 addresses are only 32 bits long therefore your network prefix should be less than 32. I don't think that's what's causing your current problems, but it will cause problems later. I suggest changing it to:
Code: Select all
/mnt/dat 10.0.0.0/24(rw)
User avatar
heindsight
Baby Hen
 
Posts: 17
Joined: Wed Jun 19, 2013 16:46
Location: London

Re: how to... nfs

Postby grimly64 » Sun Jan 19, 2014 7:19

Had this running a few years back, lost my notes. This is for everyone who needs help. (like me)
I butchered this, probably the reason I can't get it working

Please correct what is wrong or missing.

Step One: Install NFS

from Root terminal
Equo search NFS
Install nfs-utils

Refer to linuxfluesterer's and heindsight's comments about
sysvint (openrc) the old way I guess and systemd, the new way I guess , on how to proceed.

I only use External Hard Drives (usb) with NFS, and my External Hard Drive is called HDTwo.

I'm using the old way, for now, just read the comments on this thread to learn there was and how to make the systemd to change.

What I think I learned from this is for Fstab,....
Old way: //192.168.1.10:/HDTwo /media/HDTwo
New way: //192.168.1.10:/HDTwo /run/media/HDTwo

(is the Portmap needed? Anything else needed?)

Step Two: Identify your IP address
Code: Select all
ifconfig

    enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
    inet6 fe80::224:1dff:fe27:e57d prefixlen 64 scopeid 0x20<link>
    ether 00:24:1d:27:e5:7d txqueuelen 1000 (Ethernet)
    RX packets 1220714 bytes 1072173442 (1022.5 MiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 964253 bytes 169997962 (162.1 MiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Files that need to be Edited "exports" "fstab" "hosts.allow"

To edit files as Root
Alt+F2 and then type
Code: Select all
kdesu dolphin


Step Three: EXPORTS
/run/media/devos/HDTwo 192.168.1.10(rw,fsid=0,insecure,sync,no_root_squash,subtree_check)

Now my PC is called devos, do I need that in there or just /run/media/HDTwo? Is fsid=0 needed or is that dependent on if using nsf3 or nsf4?

Speaking of nsf3 and nsf4, which one to use, and how to make sure that version is running, if only using FSTAB?

Step Four: FSTAB

    //192.168,1.10:/HDTwo /run/media/HDTwo nfs nfsvers=3,rw,noauto,user 0 0


I am messing up somewhere, it is probably something simple and starring me in the face. Cause this is not working.
the WDTV cannot see the NFS and the Rasberry PI with XBMC cannot see the NFS either.

Step Five: HOST.ALLOW
Put the IP address of who can see this NFS on you local network
For Example: I've got WD Live (SMP) and a Rasberry PI with XBMC on it.
I'm probably wrong but think the IP address of these two devices need to be on the host.allow.
There is also host.deny to put IP addresses of any IP address you do not want to have access to the NFS.

Step Six: INIT.D

Code: Select all
exportfs -rv

When you make a change to the "exports" file.
(not sure what dash codes to use, see different variations when searching google)
Code: Select all
/etc/init.d/nfs restart

To get the NFS to restart
(search google for other things that can be done, but I mostly just use the retart)

Summary: I got some of the things, but bottom line, it's not working.
Used to have it working, and when it was, I remember that Ubuntu's way had way more things that had to be done, but Sabayon only needed a few things.

Old way before systemd:
/home would eventually get to the external hard drive through /media.
New way with systemd:
/home does not work
/root/run/media/devos/HDTwo
is the acutal path, (devos is PC name) but thin, not sure, only need /run/media/HDTwo. but I am sooo not sure.

Read this:

    swanson
    Member
    From: Sweden
    Registered: 2011-02-05
    Posts: 742

    Re: Systemd nfs client mount share ???

    Still mounting from fstab, but it works ok for now. Still wish I could understand native systemd mounting of nfs shares.

    All else is up and running nicely! e4rat works ok, did a new 'collect' and it's really nice!
    Edited fstab and disabled the dvd/cdrom line and now udisks mounts ok. Had a little problem with console-kit but managed to edit the slim.service to start the right slim version (svn in my local/bin).
    Learned that systemctl rescue works as 'telinit 1' and that 'systemctl isolate runlevel5.target' should take you back to X.

    But one big lesson never mentioned anywhere is that systemd takes over /media as tmpfs. For all those of us who in recent years have learned to use /media as mounting dir instead of /mnt, this is a problem. But it is fixable.

    Offline
    #12 2012-04-17 17:49:50

    tomegun
    Developer
    From: France
    Registered: 2010-05-28
    Posts: 661

    Re: Systemd nfs client mount share ???

    systemd will leave /media alone as of the next release (/media was meant to be used by udisks and similar tools, which have now moved to /run/media).

    There is no benefit of using mount units over fstab, but it's a bit strange if it does not work for you (it should be the same). The main use of the mount units is that they can be shipped by packages (such as systemd itself), and fstab should be only for the admin.
from https://bbs.archlinux.org/viewtopic.php?pid=1089008

this is where I got the run/media info from.

Again, I butchered this, but hopefully the end resul, wil be a HOW TO: in the Wiki.
grimly64
Simple Hen
 
Posts: 43
Joined: Sun Apr 17, 2011 2:38

Re: how to... nfs

Postby grimly64 » Wed Jan 22, 2014 5:55

What I think I've learned, so far, the Exports would have the IP address of where I want to share.
Example WD TV, get the IP address of that and put that into Exports.
grimly64
Simple Hen
 
Posts: 43
Joined: Sun Apr 17, 2011 2:38

Re: how to... nfs

Postby grimly64 » Wed Jan 22, 2014 6:09

Format for FSTAB

server:/remote/export /local/directory nfs options 0 0

...ok so with Sabayon, external hard drives used to be found in /home/media, that is no longer the case.

Now find the external hard drives under /run/media/(pc name)/(external hard drive name)

(IP address of the PC) ...............(local directory...this part seems wrong).......(do want RW).......(this part is right)
//192.168,1.10:/run/media/devos/HDTwo...media/HDTwo.............nfs..........nfsvers=3,rw,noauto,user 0 0
........................(path to ext. HD)..................................(file type)....(NFS version)...(nos sure on noauto or user)
grimly64
Simple Hen
 
Posts: 43
Joined: Sun Apr 17, 2011 2:38

Re: how to... nfs

Postby linuxfluesterer » Wed Jan 22, 2014 12:05

Hallo repliers here.
Did you recognise, that our task opener hor410 has no more replied to us? No feedback? Strange, I think.
Exactly, I use NFS4 from time to time, and I get it work. In a German computer magazine (c't) a complete description was given, how to use NFS4. This was a long time ago. A very important point was the binding to the directories to be exported. I have adopted the procedure by starting an nfsd.service on both the server and the client also and calling rpc.mountd manually. The command showmount -e shows exported nfs directories on the server.
Now, that's my description for Sabayon NFS4 (server and client) in root consoles here:
On your server do this:
1. Create directories for NFS4 export (here an example):
Code: Select all
mkdir /srv
mkdir /srv/nfs4
mkdir /srv/nfs4/data
# you could create more directories here

2. bind your directories, you want to export with the new directories, e.g. a mounted device named data on /mnt:
Code: Select all
mount --bind /mnt/data /srv/nfs4/data

3. Create (adopt) the /etc/exports file, e.g. here:
Code: Select all
# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/srv/nfs4          192.168.0.0/16(rw,async,fsid=0,no_subtree_check,all_squash)
/srv/nfs4/data     192.168.0.0/16(rw,nohide,insecure,async,no_subtree_check)

4. Start nfsd.service under systemd with:
Code: Select all
systemctl start nfsd.service

5. Execute:
Code: Select all
rpc.mountd

6. You may check with command:
Code: Select all
showmount -e
Export list for SSD1-K312-KDE412:
/srv/nfs4/data 192.168.0.0/16
/srv/nfs4      192.168.0.0/16

7. Check your (server) IP address with:
Code: Select all
ipconfig
(e.g. 192.168.1.99)

Now, prepare the client (it's much easier), also on a root console:
1.Open root console, create your mounting directory, e.g.:
Code: Select all
mkdir /home/username/nfs4

2. Start nfsd.service also (as same on server) with:
Code: Select all
systemctl start nfsd.service

2a. Maybe you'll need to execute command:
Code: Select all
rpc.mountd

3.Execute command with your server IP address.
Code: Select all
mount -t nfs 192.168.1.99:/srv/nfs4 /home/username/nfs4/

Now your client should be connected with your server via NFS4 and mounted in /home/username/nfs4.
I know, it's all manual, but that doesn't matter at this moment. There are some ways to do with systemd to autostart it. This may be discussed later.

-Linuxfluesterer (I love KDE ...)
I really hope, that by the Brexit (poor Britain), TTIP will be finally prevented. But don't get tired to talk to your local politician to open eyes for danger to democracy because of TTIP
User avatar
linuxfluesterer
Old Dear Hen
 
Posts: 725
Joined: Thu Sep 20, 2012 19:47
Location: Germany

Re: how to... nfs

Postby grimly64 » Wed Jan 22, 2014 23:27

can't get the NFS to broadcast. want the HDTwo and HDFive on the NFS and FYI not using systemd
Code: Select all
 Devos-PC devos #  df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/vg_devospc-lv_root   50G   17G   31G  35% /
none                            3.9G  1.3M  3.9G   1% /run
none                            3.9G   80K  3.9G   1% /dev/shm
udev                             10M     0   10M   0% /dev
cgroup_root                      10M     0   10M   0% /sys/fs/cgroup
/dev/sda1                       477M  208M  240M  47% /boot
/dev/mapper/vg_devospc-lv_home   58G   19G   37G  35% /home
tmpfs                           3.9G   80K  3.9G   1% /dev/shm
/dev/sdd1                       931G  848G   84G  92% /run/media/devos/HDTwo
/dev/sdc1                       1.9T  1.8T   60G  97% /run/media/devos/HDFive


Code: Select all
Devos-PC devos # netstat -tn | egrep '2049|Active|Pro'
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State 


Code: Select all
Devos-PC devos # /etc/init.d/nfsmount start
 * Starting NFS sm-notify ...                                                                        [ ok ]
 * Mounting NFS filesystems ...
mount.nfs: mount point /media/HDTwo does not exist 


Code: Select all
In FSTAB
nfs://192.168,1.10:/run/media/devos/HDTwo   /media/HDTwo   nfs    rw,_netdev,auto   0 0


Code: Select all
In EXPORTS
//run/media/devos/HDTwo 192.168.1.11/255.255.0.0(rw,no_subtree_check,async,insecure,no_root_squash,fsid=0)


in HOST.CONF
Code: Select all
# /etc/host.conf:
# $Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/host.conf,v 1.1 2006/09/29 23:52:23 vapier Exp $

# The  file /etc/host.conf contains configuration information specific to
# the resolver library.  It should contain one configuration keyword  per
# line,  followed by appropriate configuration information.  The keywords
# recognized are order, trim, mdns, multi, nospoof, spoof, and reorder.



# This keyword specifies how host lookups are to be performed. It
# should be followed by one or more lookup methods, separated by
# commas.  Valid methods are bind, hosts, and nis.
#
order, hosts, bind,


# Valid  values are on and off.  If set to on, the resolv+ library
# will return all valid addresses for a host that appears  in  the
# /etc/hosts  file,  instead  of  only  the first.  This is off by
# default, as it may cause a substantial performance loss at sites
# with large hosts files.
#
multi on



In HOST.ALLOW
Code: Select all
All: All

portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL


In etc/conf.d/nfs
Code: Select all
# /etc/conf.d/nfs

# If you wish to set the port numbers for lockd,
# please see /etc/sysctl.conf

# Optional services to include in default `/etc/init.d/nfs start`
# For NFSv4 users, you'll want to add "rpc.idmapd" here.
NFS_NEEDED_SERVICES="rpc.idmapd"

# Number of servers to be started up by default
OPTS_RPC_NFSD="8"

# Options to pass to rpc.mountd
# ex. OPTS_RPC_MOUNTD="-p 32767"
OPTS_RPC_MOUNTD="-V 4 -V 3 -N 2" # supporte la version 3 et 4, mais pas la version 2

# Options to pass to rpc.statd
# ex. OPTS_RPC_STATD="-p 32765 -o 32766"
OPTS_RPC_STATD=""

# Options to pass to rpc.idmapd
OPTS_RPC_IDMAPD=""

# Options to pass to rpc.gssd
OPTS_RPC_GSSD=""

# Options to pass to rpc.svcgssd
OPTS_RPC_SVCGSSD=""

# Options to pass to rpc.rquotad (requires sys-fs/quota)
OPTS_RPC_RQUOTAD=""

# Timeout (in seconds) for exportfs
EXPORTFS_TIMEOUT=80

# Options to set in the nfsd filesystem (/proc/fs/nfsd/).
# Format is <option>=<value>.  Multiple options are allowed.
#OPTS_NFSD="nfsv4leasetime=30 max_block_size=4096"



In summary: don't understand why in FSTAB, it is told exactly where the external hard drive is, ...nfs can't find it.
Also, on my network, no device can even see the IP addresss of the NFS,
grimly64
Simple Hen
 
Posts: 43
Joined: Sun Apr 17, 2011 2:38

Re: how to... nfs

Postby grimly64 » Mon Jan 27, 2014 2:41

Update, reinstalled Sabayon, just to get the systemd working, since it will be mandatory at some point.
I use KDE 64bit.

Not at home, but tried the
Code: Select all
systemctl start rpc-mountd


and get error, it basically said, (you don't have this) and yes nfs-utlis is installed.
grimly64
Simple Hen
 
Posts: 43
Joined: Sun Apr 17, 2011 2:38

Next

Return to Beginners|Newbies Area

Who is online

Users browsing this forum: No registered users and 2 guests