Solved How to share a regular file between jails

As far as I know, nullfs(5) is useful for sharing an existing and mounted directory between jails. I can edit fstab(5) file of each jails:

Code:
/path/to/be/shared /usr/jails/foo/path/shared nullfs ro 0 0
/path/to/be/shared /usr/jails/bar/path/shared nullfs rw 0 0

But it seems probably true that only directory can be shared.

Code:
# This code snippet doesn't work if /root/.emacs is a regular file.
/root/.emacs /usr/jails/foo/root/.emacs nullfs ro 0 0

Is there any solution if I just want share a single file instead of a directory?
 
That's probably the wrong tool for the job. A common approach is to collect the dotfiles you want to share in a git repository and symlink them. Some people even push their dotfiles repositories to github -- not sure whether THIS is a good idea. But you can create a bare repository anywhere and push/pull from that (using ssh).
 
That's probably the wrong tool for the job. A common approach is to collect the dotfiles you want to share in a git repository and symlink them. Some people even push their dotfiles repositories to github -- not sure whether THIS is a good idea. But you can create a bare repository anywhere and push/pull from that (using ssh).

The regular files, I was going to describe, are not only dotfiles, but also some temporary ones. I think it's too heavy for them.
 
1. Create an empty directory.
2. Share it via nullfs.
3. Create a hard link to the file in this directory.

Alternative solution:
1. Create an empty directory.
2. Share it via nullfs.
3. Move the file to the directory.
4. Put a symlink in the original location.

I personally never use hard links.
 
1. Create an empty directory.
2. Share it via nullfs.
3. Create a hard link to the file in this directory.

Alternative solution:
1. Create an empty directory.
2. Share it via nullfs.
3. Move the file to the directory.
4. Put a symlink in the original location.

I personally never use hard links.

Thanks. Maybe I have to choose your alternative one.
 
Oh, by the way, if you want to share files in such a manner (I also use it when backing up all my documents), it is a good practice I have been using for years to put everything that needs to be shared in a big basket (some independent directory, I use ~/backup). Then use symlinks everywhere you need the stuff. All symlinks would point to files inside the basket.
When you share or back things up, always use the basked directly.
 
Back
Top