Announcement

Collapse
No announcement yet.

Help with NFS server and client

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [CONFIGURATION] Help with NFS server and client

    So with the issues with samba again, and I am sure I've raised this before but I cannot find it, If I wanted to go down the NFS road, which is the server and which is the client
    I have a HTPC with all my music, pics, vids, etc, and my Main PC that I am using now, to surf the web, watch youtube, send angry letters to members of parliament. You know, the usage.

    Would this be the thinking. All of the install instruction have how to install, but not which to pick. I am assuming they think you have an actual server, server that your using.
    Do I need to be using a server, server to use NFS?

    Once Again, Thanks to the Kubuntu Forums community

    #2
    https://help.ubuntu.com/community/SettingUpNFSHowTo

    The 'server' is a separate Ubuntu PC. The 'client' is your user PC. Two PCs.
    Using Kubuntu Linux since March 23, 2007
    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

    Comment


      #3
      It's only a file location difference. The "server" hosts the files and "shares" the files with any number of "clients."
      So in your case, the NFS server software setup would go on the HTPC and your Main PC is the client. From your Main PC client, you will be able to retrieve or send any number of files from/to the server.
      If you want to be able to send files from the HTPC to the Main PC, then the Main PC would also need to be a "server". This would assume you also have a keyboard/mouse and you use the HTPC directly sometimes.

      Any computer on your network can be server or client or both. Server = machine that holds the files and shares them. Client = machine that can access files on a server.

      Packages needed:
      Server: nfs-common, nfs-kernel-server
      Client: nfs-common

      I believe both will pull in 1 or 2 depends.

      Your "server" will have the shared folders set up in /etc/exports and the "clients" will mount the NFS shares somewhere.

      Access control requirements will depend on your use-case. If you are the only user and both computers use the default ID:Group of 1000:1000 then you shouldn't have to do anything else.
      Last edited by oshunluvr; Sep 22, 2022, 11:21 AM.

      Please Read Me

      Comment


        #4
        Originally posted by oshunluvr View Post
        It's only a file location difference. The "server" hosts the files and "shares" the files with any number of "clients."
        So in your case, the NFS server software setup would go on the HTPC and your Main PC is the client. From your Main PC client, you will be able to retrieve or send any number of files from/to the server.
        If you want to be able to send files from the HTPC to the Main PC, then the Main PC would also need to be a "server". This would assume you also have a keyboard/mouse and you use the HTPC directly sometimes.

        Any computer on your network can be server or client or both. Server = machine that holds the files and shares them. Client = machine that can access files on a server.

        Packages needed:
        Server: nfs-common, nfs-kernel-server
        Client: nfs-common

        I believe both will pull in 1 or 2 depends.

        Your "server" will have the shared folders set up in /etc/exports and the "clients" will mount the NFS shares somewhere.

        Access control requirements will depend on your use-case. If you are the only user and both computers use the default ID:Group of 1000:1000 then you shouldn't have to do anything else.
        Sounds easy your explanation.
        NOW. The real question, is sometimes I want to send files from HTPC (NFS = server) to Main (NFS = client). Would I be able to do that from the main, "COPY" files from a HTPC share to a folder on MAIN?
        Q2. Can you run both on the same machine. Can MAIN be both server(ing) and Client(ing) at the same time, or is this going to cause system conflicts?

        Comment


          #5
          Originally posted by CharlieDaves View Post
          Sounds easy your explanation.
          NOW. The real question, is sometimes I want to send files from HTPC (NFS = server) to Main (NFS = client). Would I be able to do that from the main, "COPY" files from a HTPC share to a folder on MAIN?
          Q2. Can you run both on the same machine. Can MAIN be both server(ing) and Client(ing) at the same time, or is this going to cause system conflicts?
          Both can easily be server and client without conflict, but that seems unnecessary with only two computers. Here's how it works:

          HTPC (server) has a folder (with subfolders) or a list of folders that it "exports" (shares).
          MAIN (client) mounts these shared folder(s) at a local location.
          All files in the shared folders are accessible on both computers simultaneously.

          So if you have files on HTPC that you want to access on MAIN, you just put them in the shared folder(s) on HTPC and they are instantly available on MAIN. Either computer can edit, delete, whatever. You wouldn't need to SEND it from HTPC because it would already be available on MAIN.

          My use is similar to what you describe. I have a physical server that runs Plex, holds backups, and a few other things. All the files that I want to access are on the server in a group of media folders - Movies, TV Shows, Music, Pictures, etc. The root folder of these (/mnt/pool) is exported as an NFS share. On my desktop PC, my Laptop, and my tablet, I mount the NFS share to the "Public" folder in my user home. When I look in /home/myuser/Public on any of my other computers, I see the folders on the server - Movies, TV Shows, Music, Pictures, etc. So let's say I copy Pictures from my camera on to my laptop. I move them to the Pictures folder under Public and then I can view, edit, or delete them from any of the other computers.

          Another use example: I also use my server to download torrent files. I use Transmission (a torrent client) remotely via a browser interface from any of my computers to access Transmission on the server - add, start, stop torrents, etc. I have Transmission set up to use a Downloads folder that is in the exported folder (/mnt//pool). This means my server uses it's bandwidth to service the torrents but when a download is complete the file is available everywhere.

          If you install NFS server and Webmin on HTPC and set up a SSH connection to HTPC from MAIN, you can literally do almost anything you need to on HTPC without leaving your MAIN keyboard and mouse.

          Please Read Me

          Comment


            #6
            Ok OK . You've convinced me. As soon as this ZFS/ZPOOL data problem is accounted for, I'll do this instead.

            Comment


              #7
              In some instructions https://www.digitalocean.com/communi...n-ubuntu-20-04 & https://help.ubuntu.com/community/SettingUpNFSHowTo & https://www.howtoforge.com/how-to-in...n-ubuntu-2004/ It refers to CHOWN nobody:nogroup.
              Are they actually serious about this or should it be primary user, Me ?

              Comment


                #8
                Now that I've had some success with NFS setup, I just want confirmation on the correct usage
                in /etc/exports
                Is this where I put THIS machine's shares?
                Or all shares across the network?

                in /etc/fstab
                this is where I mount (where I want too) the shares from the /etc/EXPORTS file ? yes no?

                Q.
                Where are users stored? How to I add a username1 from PC1 and user2 from pc2 to allowed access to a share?

                Comment


                  #9
                  Originally posted by oshunluvr View Post
                  Your "server" will have the shared folders set up in /etc/exports and the "clients" will mount the NFS shares somewhere.

                  Access control requirements will depend on your use-case. If you are the only user and both computers use the default ID:Group of 1000:1000 then you shouldn't have to do anything else.
                  What do you mean group ID ?? is this the chmod command, or something else. Are you able to point me (this forum) to some EXPLAIN it websites please ??

                  As I wrote just before, and you mentioned, the "Server shares are in /etc/exports"
                  Does that mean (and it's the only thing I've found) is the Client to find the shares you place a reference in /etc/fstab. To me this seams like overkill. But I haven't read of any other method. This also might explain why it takes forever for the PC to boot. 6-10 times longer than normal

                  Comment


                    #10
                    Sorry, I was out of the country for the last 11 days. I'm surprised no one else picked this up. anyway...

                    UID:GID are set using "chown". "chmod" is to change permissions. The default UID:GID for *buntus is 1000:1000.

                    Group and File ownership can be handled several ways. If it just YOU and no others using these computers, you really shouldn't have to do anything. Since you're the primary user on both computers, owner:group will be the same unless you've modified it from the default. Again, this goes back to your use case. In my case, my system is usable by the family so I wanted some generic settings so everyone can do whatever - save, edit, delete, etc. In a business environment, it would have to be more secure.

                    My solution was to create a group called "shared" and to set all the folders with "nobody" as the owner and then set the GUID execute bit to "s". See " man chmod" for info on it, but basically the group setting on all the folders is "rws" instead of "rwx" and this automatically changes the group of any file or folder to "shared". Obviously, all my users are members of the "shared" group. Then I wanted to manage file ownership. If left alone, every user would have ownership of certain files but I didn't want that. I solved it with a mount option that forces user to "nobody" and group to "shared" when any file transaction is made. The result is all files in the shared folders and files are owned by "nobody" and belong to the "shared" group.

                    The "exports" file goes on the server. Here's my /etc/exports on the NFS server:
                    Code:
                    # /etc/exports: the access control list for filesystems which may be exported
                    # to NFS clients. See exports(5).
                    #
                    /exports 192.168.1.0/24(rw,fsid=0,crossmnt,no_subtree_check,sync,secure,nohide,all_squash,anonuid=65534,anongid=560)
                    /private 192.168.1.0/24(rw,fsid=1,crossmnt,no_subtree_check,sync,secure,nohide,no_root_squash)
                    Note that "65534" is the UID for "nobody" and "560" is the GID I use for "shared".

                    The first line: /exports, is the shared folders.​ The subfolders are also shared when using NFSv4. The second line: /private is a folder used by individuals to backup their home folders to the server without sharing them with other users.

                    On the client side, these are mounted this way in /etc/fstab:
                    Code:
                    ## Server media exports
                    server:/ /shared nfs nofail,x-systemd.automount,x-systemd-device-timeout=10,_netdev,bg,hard,timeo=28,retrans=5,intr ,noatime,nodiratime 0 0
                    server:/private /mnt/private nfs nofail,x-systemd.automount,x-systemd-device-timeout=10,_netdev,bg,hard,timeo=28,retrans=5,intr ,noatime,nodiratime 0 0

                    Your long boot time is directly related to your mount options in fstab. What you probably want is for your system to boot without delaying for the NFS mounts to be ready. If your home folder is stored on a central server, that would be different but I don;t recommend that for a normal home setup.

                    I suggest reading up on the various mount (/etc/fstab on the client) and export (/etc/exports on the server) options. I re-visit them every couple of years as they have changed over time. I think I'm due for a review now, lol.

                    On thing I've noticed when if I reboot my server while my desktop client is running, some or all of the NFS mounts will give an error message when trying to access them - "stale file handle" - or something similar. The solution is to restart the NFS server (the application, not the computer) and the errors clear up.

                    One EXTREMELY useful thing to do is set up SSH with secure key access on the server. After doing that, then I set up my ssh config on the client pc and use a bash alias to allow me to log into the server PC from Konsole with a single word - "server". Then I have terminal access to the server to run updates, restart NFS, etc.

                    Please Read Me

                    Comment


                      #11
                      Originally posted by oshunluvr View Post
                      Sorry, I was out of the country for the last 11 days. I'm surprised no one else picked this up. anyway...

                      UID:GID are set using "chown". "chmod" is to change permissions. The default UID:GID for *buntus is 1000:1000.
                      Sounds familiar. Every time I user part manager to format a newly purchased HDD, I have to run
                      Code:
                      chown username:username /folder/mountpoint -R
                      . To be honest, it's the only one I use.
                      chmod is for user group and excute permissions. The only time I've used this command is if I've downloaded something to install, and have to +x the file so I may execute it

                      Originally posted by oshunluvr View Post
                      My solution was to create a group called "shared" and to set all the folders with "nobody" as the owner and then set the GUID execute bit to "s". See " man chmod" for info on it, but basically the group setting on all the folders is "rws" instead of "rwx" and this automatically changes the group of any file or folder to "shared". Obviously, all my users are members of the "shared" group. Then I wanted to manage file ownership. If left alone, every user would have ownership of certain files but I didn't want that. I solved it with a mount option that forces user to "nobody" and group to "shared" when any file transaction is made. The result is all files in the shared folders and files are owned by "nobody" and belong to the "shared" group.
                      Ummm, yeah. Okaaaaay - FYI can we stick to GUID UID for the moment. Let me understand this first. Then we can move on to setup shares and sharing (rw,fsid=0,crossmnt,no_subtree_check,sync,secure,n ohide,all_squash,anonuid=65534,anongid=560)
                      Makes little to no sense to me.​
                      AS I want to basically set up a small business type networked PC setup, without any servers, from what I've read, I should create an all-in group (a bit like sambashare with samba) and each user I create is a member of this group.
                      As members of all-in, they would automatically have group access to folders and flles? (yes no)
                      How does this propagate across a small network of computers? Do I have to create the "all-in" group on each PC? ?? .... And somehow each PC knows that accessing a shared (once I figure out setting this up again, with option of either NFS or Samba).
                      Back to the ABANDONED Question https://www.kubuntuforums.net/forum/...es-it-all-work

                      Is there a website to read through that explains this. Not the simple 4 step setups I've been using.

                      Thanks oshunluvr;n666077

                      Comment


                        #12
                        There might be a slight misunderstanding about the word "server". When you say "without any servers" I believe you mean "no PC dedicated to being only a server". The term "server" refers to server software. Regardless of your hardware configuration and whether you use NFS or SAMBA, the only way to share files is by having at least one server running, whether it's a stand-alone machine or simply a machine that's part of the network. I wasn't ever suggesting you needed to dedicate a machine to being only a server machine, just that you must install and set up NFS server - a software application.

                        To the GID - as I tried to explain, I use a group called "shared" and I assign it a GID of 560 when I create it on all the machines on my network. Then exporting with "anongid=560" forces all accessing the shared folders to have membership in the 560 group. In NFS terminology, an "export" is a shared folder or set of folders and their contents. Using SAMBA it would be called a "share". Since the export is assigned the GID of 560, no user that is not a member of that group will be able to access the exported folders and all files added to the server become owned by group 560. This may not be how you want to share files.

                        A direct answer to "As members of all-in, they would automatically have group access to folders and flles? (yes no)" is YES. You also have to mount the exports/shares as well obviously. And again, YES, you would create this "all-in" group on every PC and assign it to every user if you want everyone to share files freely.

                        As far as how to propagate files across a network, the simplest and only way to manage it easily is to have one PC that will always be on when file sharing is occurring and have it running the server. If this is not possible it becomes more difficult. Here's why:

                        Computers A, B, C, and D all on a network together:
                        Setup 1: Computer A has NFS server on it. As long as computer A is running, A, B, C, and D all share files as needed. So if the user of B wants to share a file with C, B simply copies the file to the shared folders (residing on A) and C can access it. Users of A and D can as well.
                        Setup 2: No one computer will always be on, so every computer has to have NFS server running on it. All 4 computers will need to export a folder and all 4 computers will need to mount the other 3 exports. If B wants to share a file with C, they would copy it to the C exported folder, but if they also want to share it with A and D, they have to copy it to those folders also.

                        Another way to look at it is using setup 1 your shared folders look like:

                        A:/shared
                        B:/shared
                        C:/shared
                        D:/shared

                        Using Setup 2 your shared file folders would look like:
                        A: B: C: D:
                        /shared/B /shared/A /shared/A /shared/A
                        /shared/C /shared/C /shared/B /shared/B
                        /shared/D /shared/D /shared/D /shared/C






                        Setup 1 is sharing the files among everyone. Setup 2 allows users to transfer files to other users individually. If by "sharing" files you mean "A user should be able to transfer a file to other users on the network" either Setup 1 or 2 works. If you want "collaboration on files" Setup 2 doesn't work.

                        Setup 1 requires at least one PC be on every day. Setup 2 requires that any file needed to be shared by everyone will have to exist in at least three copies - not very efficient or functional unless this is your intent.

                        This makes no difference if you use NFS or SAMBA or whatever, without a central storage location you cannot share a file beyond 2 users without duplication.

                        Frankly, before you need to worry about how to setup your UID/GID control, you need to figure out your hardware use and specifically how you want to share files.

                        It would be easier to help you if you explained in detail how your network is configured and how you intend to use file sharing.

                        Please Read Me

                        Comment


                          #13
                          Originally posted by oshunluvr View Post
                          There might be a slight misunderstanding about the word "server". When you say "without any servers" I believe you mean "no PC dedicated to being only a server". The term "server" refers to server software. Regardless of your hardware configuration and whether you use NFS or SAMBA, the only way to share files is by having at least one server running, whether it's a stand-alone machine or simply a machine that's part of the network. I wasn't ever suggesting you needed to dedicate a machine to being only a server machine, just that you must install and set up NFS server - a software application.
                          Thanks for that clarification. I assume when reading online guides (kubuntu forums included) that is what they "are" referring to. I actually read for the first time recently, that Samba has a server version and a client version. Never ever read that over the last 5 years

                          Comment


                            #14
                            Originally posted by oshunluvr View Post
                            To the GID - as I tried to explain, I use a group called "shared" and I assign it a GID of 560 when I create it on all the machines on my network. Then exporting with "anongid=560" forces all accessing the shared folders to have membership in the 560 group. In NFS terminology, an "export" is a shared folder or set of folders and their contents. Using SAMBA it would be called a "share". Since the export is assigned the GID of 560, no user that is not a member of that group will be able to access the exported folders and all files added to the server become owned by group 560. This may not be how you want to share files.
                            What's with the number This is the bit that is confusing me.... Really confusing me. Can't a GID = shared ??
                            And why 560?
                            Exporting with "anongid=560". Can I export "sharedgid=560"

                            Anywhere I can read up more about this. Is this "software server and Client" stuff ??

                            Comment


                              #15
                              Originally posted by oshunluvr View Post
                              Since the export is assigned the GID of 560, no user that is not a member of that group will be able to access the exported folders and all files added to the server become owned by group 560. This may not be how you want to share files.

                              A direct answer to "As members of all-in (shared), they would automatically have group access to folders and flles? (yes no)" is YES. You also have to mount the exports/shares as well obviously. And again, YES, you would create this "all-in" group on every PC and assign it to every user if you want everyone to share files freely.
                              Okay. I'll stick with your terminology for the moment All-in = shared.
                              found this https://linuxize.com/post/how-to-cre...oups-in-linux/ and has create group with GID. Yep. I must add the share / GID=560 group on every network pc, and add users whom I want to access this share / GID=560 group to that group. The same as when I create a sambashare, I have to add each user to the sambashare group that "samba created on install"

                              I think I'm starting to understand this, except the number

                              Comment

                              Working...
                              X