thanks to oshunluvr for the write up
Announcement
Collapse
No announcement yet.
Help with NFS server and client
Collapse
This topic is closed.
X
X
-
Originally posted by oshunluvr View PostAs 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: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.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 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.
Originally posted by oshunluvr View PostFrankly, 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.
- Top
- Bottom
Comment
-
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 isCode:chown username:groupname /media/newdrive -R
May I assume my analogy of UID/GID is accurate?
Or is there more to it?
- Top
- Bottom
Comment
-
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 ??
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:- I picked 560 randomly because it was not in use anywhere
- Using the same GID on all your systems makes life easier
- I didn't use 100 at the time because I was new to Kubuntu and didn't realize it was an option.
However, unless the user existed on the system reading the file list, UID would only appear as number
- Top
- Bottom
Comment
-
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
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.
- Top
- Bottom
Comment
-
I attempted to alter the gid of the second user I created here on computer A.
My primary user's groupCode: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)Code:groupmod -g 1000 mm7
groupmod: GID '1000' already existsid mm7 = uid=1001(mm7) gid=1005(mm7) groups=1005(mm7)
Q- Is it required to post the output ofCode:getent group
Code:getent passwd
Code:sudo getent passwd
Last edited by CharlieDaves; Nov 13, 2022, 07:35 PM.
- Top
- Bottom
Comment
-
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 ?
- Top
- Bottom
Comment
-
Originally posted by CharlieDaves View PostFrom what I've found and read the command to change group ID for second user mm7 isCode:groupmod -g 1000 mm7
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
- Top
- Bottom
- Likes 1
Comment
-
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
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
Code:usermod -a -G stuart shared usermod -a -G trevor shared
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.
- Top
- Bottom
- Likes 1
Comment
-
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
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
- Top
- Bottom
Comment
-
Originally posted by CharlieDaves View PostI'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)
The next steps:- Create the shared group on all the computer and add all users to it.
- Create a shared folder on the "server" (the computer with NFS server on it).
- Create subfolders to contain the shared documents
- Set the UID:GID of the subfolders
- Export the shared folder
- Create mount points on all the client computers
- Mount the shared folder on the clients
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.
- Top
- Bottom
Comment
-
[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.
- Top
- Bottom
Comment
-
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.
- Top
- Bottom
Comment
Comment