9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] name space and fossil tricks
@ 2003-02-07 19:54 Russ Cox
  2003-02-08 15:20 ` Kenji Arisawa
  0 siblings, 1 reply; 2+ messages in thread
From: Russ Cox @ 2003-02-07 19:54 UTC (permalink / raw)
  To: 9fans

[I wrote this back in November, but was waiting for Fossil to be
released for context before mailing it, and then I forgot.  -rsc]

Rob wrote a script like the one below when we were working
on the 4th edition distribution.  To build the distribution binaries,
we could make a copy of sources (say, in /n/dist) and then run

	g% namespace /n/dist

which makes the name space in that window almost identical to
the name space you'd get booting from /n/dist.  If you then run

	g% window -m rio

you've got a full terminal!  This is much easier than using
a different machine.

In fact, you can, for example, boot over the network
and then do

	g% 9fs kfs
	g% namespace /n/kfs
	kfs=;

Then even if the network connection dies you can keep doing
useful things in the kfs name space window.

This is a neat trick, but I didn't realize how neat it was until
just now.  I've been testing the new file server (called fossil)
on my laptop (hey, when you've only got one machine, ...).
I can boot from fossil to get my up-to-date system, or if I
really screw things up I can boot from kfs to get an out-of-date
system I can use to fix things.

I made a change to the on-disk layout of the new file system
and needed to reformat the disk.

Usually this would require the following:

	- build a new kernel containing the new fossil
	- copy kernel to 9fat
	- run a dump of the file system to Venti
	- reboot using kfs kernel
	- reformat the disk
	- reboot using new kernel

But instead I did:

	- run a dump of fossil to Venti, remember score
	- switch to kfs and kill fossil
		g% namespace /n/kfs
		kfs=; slay fossil | rc

	- realize I forgot to copy the format binary to kfs
	- realize I forgot to build a new kernel
	- mount dump
		kfs=; vacfs <{echo vac:asdfadsfasdadsf}
	- reformat using binary in dump
		kfs=; cd /n/vac/sys/src/cmd/fossil
		kfs=; 8.format /dev/sdC0/fossil vac:asdfadsfadsfadsf
	- start fossil and switch back
		kfs=; 8.fossil ...
		kfs=; mount /srv/fossil /n/fossil
		kfs=; namespace /n/fossil
	- rebuild the kernel
		fossil=; cd /sys/src/cmd/fossil
		fossil=; mk install
		fossil=; cd /sys/src/9/pc
		fossil=; mk 'CONF=pcfl' 9pcfl.gz
		fossil=; 9fat:
		fossil=; cp 9pcfl.gz /n/9fat
	- reboot

So despite screwing up I still only needed to reboot once
(rather than the four reboots it would have taken without
name space but with the same screwup).

Anyhow, the point is: how many systems do you know
that stay up after you've removed their root file systems
out from under them?

g% cat /usr/rsc/bin/rc/namespace
#!/bin/rc

rfork en

# adapted from /lib/namespace

if(! ~ $#* 1 || ! test -x $1/$cputype/bin/bind) {
	echo 'usage: namespace /n/foo' >[1=2]
	echo '	/n/foo/$cputype/bin/bind must exist' >[1=2]
	exit usage
}

root = $1
echo setting up $root

fn bind{
	/$cputype/bin/bind $*
}

# root
bind  $root /
bind -b '#/' /

# kernel devices
bind '#c' /dev
bind '#d' /fd
bind -c '#e' /env
bind '#p' /proc
bind -c '#s' /srv
bind -a '#S' /dev

# standard bin
bind /$cputype/bin /bin
bind -a /rc/bin /bin

ramfs
cd
prompt=(`{basename $root}^'=; ' '	')
fn cd
rc -i
g%



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] name space and fossil tricks
  2003-02-07 19:54 [9fans] name space and fossil tricks Russ Cox
@ 2003-02-08 15:20 ` Kenji Arisawa
  0 siblings, 0 replies; 2+ messages in thread
From: Kenji Arisawa @ 2003-02-08 15:20 UTC (permalink / raw)
  To: 9fans

 >This is a neat trick
Thanks Russ, that works pretty fine!

Kenji Arisawa



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-02-08 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-07 19:54 [9fans] name space and fossil tricks Russ Cox
2003-02-08 15:20 ` Kenji Arisawa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).