[comp.unix.wizards] File Sys Hierarchies

bzs@bu-cs.bu.edu (Barry Shein) (06/09/89)

From: Root Boy Jim <rbj@dsys.ncsl.nist.gov>
>One thing that is weird about the root file system is that it has
>no name. So, let's move everything into /root. NOTHING goes into
>the / directory except mount points, and directorys are automagically
>created when mounts are made, and disappear when unmounted.

The main motivation to put things into root was to make it easy for a
boot program to find what it needed without having to grovel the
directory hierarchy.

Also that a very minimal number of directories and files have to be
alive to get a system up, in emergency (remember the days when we'd
have to patch the file system back together just to get it to the
point that we had a shell and start really fixing the mess.)

Most of this may be anachronism, some vendors have ROMs these days
which can do 'cd's, 'ls's and other file ops w/o Unix even running
yet. Obviously things have changed from the days when a PDP-11 boot
prom would suck in the 512 bytes of block zero and jump to it and
you'd have to get the system started with that 512 bytes of code (I've
written a few of those, it is fun in a masochistic way...)

Anyhow, one wants to carefully balance between convenience and
robustness under fire. I agree it would be nice if someone came up
with some basic directory hierarchy which all vendors would please
use. They seem to accept /bin and /usr/bin as givens (most of them
anyhow), some rational standard for more (boot files, mount points
etc) would be nice. It's certainly a very silly area for a vendor to
get creative, yet they do...

	-Barry Shein

Software Tool & Die, Purveyors to the Trade
1330 Beacon Street, Brookline, MA 02146, (617) 739-0202

dhh@nwnexus.WA.COM (Duane Hesser) (06/16/89)

> ..... I agree it would be nice if someone came up
> with some basic directory hierarchy which all vendors would please
> use. 


Barry
	Perhaps you missed the posting by the Berkeley folk about a year
or a year and a half ago, in which they just such a "standard"
hierarchy.  The organization was based upon several aims, not the
least of which was placement of all "static" system files in
read-only directories.  Vendor-specific files have their own
fileystem mount point, and things were generally set up to
accomodate networked filesystems.  You may want to check back in
the nearest archives to see if you can find the posting.

If lI'm not mistaken, Sun has adopted this organization in 4.0,
and perhaps others will (or have) as well.

As for the original posters notion about "/root", I will point out
that the root directory is a directory like any other, that it has
a name ("/"), and that it serves not only to provide mount points,
but normally contains some rather important FILES as well (e.g.
/vmunix [or, if you happen to have a pdp11, /unix], /boot, and
let's not forget /.profile).  This is not to mention ordinary,
not-mounted DIRECTORIES like /etc, /bin, /lib.  Perhaps I missed
his point?

------
Duane H. Hesser
Future Systems
dhh@nwnexus.wa.com

rbj@dsys.ncsl.nist.gov (Root Boy Jim) (06/29/89)

? From: Duane Hesser <dhh@nwnexus.wa.com>

? As for the original posters notion about "/root", I will point out
? that the root directory is a directory like any other, that it has
? a name ("/"), and that it serves not only to provide mount points,
? but normally contains some rather important FILES as well (e.g.
? /vmunix [or, if you happen to have a pdp11, /unix], /boot, and
? let's not forget /.profile).  This is not to mention ordinary,
? not-mounted DIRECTORIES like /etc, /bin, /lib.  Perhaps I missed
? his point?

No, it does not have a name. A name is a character string you can look
up in a directory. The root is treated as a special case by the
kernel.  As you know, pathnames beginning with a `/' are treated as
absolute; otherwise they are relative to the current directory. To
translate a pathname, the kernel uses either the root or at the
current directory as a reference point, and for each component seen,
looks it up relative to that reference point, and makes the inode
found the new reference point. When all names are used up, the
inode found is returned.

Of course it works to say `/'; things would be broken if it didn't.
My point is that the `/' is really used to denote an absolute path,
so the real name of the root is perhaps "". You can get around that
by claiming that its real name is `/.' if you like.

But however you might try, there is just no getting around the fact
that the root is a special case. It is too easy to generate `//' at
the beginning of a name accidently in shell scripts or makefiles.
Furthermore, consider a script which automatically makes dumps:

	cd /usr/adm
	foreach fs (/ /usr /u ...)
		dump un$1 $fs			# $1 is dump level
		mt bsf 2
		mt fsf
		restore tv > dump.$1.$2.$fs:t	# $2 is date YYMMDD
		mt fsf
	end

For the root, the thing after the third period evaluates to "".
Perhaps this is no big deal, but I hope it illustrates the point.
No flames for using a csh script, please.

Another annoying thing is that the superuser's home directory is `/'.
This make it difficult to have a private bin directory and use the
same .cshrc and .login scripts as my user account.

Please don't respond with microsuggestions about how easy it is to
do this or that; I know all the tricks, and I can live with things the way
things are. This is a forest posting, don't talk to me about trees. 

? Duane H. Hesser
? Future Systems
? dhh@nwnexus.wa.com

	Root Boy Jim is what I am
	Are you what you are or what?

night@pawl.rpi.edu (Trip Martin) (06/29/89)

In article <20140@adm.BRL.MIL> rbj@dsys.ncsl.nist.gov (Root Boy Jim) writes:
>Another annoying thing is that the superuser's home directory is `/'.
>This make it difficult to have a private bin directory and use the
>same .cshrc and .login scripts as my user account.

Is there any good reason to leave root's home directory as "/"?  Or
is this just another convention that's been around so long that no one's
bothered to change it?

Trip Martin  KA2LIV       night@pawl.rpi.edu
Finite state machinist    night@uruguay.acm.rpi.edu

smb@ulysses.homer.nj.att.com (Steven M. Bellovin) (06/30/89)

In article <5748@rpi.edu>, night@pawl.rpi.edu (Trip Martin) writes:

} Is there any good reason to leave root's home directory as "/"?  Or
} is this just another convention that's been around so long that no one's
} bothered to change it?

