ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Linux: Mounting an NFS Share

    IT Discussion
    linux nfs fedora centos filesystem sam linux administration sam linux desktop administration system administration scott alan miller
    5
    16
    3.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      If you followed my last example for creating a Simple NFS File Server and Share, we can now mount that share to another machine on our network. To get started, we need the IP address of the NFS Server that we will be mounting the share from (assuming that you are following my examples, this is the IP address of the server from the previous example.)

      We can start my listing all shares available from the NFS server. For our example, we will assume that the NFS server's IP address is 192.168.2.2. Make sure to always substitute your server's IP address.

      showmount -e 192.168.2.2

      This should show us the share that we created in the other example. If not, check your file server setup, make sure that you can ping the server, etc.

      Now, like with any filesystem, in order to use it we need a place to mount it. To make things quick and simple, there is a portion of the file hierarchy designated for this under /mnt. But you could mount anywhere that makes sense. A very common location would be something like /data. In our case, we will make a new spot at /mnt/nfs1

      mkdir /mnt/nfs1
      

      Now we can manually mount the share to this new location with the mount command. Other than a small extra amount of detail to tell the local system where the NFS share is located, nothing special is needed. The mount command will even detect the use of NFS automatically for us, so no need to speficy the filesystem in question.

      mount 192.168.2.2:/var/nfs_share1 /mnt/nfs1
      

      That is it. You should be able to "cd /mnt/nfs1" and create, read, modify files or whatever. You can view details about this mount point in the usual ways with things like the mount, df, and similar commands.

      Configure NFS Share to Mount at Boot Automatically

      Like other filesystems, we can make an NFS share be mounted automatically when our system boots. To do this, we add it to the /etc/fstab file where our other mounts are specified.

      vi /etc/fstab
      

      Navigate to the bottom of the file and for our mount point example, just add this line:

      192.168.2.2:/var/nfs_share1 /mnt/nfs1 nfs rw,sync,hard,intr 0 0
      

      Now you can reboot to verify that it mounts and is available after a system restart.


      Part of a series on Linux Systems Administration by Scott Alan Miller

      1 Reply Last reply Reply Quote 2
      • JaredBuschJ
        JaredBusch
        last edited by

        I have always wished that the mount command had to switch to put the damn thing Into fstab.

        scottalanmillerS 1 Reply Last reply Reply Quote 2
        • scottalanmillerS
          scottalanmiller @JaredBusch
          last edited by

          @JaredBusch said in Linux: Mounting an NFS Share:

          I have always wished that the mount command had to switch to put the damn thing Into fstab.

          You mean like --perm and it just appended into fstab? That would rock.

          JaredBuschJ 1 Reply Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch @scottalanmiller
            last edited by

            @scottalanmiller said in Linux: Mounting an NFS Share:

            @JaredBusch said in Linux: Mounting an NFS Share:

            I have always wished that the mount command had to switch to put the damn thing Into fstab.

            You mean like --perm and it just appended into fstab? That would rock.

            Yeah pretty much anything like that

            1 Reply Last reply Reply Quote 0
            • AdamFA
              AdamF
              last edited by

              Can you explain why if I just mount an NFS share, using the command below, I can get a data transfer/throughput speed of approx 300 MB/s

              mount 192.168.2.2:/var/nfs_share1 /mnt/nfs1
              

              BUT,

              If I put an entry in fstab, it dramatically slows the transfer to about 35-40 MB/s

              192.168.2.2:/var/nfs_share1 /mnt/nfs1 nfs rw,sync,hard,intr 0 0
              

              What causes that?

              scottalanmillerS 1 Reply Last reply Reply Quote 1
              • scottalanmillerS
                scottalanmiller @AdamF
                last edited by

                @fuznutz04 said in Linux: Mounting an NFS Share:

                Can you explain why if I just mount an NFS share, using the command below, I can get a data transfer/throughput speed of approx 300 MB/s

                mount 192.168.2.2:/var/nfs_share1 /mnt/nfs1
                

                BUT,

                If I put an entry in fstab, it dramatically slows the transfer to about 35-40 MB/s

                192.168.2.2:/var/nfs_share1 /mnt/nfs1 nfs rw,sync,hard,intr 0 0
                

                What causes that?

                sync

                1 Reply Last reply Reply Quote 0
                • scottalanmillerS
                  scottalanmiller
                  last edited by

                  "The default export behavior for both NFS Version 2 and Version 3 protocols, used by exportfs in nfs-utils versions prior to nfs-utils-1.0.1 is "asynchronous". This default permits the server to reply to client requests as soon as it has processed the request and handed it off to the local file system, without waiting for the data to be written to stable storage. This is indicated by the async option denoted in the server's export list. It yields better performance at the cost of possible data corruption if the server reboots while still holding unwritten data and/or metadata in its caches. This possible data corruption is not detectable at the time of occurrence, since the async option instructs the server to lie to the client, telling the client that all data has indeed been written to the stable storage, regardless of the protocol used."

                  http://nfs.sourceforge.net/nfs-howto/ar01s05.html

                  1 Reply Last reply Reply Quote 0
                  • scottalanmillerS
                    scottalanmiller
                    last edited by

                    So when you mount with the mount command without specifying, you get async. When you put it into fstab, you manually overrode the async to go with sync. So a major change.

                    K AdamFA 2 Replies Last reply Reply Quote 0
                    • K
                      krisleslie @scottalanmiller
                      last edited by

                      @scottalanmiller are the nfs shares faster than Windows SMB shares?

                      scottalanmillerS 1 Reply Last reply Reply Quote 0
                      • AdamFA
                        AdamF @scottalanmiller
                        last edited by

                        @scottalanmiller so safer, but slower essentially.

                        DustinB3403D scottalanmillerS 2 Replies Last reply Reply Quote 0
                        • DustinB3403D
                          DustinB3403 @AdamF
                          last edited by

                          @fuznutz04 said in Linux: Mounting an NFS Share:

                          @scottalanmiller so safer, but slower essentially.

                          Slower usually is safer.

                          1 Reply Last reply Reply Quote 0
                          • scottalanmillerS
                            scottalanmiller @krisleslie
                            last edited by

                            @krisleslie said in Linux: Mounting an NFS Share:

                            @scottalanmiller are the nfs shares faster than Windows SMB shares?

                            NFS is generally faster than SMB. SMB is traditionally super slow, NFS is screaming fast. SMB has improved over time, but NFS typically beats it.

                            1 Reply Last reply Reply Quote 1
                            • scottalanmillerS
                              scottalanmiller @AdamF
                              last edited by

                              @fuznutz04 said in Linux: Mounting an NFS Share:

                              @scottalanmiller so safer, but slower essentially.

                              Sync is safer for writes, but yeah, way slower.

                              AdamFA 1 Reply Last reply Reply Quote 0
                              • AdamFA
                                AdamF @scottalanmiller
                                last edited by

                                @scottalanmiller Do you typically use the Sync then as a best practice, even though it is much slower to ensure there is no corruption?

                                scottalanmillerS 1 Reply Last reply Reply Quote 0
                                • scottalanmillerS
                                  scottalanmiller @AdamF
                                  last edited by

                                  @fuznutz04 said in Linux: Mounting an NFS Share:

                                  @scottalanmiller Do you typically use the Sync then as a best practice, even though it is much slower to ensure there is no corruption?

                                  Totally depends on the need. A database, hell yeah sync that. A general document file server? Nah, async is fine.

                                  AdamFA 1 Reply Last reply Reply Quote 1
                                  • AdamFA
                                    AdamF @scottalanmiller
                                    last edited by

                                    @scottalanmiller Sounds solid. The speed difference is dramatic. Thanks.

                                    1 Reply Last reply Reply Quote 1
                                    • scottalanmillerS scottalanmiller referenced this topic on
                                    • 1 / 1
                                    • First post
                                      Last post