Stefan led me down the right track. This will work on any system 12.04 and newer.
Your filesystem will also need extended attribute support. If you're using EXT4 you're fine, if you're using EXT3 you'll need to ensure your filesystem is mounted with the user_xattr
attribute.
Here's how I set it up on the client machine, you don't need to do anything on the server side.
First, install the user space daemon:
sudo apt-get install cachefilesd
Then turn it on by editing /etc/default/cachefilesd
and changing the run line to RUN=yes
Ensure your NFS mount in /etc/fstab
has an fsc
option. Don't forget to remount it after you've made the changes. Here's my excerpt (modify to your needs):
192.168.1.115:/home/jorge /home/jorge/Backup nfs fsc
Start the service: sudo /etc/init.d/cachefilesd start
Configuration of the cache is done in /etc/cachefilesd.conf
, see the references for what the setting options are.
References:
Access control lists
The straight answer is access control lists (ACLs). Yeah, you can find a counterexample, but they're good enough in practice (unlike mere group writability which requires that users think about it all the time). What they do require is that the system administrator (root) define the groups, if you want files to be shared only by a named group (root can choose to delegate, for example by accepting groups from LDAP, but that's another story).
You do need participating users to have a umask of 022. If they create non-world-readable files routinely, this scheme won't work. But if they have a restrictive umask, it's presumably because they don't want to share files anyway.
Enabling ACLs
Ubuntu doesn't enable ACLs by default, so there's a one-time admin requirement. Edit /etc/fstab
using your favorite editor, and change every line corresponding to a filesystem where you want to share files: add acl
to the options. (Make sure not to change any other line, and not to use an editor that wraps long lines.) Here's an example line with the acl
option added:
UUID=5e1ec7ed-face-dead-beef-c011ec7ab1e5 / ext4 errors=remount-ro,acl 0 1
For the option to take effect the first time, use a command like the following (for each filesystem):
sudo mount -o remount,acl /
Install the ACL tools from the acl
package.
Setting up the shared directory
To have files shared by the group mygroup
:
setfacl -m group:mygroup:rwx /path/to/shared/root
setfacl -d -m group:mygroup:rwx /path/to/shared/root
If people create files and copy them to the shared directory, the files will be world-readable (because of the umask) and anyone in the group can add and remove files (because the group is group-writable). People can't edit each others' files, but that's a good thing or you'd run into editing conflicts straight away.
If you don't have a unix group, you can add users one by one:
setfacl -m user:bob:rwx /path/to/shared/root
setfacl -d -m user:bob:rwx /path/to/shared/root
Version control
If you do want people to be able to edit files in place, you also need something to prevent editing conflicts. That's version control.
You don't need any of this to share a git repository. You know there are solutions like gitosis, so use them.
Best Answer
I think you might be able to accomplish what you want using network block devices (NBD). Looking at the wikipedia page on the subject there is mention of a tool called
nbd
. It's comprised of a client and server component.Example
In this scenario I'm setting up a CDROM on my Fedora 19 laptop (server) and I'm sharing it out to an Ubuntu 12.10 system (client).
installing sharing a CDNow back on the server (Fedodra 19) I do a similar thing using its package manager YUM. Once complete I pop a CD in and run this command to share it out as a block device:
A quick check to see if it's running:
Mounting the CDNow back on the Ubuntu client we need to connect to the
nbd-server
usingnbd-client
like so:We can confirm that there's now a block device on the Ubuntu system using
lsblk
:And now we mount it:
did it work?The suspense is killing me, and we have liftoff:
There's the contents of a LiveCD of CentOS that I mounted in the Fedora 19 laptop and was able to mount it as a block device of the network on Ubuntu.
Autoplaying & Automounting?
In the above setup I had to manually mount the DVD.
In investigating the plausibility of whether this approach would work with autoplaying and automounting, out of the box, Ubuntu's autoplay doesn't work but the
nbd-client
andnbd-server
stayed up when I ejected the disk. When I put the DVD back in I was able to run themount
command on Ubuntu, which remounted the DVD just fine.So I would assume you could stick a UDEV rule in on Ubuntu to detect this change and do the automount/autoplay automatically. I'm not gonna try it all out but I don't see anything that would lead me to think that it won't work.