How to share disk space between virtual machines? reddit / selfhosted ---------------------------------------------------------------------- aqa5 · 2023-12-03 12:08 I have serveral Ubuntu server running in virtual machines on my host. Everything works fine but there is a problem. I use NFS to share a common directory between the VMs. And as the machines user IDs are different so even when user and password are the same, they cannot write data or use data thats from another VM. Changing user IDs did not work properly, I rolled that back. So, someone mentioned Kerberos to manage users. This seems a bit too much effort. Is there a better, lightweight solution? Or even another way to share a common disk space? How is this done usually? ---------------------------------------------------------------------- RedditSlayer2020 · 2023-12-03 12:23 Try samba ---------------------------------------------------------------------- ro55mo · 2023-12-03 12:55 The laziest way to fix your issue is to chmod the shared directory to 777. ---------------------------------------------------------------------- ex800 · 2023-12-03 13:47 would access rights per client IP work for you? if you want per user, then kerberos, or as u/RedditSlayer2020 has said, use SMB ---------------------------------------------------------------------- bobj33 · 2023-12-03 14:24 > Changing user IDs did not work properly, I rolled that back. It should work fine so you must have done something wrong. How did you change the user IDs? ---------------------------------------------------------------------- sudonem · 2023-12-03 14:43 NFS handles permissions based on the UID and GID of the user account accessing the share. (Assuming you haven’t restricted the share to a specific subnet or host IP). When you create the NFS share, assign permissions using a group with a non-standard GID (doesn’t matter what, but pick something you’ll remember like 3000). How you go about that will depend on the server you’re running the NFS share on. It’ll be different for Ubuntu or TrueNAS or Unraid etc - so read the documentation. Once that is sorted, for each VM you need to create a group using that GID and assign the relevant users on each VM to be members of that group. ---------------------------------------------------------------------- aqa5 · 2023-12-03 15:27 This seems besides Kerberos the best solution so far. I did not think of user groups, only users. Thank you, that will be what I will do next. ---------------------------------------------------------------------- sudonem · 2023-12-03 16:33 Happy to help. I like this approach because it means you don’t have to constantly fiddle with UID’s and trying to override system defaults for new users. You just create the group once per system and add / remove the relevant users as necessary. ---------------------------------------------------------------------- boli99 · 2023-12-03 20:57 my chosen methods in order of preference: - virtiofs - nfs 4 - nfs 3 - samba (ick) ---------------------------------------------------------------------- adamshand · 2023-12-03 22:10 The professional sysadmin in me is having to resist screaming ... ---------------------------------------------------------------------- ro55mo · 2023-12-03 22:13 Exactly why I called it 'lazy' and said this should only be done if you are the only user. I am aware it is a bad idea. ---------------------------------------------------------------------- adamshand · 2023-12-03 22:14 This is how NFS works. Making sure that usernames and userids match on all of your servers will fix this and is by far the simplest solution. If it didn't work, you probably just made a typo somewhere. Other options. Use an LDAP serer (I like LLDAP) to provide a single user database for all your servers. This has lots of advantages (can provision users and change passwords for all servers in a single place). But it is fixing your problem in the same way as above (making usernames and user ids match on all of your servers). Use Samba/CIFS instead of NFS. Because you authenticate with a user/pass all actions happen as the user you authenticate and so local user permissions don't matter. ---------------------------------------------------------------------- adamshand · 2023-12-03 23:03 It works, but ... 😱😱😱 🤣 ---------------------------------------------------------------------- revereddesecration · 2023-12-04 03:17 It’s bad, and you shouldn’t write comments suggesting it. Here’s why: https://www.baeldung.com/linux/why-is-chmod-r-777-destructive