[comp.os.minix] chroot

paradis@encore.UUCP (Jim Paradis) (04/18/87)

In article <3423@gitpyr.gatech.EDU> kpk@gitpyr.gatech.EDU (Kevin P. Kleinfelter) writes:
>I have a PC with a hard disk.  I would like to make the hard disk be the
>root file system, and mount the ram disk as non-root.
>I wrote a program "chroot" which simply makes a chroot call with the
>program's parameter.  "chroot" returns 0 (indicating success).  However,
>the root is still the ram disk, as far as I can tell (i.e. using "ls /"
>gives the ram disk's directory).
>
>Am I doing something wrong, or is this a bug?

You have to understand that the 'chroot' system call ONLY applies to the
process that called it and its descendants.  Realize, too, that every time
you run a program in MINIX/UNIX/whatever, the program is run in a separate
process from the shell (as opposed to systems like VMS where programs run
in the same process as the command interpreter).  Therefore, your program
happily changed the root for the process it was running, which then exited.
No effect on the rest of the system.  By the way, this is why 'cd' is built
into the shell and is not a separate program.

Reading your message got me thinking, though:  using 'chroot' there IS a
quick-and-dirty way to use your hard disk as your "root filesystem".  Since
the INIT process is the granddaddy of all other processes, and since chroot
applies to ALL descendants of a process, if you hack-up init to do a chroot,
then the whole system will end up using the new root.  Of course, it's not
QUITE so simple as that, since filesystems other than root will get mounted
by /etc/rc, which is LONG after init has started!  Hacking up init to mount
the hard disk before doing a chroot might be the way to go.  Since I'm as
interested as anyone else is in using my hard disk as a root, I'll be looking
into this soon.  I'll post anything I come up with.

   +----------------+  Jim Paradis                  linus--+
+--+-------------+  |  Encore Computer Corp.       necntc--|
|  | E N C O R E |  |  257 Cedar Hill St.           ihnp4--+-encore!paradis
|  +-------------+--+  Marlboro MA 01752           decvax--|
+----------------+     (617) 460-0500             talcott--+
You don't honestly think ENCORE is responsible for this??!!