Announcement

Collapse
No announcement yet.

Help with NFS server and client

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    thanks to oshunluvr for the write up
    Last edited by CharlieDaves; Nov 02, 2022, 08:11 PM.

    Comment


      #17
      Originally posted by oshunluvr View Post
      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.
      OKAY. You used the phrase "propagate files across a network". Does this mean if I copy a file to Computer B (see below) it will also appear on Computer A, C & D? If I have a similar shared group or user? I ask as this would be handy for backups. I create the backup, and just let it propagate across where I want it. Or is this referencing something else that I don't fully understand?

      Originally posted by oshunluvr View Post
      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.

      ​Now in my case Computer A, is almost always on, BUT I don't really have anything I want to share, and not going to be acing as a "file Storage". One drive maybe. Under setup 1, can computers B,C,D still share with each other, or does everything have to go to Computer A?
      Also for me, Computer B is the "STORAGE" Computer that I want files shared too, 90% of the time. Computer A also has printers. Computer B is only switched on for a few hours a day for most of the time, and I can sort of "take-my-time" to transfer files from computer A or C to computer B.
      Is Setup 1, the better option for me, In Your Humble Opinion?
      Last edited by CharlieDaves; Nov 02, 2022, 08:36 PM.

      Comment


        #18
        NOW the UID/GID

        Since the scare of someone remotely playing with my PC (Mouse moved by itself and data was copied and pasted) as I was looking at the screen, I've decided to create 2 accounts on each PC. An admin account, and a user account. All different names, and different passwords. It's going to annoy me to say the least, as I was happy with one username, and same password on each PC.

        As mentioned my only knowledge of UID/GID from this thread is
        Code:
        chown username:groupname /media/newdrive -R
        The groupname appears to be created automatically when I create the user

        May I assume my analogy of UID/GID is accurate?
        Or is there more to it?

        Comment


          #19
          Originally posted by CharlieDaves View Post

          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 ??
          I picked 560 YEARS ago when I first set this up.

          If you create a new GID, you get whatever number is available on that system starting at 1000.
          If you request a "system" GID, It goes down from 1000 to the next available number. If you request a non-system (user) GID, it goes up from 1000.

          It seemed infinitely confusing if every machine on my network had a different GID for the same named group, so I picked one that was not near any others so that I was sure it would be available everywhere.
          You can pick whatever you want or let the system decide for you. 560 just worked for me. The specific number has no significance, nor does the name you use for the group.

          As far as "anongid=" - that's an export option, not something I made up. "sharedgid=" is obviously not and thus would probably cause your export to fail. "anongid=" means all files received from any client are mapped to that user group.

          In fact, a group exists that isn't really used by *buntus that you could user for this purpose. Group "100" is "users" and afaik, *buntus don't assign it to any users by default. You could use that for your shared group and set it as your "anongid=" group.

          Here's the manpage for NFS exports.Scroll down to the bit about "User ID Mapping."

          The idea is, if you're sharing files all users at a minimum need to have group access. This is one way to do it. If you want to also shared ownership, use "anonuid=" to set file ownership.

          Another way of doing it to reset all the umasks and primary group ids of all your users to 100 on all your systems so everyone has the same group. While this is a common way to set up a Linux system, it is not the default way that *buntus do it so it is infinitely more work IMO.

          Bottom line is:
          1. I picked 560 randomly because it was not in use anywhere
          2. Using the same GID on all your systems makes life easier
          3. I didn't use 100 at the time because I was new to Kubuntu and didn't realize it was an option.
          As far as UID and whether or not you want to set that - there is a case for not force-setting it. Not setting UIDs would allow everyone to know who created a specific file. The downside to this is all users would have to exist on all systems and have uniform UIDs across all the systems. Basically, you would manually add all users and assign each a specific UID so they would be "known". This could be easily done by scripting it and have the advantage of possibly allowing users to log onto more than one system. Again - this is a use-case thing so having a well defined plan of how you want user access and how you want to share files is a must.

          However, unless the user existed on the system reading the file list, UID would only appear as number

          Please Read Me

          Comment


            #20
            Example of the two choices - forcing UID and GID or just forcing GID:

            GID and UID:
            Code:
            -rw-rw-r-- 1 nobody shared 63469 Dec 23 2021 some_file1.pdf
            ​-rw-rw-r-- 1 nobody shared 63469 Dec 23 2021 some_file2.pdf
            ​-rw-rw-r-- 1 nobody shared 63469 Dec 23 2021 some_file3.pdf

            GID only:
            Code:
            -rw-rw-r-- 1 bob    shared 63469 Dec 23 2021 some_file1.pdf
            ​-rw-rw-r-- 1 carol  shared 63469 Dec 23 2021 some_file2.pdf
            ​-rw-rw-r-- 1 ted    shared 63469 Dec 23 2021 some_file3.pdf
            ​


            For the GID only option, bob, carol, and ted must have unique UIDs and all the users should exist on all the systems. This wouldn't mean they could log on to any computer, they would just have to exist on it.

            For example if bob and ted were both UID 1002, carol was 1001, and carol did not exist on bob's system - bob would see this;
            Code:
            -rw-rw-r-- 1 bob    shared 63469 Dec 23 2021 some_file1.pdf
            ​-rw-rw-r-- 1 1001   shared 63469 Dec 23 2021 some_file2.pdf
            ​-rw-rw-r-- 1 bob    shared 63469 Dec 23 2021 some_file3.pdf
            ​
            When using bob's system to access the shared files, because both bob and ted have the same UID they both are the owner of files 1 and 3. Since carol does not exist on bob's​ system, file 2 shows her UID number instead of name.

            It's simple to create your users and assign specific IDs and groups to them from the command line and a script would make it even easier. Unfortunately, System Settings is not up to the task so it would have to be done manually.

            Please Read Me

            Comment


              #21
              I attempted to alter the gid of the second user I created here on computer A.
              My primary user's group
              Code:
              id mm3
              uid=1000(mm3) gid=1000(mm3) groups=1000(mm3),4(adm),24(cdrom),27(sudo),30(dip) ,46(plugdev),12
              1(lpadmin),131(lxd),132(sambashare),134(vboxusers)
              From what I've found and read the command to change group ID for second user mm7 is
              Code:
              groupmod -g 1000 mm7​
              Which resulted in response
              groupmod: GID '1000' already exists
              id mm7 = uid=1001(mm7) gid=1005(mm7) groups=1005(mm7)
              Not quite what I was expecting. So where did I go wrong?
              Q- Is it required to post the output of
              Code:
              getent group​
              (It doesn't display passwords. Neither does
              Code:
              getent passwd
              which from what I've read should display passwords. I've even tried it with
              Code:
              sudo getent passwd
              Sorry I was reading this https://www.cyberciti.biz/faq/linux-...l-owned-files/ Along with some other sites that have basically the same coding, but different explaining. This appear the easiest to understand.
              Last edited by CharlieDaves; Nov 13, 2022, 07:35 PM.

              Comment


                #22
                Found this.
                https://unix.stackexchange.com/quest...rectory-owners
                So is this what I should or could be doing? adding additional groups to share the folder/files ?

                Comment


                  #23
                  Originally posted by CharlieDaves View Post
                  From what I've found and read the command to change group ID for second user mm7 is
                  Code:
                  groupmod -g 1000 mm7​
                  groupmod modifies groups, you want usermod.

                  As well, I expect you want to add mm7 to a group, not change the user's primary group. A user has one primary group, which is applied to files created by that user, but also can be the member of several groups, and these give the user group access. I suspect what you want to do is
                  Code:
                  sudo addgroup somename
                  sudo usermod -a -G somename mm7
                  Regards, John Little

                  Comment


                    #24
                    Just re-read this and I missed a couple small points. The GID is a NUMBER. The word you see when using "ls -l" or some other tool like Dolphin is a group NAME. These are stored in /etc/group. From my /etc/group file:
                    Code:
                    shared:x:560:stuart,trevor
                    ​shared = group name
                    x = group password (none in this case)
                    560 = GID
                    lastly, the list of group members.

                    My systems correlate GID 560 with the name "shared" since they are all configured the same.

                    When you create a new group using "groupadd" or "addgroup" you must specify a group name - the system doesn't provide or guess one for you. What it does do is pick a number for you unless you specify one. Since, as I explained, you're going to want to have this group on many systems, it's more logical or at least simpler in my view - to have the same GID and name on all the systems. I believe (not 100% sure without testing it) if you let the systems pick a number and they aren't uniform, you could end up with some files locked from some users unintentionally. I'm not sure if this happens just via ssh terminal access or if Dolphin would work it out. Anyway, it's neater to have all the systems identical and I like things neat.

                    Also, pay attention to the GID you select. In the *buntu world GIDs 1000 and above are user GIDs. System GIDs are below 1000. Again, you can do whatever you want, but following the rules is neater.

                    So what I did was:
                    Code:
                    groupadd -g 560 shared
                    then:
                    Code:
                    usermod -a -G stuart shared
                    usermod -a -G trevor shared
                    The result shows in /etc/group as I showed above. I repeated this on all my systems.

                    More info: - one effect of UID and GID and access vis SSH: On my computers, I am UID:GID 1000:1000 except on the main server machine (I have a dedicated server). My user account name and group name on that one system are not the same as my regular user but my UID:GID are the same. So when I log into the server via ssh, I see a different file owner name and group name than on all my other systems. This was intentional so I wouldn't forget where I was when I'm using the terminal, lol.

                    As far as the links, seems a bit complicated and a lot of work to create ACLs and reset all your umasks for a small workgroup. If you had 1000's of users and security needs, then OK.
                    Changing UIDs is doable, especially if you start out that way. However, if you map shared folders/file to NOBODY then it becomes less important. Again, it's really about defining your use-case and building a system that does what you need without constant maintenance.


                    Please Read Me

                    Comment


                      #25
                      So.. This is basically the instructions on installing Samba? Yeah? you install samba, then add each user to the sambashare group...

                      I have just completed this =
                      Code:
                      sudo usermod -a -G mm7 mm3
                      groups mm3
                      mm3 : mm3 adm cdrom sudo dip plugdev lpadmin lxd sambashare vboxusers mm7
                      So now that user mm7 is part of mm3 group, it should be able to access shares created by mm3.

                      Now the UID part. I'm re-READING this thread, just trying to put things into perspective
                      Q. Can I change a users group GID. If on a different PC the user mm3, has a different GID (1005) off the top of my head I think..... If yes how please

                      Comment


                        #26
                        I've now created a group 566 shared.
                        Do I have to create a user UID xyz = shared ?
                        If multiple users are coping files to a "shared" folder, who or whom becomes the owner, or owners (other than root:root)
                        Thanks

                        Comment


                          #27
                          Originally posted by CharlieDaves View Post
                          I've now created a group 566 shared.
                          Do I have to create a user UID xyz = shared ?
                          A group and a user are not synonymous so you do not need an equivalent UID. There are literally 100s of groups on your system with no matching user.

                          If multiple users are coping files to a "shared" folder, who or whom becomes the owner, or owners (other than root:root)
                          Mostly, the owner is irrelevant. What is relevant is permissions and how you are going to use file sharing. I can't emphasize this last bit enough. Your plan on how this is to work must be decided before you continue.

                          The next steps:
                          1. Create the shared group on all the computer and add all users to it.
                          2. Create a shared folder on the "server" (the computer with NFS server on it).
                          3. Create subfolders to contain the shared documents
                          4. Set the UID:GID of the subfolders
                          5. Export the shared folder
                          6. Create mount points on all the client computers
                          7. Mount the shared folder on the clients
                          What you call the shared folder or where it is is irrelevant.
                          UID:GID of the shared folder is not normally important.
                          UID:GID of the sub-folders in it is usually important.
                          How you export is important (what options are used).
                          The mount points on the clients are not very important.
                          How you mount them is important.

                          Just to throw a wrench into it, you can choose NFSv3 or NFSv4. There are several advantages to NFSv4, this most noticeable difference is the ease of sharing nested folders.

                          Since we don't really know exactly how you are going to use this, I will share my setup. On the server, I have a single folder that is exported. It has subfolders in it which contain the shared files. For my use, I simply mimicked the file default structure of the /home subfolders.

                          So on the server /exports is the exported folder.

                          Within it are:
                          /Documents
                          /Downloads
                          /Music
                          /Pictures
                          /Videos


                          On my client computers, the exports are mounted to the /home/Public folder of each user. What each user "sees" in their /home/Public are the five folders listed above. Again - this made sense to me. Using "/home/user/Public" makes it very clear these are things files that are Public vs. files in the users' folders.

                          The UID:GID and permissions structure on the server is:

                          /exports = drwxr-xr-x root:root

                          The five folders under /exports are:

                          drwxrwsr-x nobody:shared

                          Note the "s" in group permissions. This means if I add files to the shared folders while using on the server, they all are set to the group listed on the folder: "shared"

                          Next is how you export. I exported using anonuid=65534,anongid=560 as options which means anytime a user adds a file to the shared folders, the owner is "nobody" and the group is "shared".
                          In your case, I suspect using only anongid=566 to set the group but leaving the owner in tact might be what you want. That way you know who supplied the file. I'm not sure if editing the file while it's in the shared folders changes the owner or not. Probably not.
                          I exported all the folders to "nobody" because this meant I didn't have to manage UIDs across all my systems. You may want to do that so that it's known who created what file.

                          What mount options you use on the clients is important because it can make a difference at boot time and shut down. The wrong options can cause a long delays in both.
                          Honestly, I've been fiddling with my mount options for as long as I've been using NFS (years) and cant ever seem to get it just right. It seems there's always one or two option that don't work as advertised or change how they work while I wasn't looking.


                          Please Read Me

                          Comment


                            #28
                            [QUOTE=CharlieDaves;n666471] Modified from above [\QUOTE]

                            ​Now in my case Computer A, is almost always on, BUT I don't really have anything I want to share, and IS NOT going to be acing as a "file Storage". HOWEVER I would like it to be the NFS server, simple because it's on most of the time.
                            Q. Should I do it this way?

                            Computer B, is the "STORAGE" Computer that I want files shared too and From, 95% of the time. But I only switch this computer on when I want to listen to music, or watch a movie.
                            Q. Should Computer B NOT be a server, but normal ?

                            Computer A also has printers.(which I might share. ATM I have no reason to do so) Laptop C is only switched on for a few hours a day and is setup as a back-up-ish "A file searching" of the stored files on all my computers, so It will need access, and "modify (delete) on duplicate files.

                            Computer D, would be nice to give it access, but ATM not bothering me that it doesn't

                            Final Conclusion and Question
                            I should install the NFS SERVER on Computer A, or Computer B
                            Thanks
                            PS. Sorry for delay, I've been dealing with my Migraines and my father into a nursing home, and all the BS that goes with it, Like trying to understand the Nursing home "blunt speaking" intake nurse when your head feels like it's exploding, and your writing things down in the dark.

                            Comment


                              #29
                              Seems like you might want both A and B as NFS servers. The question to answer is "How do you want to access your files?" There's a couple likely scenarios.

                              "B" holds all of but only Music and Movies/Videos. "A" holds all your docs, pics and whatever. Then, on C and D you could mount both or either A and B depending on how C and D get used.

                              If B is not a server, then you couldn't watch a movie or listen to music on your laptop or on A. If A is not a server then you can't access a file on A from your laptop.

                              Seems to me unless you are very rigid on how each computer is used, having both A and B as servers gives you the most flexibility. I would not automatically mount either of them at boot since one or the other may not be on.

                              Please Read Me

                              Comment

                              Working...
                              X