So you can log in as root when all else is munged.

bill@twwells.com (T. William Wells) (07/01/89)

In article <5748@rpi.edu> night@pawl.rpi.edu (Trip Martin) writes:
: In article <20140@adm.BRL.MIL> rbj@dsys.ncsl.nist.gov (Root Boy Jim) writes:
: >Another annoying thing is that the superuser's home directory is `/'.
: >This make it difficult to have a private bin directory and use the
: >same .cshrc and .login scripts as my user account.
:
: Is there any good reason to leave root's home directory as "/"?  Or
: is this just another convention that's been around so long that no one's
: bothered to change it?

Well, you want root's home directory to be on the boot file system so
that root is not dependent on other file systems.

My solution is this: in /.profile, I check to see if there is a
/usr/home/root directory. If not, I leave the home directory as /. If
there is, I fake things so that /usr/home/root becomes the root home
directory. Programs generally useful to root that aren't needed when
/usr is down go in /usr/home/root/bin; those needed under all
conditions go in /etc/bin.

(Yeah, I'd probably do it differently if I had symbolic links.)

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill@twwells.com

limes@sun.com (Greg Limes) (07/20/89)

In article <5748@rpi.edu> night@pawl.rpi.edu (Trip Martin) writes:
   In article <20140@adm.BRL.MIL> rbj@dsys.ncsl.nist.gov (Root Boy Jim) writes:
   >Another annoying thing is that the superuser's home directory is `/'.
   >This make it difficult to have a private bin directory and use the
   >same .cshrc and .login scripts as my user account.

   Is there any good reason to leave root's home directory as "/"?  Or
   is this just another convention that's been around so long that no one's
   bothered to change it?

I regularly establish special purpose accounts with UID==0 (i.e.
superuser accounts) that have home directories other than "/". Quite
useful, actually, and does not seem to cause problems.

--
Greg Limes	limes@sun.com	...!sun!limes	73327,2473	[chose one]

tlm@hpsmtc1.HP.COM (Teri Miller) (07/27/89)

limes@sun.com (Greg Limes) writes:
>
>I regularly establish special purpose accounts with UID==0 (i.e.
>superuser accounts) that have home directories other than "/". Quite
>useful, actually, and does not seem to cause problems.

I agree - I never set up su accounts to default to "/".  I also don't 
set them up to point to the person's regular home directory.  We use NFS, 
and if there's a problem with the "user" directories, I want the superuser 
to be able to log in anyway.