[Gllug] Multiple Distro's, one swap partition?

Nix nix at esperi.org.uk
Sat Mar 20 18:20:36 UTC 2004


On Mon, 8 Mar 2004, Alain Williams stated:
> Either create a /home_real (or something) and put real user's $HOMEs
> here, or creating a /home partition in the first distro that you in,
> but not in subsequent ones and symlink real user directories over in
> subsequent ones.

I evolved something which, well, it seems to work and is pretty robust
(against everything but usernames starting with dots; how likely is
that?)

You have a bunch of machines which serve home directories. Each of these
has a directory /home/.{machine-FQDN}/; home directories for it are
under there.

So I might have

/home/.svn.esperi.org.uk/nix
/home/.svn.esperi.org.uk/gerald
/home/.inferno.esperi.org.uk/locutus
/home/.inferno.esperi.org.uk/billg
/home/.inferno.esperi.org.uk/darl

(Those usernames may not overlap: only one machine may export a given
user. To fix that, use NFSv4 or something else with replication
capability.)

esperi NFS-exports `/home/.svn.esperi.org.uk' and NFS-imports all the
others in the cell to the same places in /home as they are exported on
their respective servers: so everyone has a /home tree that looks
pretty much identical.

But it's really ugly having to wire paths like that into /etc/passwd,
and uglier hitting users with them whenever they type `pwd': those paths
would probably end up wired into scripts and config files, stopping you
from migrating home directories properly.

On each machine, you mkdir a directory under /home for each user whose
home directory you want to be exported to that machine: they don't need
to be owned by anyone in particular or anything like that. Then,
somewhere in the startup scripts, after remote filesystems are mounted,
run this:

#!/bin/bash
#
# Populate /home with bind-mounts.
#

for name in `find /home -type d -maxdepth 1 -mindepth 1 | sed 's,/home/,,' | grep -v '^\.'`; do
    DIR=`find /home -type d -maxdepth 2 -mindepth 2 -name $name | grep '^/home/\.' | head -1`
    [[ -n $DIR ]] && mount -o bind $DIR /home/$name
done

and that'll pick out the home directories from their dot-directories and
bind-mount them into place.

The only disadvantage of this scheme is that it spams df(1) output
something chronic: IMNSHO, bind-mounts should be excluded from df(1)
output by default.

-- 
`The game proceeds with people picking up cards in turn, and every so
 often this is punctuated with a church council when everyone goes mad
 and starts yelling and playing cards at each other and persecuting and
 making deals.' --- Jo Walton on _Credo_
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list