【说明】

-------------------------------------------------------

# 9vx tutorial:running a cpu server from kfs (RFC)

This tutorial is a work in progress (it will eventually be added to the 9vx documentation and probably to the Plan 9 wiki). Please let me know if you see anything I'm doing wrong (unfortunately I don't have too much experience with real Plan 9 systems of more than one machine). In particular, I don't know why I could not use mkfs instead of dircp. The line

 % disk/mkfs -s /n/9660 /sys/lib/sysconfig/proto/allproto

gave me this error:

mkfs: /sys/lib/sysconfig/proto/allproto:1: can't move tmp file to /n/kfs/dist/replica/plan9.compressed.db: wstat -- unknown type/mode

Anyway, these instructions are working here. Please, let me know if they work for you too.

By the way, this tutorial is only the first one, but I'd like to have some more. For example, to run several 9vx instances in a private network using the tap device and to run 9vx from fossil backed up by p9p's venti. Contributions are welcomed ;-)

----------------------------------------------------------------------

This is a brief tutorial on how to run a 9vx cpu server from a kfs file system. You will need 9vx, a plan9.iso and some free disk space.

First, go to the destination directory and install 9vx:

$hg clone http://bitbucket.org/yiyus/vx32/$ cd vx32/src/
$make 9vx/9vx && sudo make 9vx/install  (Commands run on the host are preceded by$, commands run from inside 9vx are preceded with %

You can check that 9vx is working running the minimal system embedded in the executable. The rcvx script should take you to a vx32% rc prompt in the current directory. Once you have played a bit with a rootless 9vx type exit to go back to your host system.

rcvx is cool but you will want a full Plan 9 tree to have real fun.

Let's boot from the iso file:

 $9vx -r plan9.iso -u glenda "CWD=#Zpwd" "nvram=#Zpwd/plan9.nvr"  You should be in rio now, have an acme and a rio window, stats, faces... This is the live system in the iso that you probably already know. The CWD=... and nvram=... arguments are interpreted as plan9.ini lines and passed as environment variables, we will use them later. Open a new rio window: % cd$CWD
% dd -if /dev/random -of plan9.nvr -bs 512 -count 1
% dd -if /dev/zero -of plan9.kfs -bs 1024 -count 320000 

Those files will be our nvram and kfs partitions (check the size of your kfs file, 320Mb is not too much, but will be enough). Nvram needs to be initialized:

    % auth/wrkey
authid: bootes
authdom: 9vx
secstore key:
password: 

We can populate the file system now:

% 9660srv -f plan9.iso
% 9fs 9660
% disk/kfs -f plan9.kfs
File system main inconsistent
Would you like to ream it (y/n)? y
% 9fs kfs
% dircp /n/9660 /n/kfs 

The system is now installed. You should be able to open a new 9vx instance from your new root:

$9vx "nvram=#Zpwd/plan9.nvr" -r plan9.kfs -u glenda  You can also boot a cpu server. We will use the canopenpath option, so that only the files which begin with pwd/plan9 can be opened from 9vx, the -ic flags tell 9vx to pass -c to /386/init: $ 9vx -gic -r plan9.kfs "nvram=#Zpwd/plan9.nvr" "canopenpath=pwd/plan9" -u bootes

When you see the vx32# prompt add a key so that you can cpu as glenda:

vx32# echo 'key proto=p9sk1 dom=9vx user=glenda !password=password' >/mnt/factotum/ctl

Now you can cpu to your new server. From another 9vx instance (for example, booted from the iso):

% cpu -h 127.0.0.1

If it worked we are done.

Now you will probably want to adjust to your needs the 9vxc script to launch cpu servers (also, think about adding a /cfg/vx32/cpurc file).

You could be interested in the options localroot, canopenpath, cpulimit and memsize. Or maybe you want to setup a virtual ethernet device (have a look at the tap script and the 9vx man page).

Have fun! (and please, report bugs)

--

- yiyus || JGL . 4l77.com