chongo@nsc.UUCP (Landon C. Noll) (03/18/85)
I would like to mount things like /bin, most of /etc, /usr/{bin,lib, ... }, /dev/{mem,kmem,...}, usw... on a read-only disc pack. What is needed (if it can be done) to be done to unix to allow this? A guess is that one needs to change the mountfs call in init_main.c to pass a read-only flag. One would need to add an additional mountfs call to mount a second writable pack. Files which need to be written such as /etc/utmp, or /usr/adm would be symbolicly linked over to the write pack. What problems are connected with that? What about the /dev/ttyxx files. To allow getty/login to play with the ownership, one might need to symbolic link to the write pack as well. Will this cause a problem? Does unix assume that it can write on root? (my guess again is that one the superblock timestamp update for root is not needed since I can get the starttime for a real time clock) What about last file access times? chongo <thanx> /\../\ -- no comment is a comment.
long@ittvax.UUCP (H. Morrow Long [Systems Center]) (03/19/85)
In <2483@nsc.UUCP> chongo writes > I would like to mount things like /bin, most of /etc, /usr/{bin,lib, ... }, > /dev/{mem,kmem,...}, usw... on a read-only disc pack. > > What is needed (if it can be done) to be done to unix to allow this? > What you need to do is place the (sub)directory to be read-only in its own filesystem. You can then use 'mount /usr/src -r' to mount the filesystem readonly or change field 3 from ':rw:' to ':ro:' in /etc/fstab and the 'mount -a' will do it for you. In the following fstab fragment /usr/src is mounted readonly: /dev/hp0a:/:rw:1:1 /dev/hp2a:/tmp:rw:0:4 /dev/hp3g:/usr:rw:1:2 /dev/hp0e:/usr/src:ro:1:3 ------ From /etc/rc: /etc/mount -a >/dev/console ------- You can still unmount the filesystem (although you probably wouldn't be able to umount /bin or /usr/bin if you are in multiuser mode because they would be in almost continual use) and mount it read-write (the default) if you need to place a program on it. -- H. Morrow Long ITT-ATC Systems Center, 1 Research Drive Shelton, CT 06484 Phone #: (203)-929-7341 x. 634 path = {allegra bunker ctcgrafx dcdvaxb dcdwest ucbvax!decvax duke eosp1 ittral lbl-csam milford mit-eddie psuvax1 purdue qubix qumix research sii supai tmmnet twg uf-cgrl wxlvax yale}!ittvax!long
chris@umcp-cs.UUCP (Chris Torek) (03/21/85)
> From: long@ittvax.UUCP (H. Morrow Long [Systems Center]) > In <2483@nsc.UUCP> chongo writes > > I would like to mount things like /bin, most of /etc, /usr/{bin,lib, ... }, > > /dev/{mem,kmem,...}, usw... on a read-only disc pack. > > What you need to do is place the (sub)directory to be read-only in its > own filesystem. You can then use 'mount /usr/src -r' to mount the > filesystem readonly or change field 3 from ':rw:' to ':ro:' in > /etc/fstab and the 'mount -a' will do it for you. I don't think this answers his particular question. The problem is that much of /bin and /etc is required simply to get far enough into the boot that "mount -a" will even get done. Consider: even before you get a single user shell after a "b hps" or "b/2" (e.g.), Unix has to run /etc/init. Init needs access to /bin/sh. Sh is nearly useless without most of /etc and /bin. During boots to multi-user mode you need both /etc/rc and /bin/sh. Without /dev, /etc/fsck may have a hard time fixing disks. Anyway, clearly most of the root file system has to be present in order for Unix to boot. Since it's mounted read-write by init_main.c, /bin, /dev, /etc, and anything else out there is clearly going to be writable. Is there a solution? Well, sort of. It turns out that you can mount on top of *any* directory. So you can have a "minimal root" that has just enough in it to be able to safely "mount -a", and have an fstab that mounts a true /bin, /etc, etc., which are all read-only. This helps protect against fumble-fingered super users, at least. (I've been known to trip over the keys myself now and then. :-) ) (By the way, it used to be that you could mount on top of *any* file! 4.2 makes sure it's a directory. Ah well.) To answer chongo's original question: could you change the mountfs() call in main() to make / read-only? Answer: yes, but you'd have to be *real* careful. It's no fun having to switch Unixes just because you need to write in / now. . . . (Don't forget about new /vmunixes!) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland