Plan9 on Xen 3.0.2

今週末はPlan9Xen上で動かそうと格闘していた.一応,ブートするところまでは確認できた.以下はそのメモ.
基本的に参考にしたのは,次のページ.UbuntuFedoraCoreと多少,勝手が違うようなので,Howtoforgeの記事が参考になった.Xenが動いてしまえば,Plan9 Wikiの説明にしたがって作業を進めれば,問題はなく動作できるはず.

必要なカーネルは,/n/sources/xen/xen3からダウンロードできる.Plan9用に1GBのディスクイメージを用意した.

$ dd if=/dev/zero of=plan9.img seek=$((1024 * 1024 * 1024 - 1)) bs=1 count=1

インストール用と通常の起動用にカーネルを使い分ける.それぞれの設定ファイルを示す*1
まずは,インストール用のplan9install.

kernel = "/opt/xen/plan9/9xeninst.gz"
memory = 64
name = "plan9"
#vif = [ 'mac=aa:00:10:00:00:10' ]
disk = [ 'file:/opt/xen/plan9/plan9.img,sda,w',
	'file:/opt/xen/plan9/plan9.iso,sdb,r' ]
restart = 'never'

# This is the equivalent of plan9.ini:
extra="""
nobootprompt=local!/boot/bzroot
bootfile=sd01!cdboot!bootdisk.img
"""

続いて,インストール後にターミナルとして立ち上げるときの,plan9term.

kernel = "/opt/xen/plan9/9xenpcf.gz"
memory = 64
name = "plan9"
#vif = [ 'mac=aa:00:10:00:00:10' ]
disk = [ 'file:/opt/xen/plan9/plan9.img,sda,w' ]
restart = 'never'
	 
# This is the equivalent of plan9.ini:
extra="""
bootargs=local!#S/sd00/fossil
"""

インストール用のカーネルを起動すると,

# xm create plan9install -c
Using config file "plan9install".
Started domain plan9

Plan 9
127 holes free
00190000 01a8a000 26189824
26189824 bytes free
cpu0: 1598MHz GenuineIntel P6 (cpuid: AX 0x0695 DX 0xA7E9F9BF)
64M memory: 27M kernel data, 37M user, 165M swap
cpu0: spurious interrupt 101, last 0
sdxen: backend /local/domain/0/backend/vbd/3/2048/ secsize 512 sectors 2097152
sdxen: backend /local/domain/0/backend/vbd/3/2064/ secsize 512 sectors 515080
#S/sd00/data: no partitions
#S/sd01/: part cdboot 188284 194044
kfs...version...time...

init: starting /bin/rc
/bin/dossrv: serving #s/dos
dev 3 sector 18, write: 0, should be 4608
dev 3 sector 0, write: 0, should be 4608
dev 3 sector 18, write: 0, should be 4608
dev 3 sector 9, write: 0, should be 4608
dev 3 sector 3861, write: 0, should be 4608
use DMA for ide drives[yes]: 
echo: write error: bad process or channel control request
echo: write error: bad process or channel control request
rio: can't open display: initdisplay: /dev/draw/new: unknown device in # filename

failed to start rio.  you can start a text-based installation by running

	inst/textonly


init: starting /bin/rc
%

プロンプトが表示され,入力待ちになるので,テキストモードでインストールするため,(メッセージにしたがい)"inst/textonly"と入力する.

基本的にデフォルトから値を変えずにそのままでインストールは進む.Plan9のインストールが始めてでも,悩む箇所はあまりないだろう.注意すべきは,HDDはsd00,CD-ROMがsd01であること.インストールメディアはlocal (CD-ROM)の/を選択することかな.スタンドアローンで動かすことを前提にするので,ファイルサーバはfossilのみの構成を選択する.パーティショニングは自動でやってくれる.

% inst/textonly
Sun Aug 20 15:37:54 BST 2006 Installation process started

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

Preparing menu...
The following unfinished tasks are ready to be done:
	configfs	- choose the type of file system to install
	stop	- save the current installation state, to be resumed later

Task to do [configfs]: 

--------------------------------------
You can install the following types of file systems:

	fossil			the new Plan9 fileserver
	fossil+venti	fossil + a archival dump server

File system (fossil, fossil+venti)[fossil]: 

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

Preparing menu...
The following tasks are done: 
	configfs	- choose the type of file system to install

The following unfinished tasks are ready to be done:
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)
	stop	- save the current installation state, to be resumed later

Task to do [partdisk]: 

--------------------------------------
The following disk devices were found.

sd00 - Xen block device

sd01 - Xen block device

Disk to partition (sd00, sd01)[no default]: sd00
The disk you selected HAS NO master boot record on its first sector.
(Perhaps it is a completely blank disk.)
You need a master boot record to use the disk.
Should we install a default master boot record?

Install mbr (y, n)[no default]: y

This is disk/fdisk; use it to create a Plan 9 partition.
If there is enough room, a Plan 9 partition will be
suggested; you can probably just type 'w' and then 'q'.

cylinder = 1048576 bytes
'* p1                    0 1024       (1024 cylinders, 1.00 GB) PLAN9
>>> w
>>> q

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

Preparing menu...
The following tasks are done: 
	configfs	- choose the type of file system to install
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)

The following unfinished tasks are ready to be done:
	prepdisk	- subdivide plan 9 disk partition
	stop	- save the current installation state, to be resumed later

Task to do [prepdisk]: 

--------------------------------------
The following Plan 9 disk partitions were found.

/dev/sd00/plan9
  empty                 0 2097120    (2097120 sectors, 1023.98 MB)

Plan 9 partition to subdivide (/dev/sd00/plan9)[/dev/sd00/plan9]: 
This is disk/prep; use it to subdivide the Plan 9 partition.
If it is not yet subdivided, a sensible layout will be suggested;
you can probably just type 'w' and then 'q'.

no plan9 partition table found
9fat 204800
nvram 1
fossil 1687519
swap 204800
' 9fat                  0 204800     (204800 sectors, 100.00 MB)
' nvram            204800 204801     (1 sectors, 512 B )
' fossil           204801 1892320    (1687519 sectors, 823.98 MB)
' swap            1892320 2097120    (204800 sectors, 100.00 MB)
>>> w
>>> q

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

Preparing menu...
The following tasks are done: 
	configfs	- choose the type of file system to install
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)
	prepdisk	- subdivide plan 9 disk partition

The following unfinished tasks are ready to be done:
	fmtfossil	- initialize disks for a fossil server
	stop	- save the current installation state, to be resumed later

Task to do [fmtfossil]: 

--------------------------------------
You have the following fossil partitions.

Fossil partition to format (/dev/sd00/fossil)[/dev/sd00/fossil]: 
Done.

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

Preparing menu...
The following tasks are done: 
	configfs	- choose the type of file system to install
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)
	prepdisk	- subdivide plan 9 disk partition
	fmtfossil	- initialize disks for a fossil server

The following unfinished tasks are ready to be done:
	mountfs	- choose and mount file system partition
	stop	- save the current installation state, to be resumed later

Task to do [mountfs]: 

--------------------------------------
The following partitions named fossil* were found.

Please choose one to use as the installation file system
for your Plan 9 installation.

--rw-r----- S 0 glenda glenda 864009728 Jul 27 12:34 /dev/sd00/fossil

Fossil partition (/dev/sd00/fossil)[/dev/sd00/fossil]: 

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

Preparing menu...% fossil/fossil -c . /env/fossilconf
prompt: % mount -c /srv/fossil /n/newfs
fsys main create /active/adm adm sys d775
prompt: fsys main create /active/adm/users adm sys 664
prompt: uname upas :upas
prompt: users -w
	nuser 6 len 96
prompt: fsys main create /active/dist sys sys d775
prompt: fsys main create /active/dist/replica sys sys d775
prompt: fsys main create /active/dist/replica/client sys sys d775
prompt: fsys main create /active/dist/replica/client/plan9.db sys sys 664
prompt: fsys main create /active/dist/replica/client/plan9.log sys sys a664
prompt: 
The following tasks are done: 
	configfs	- choose the type of file system to install
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)
	prepdisk	- subdivide plan 9 disk partition
	fmtfossil	- initialize disks for a fossil server
	mountfs	- choose and mount file system partition

The following unfinished tasks are ready to be done:
	configdist	- choose the source of the distribution archive
	download	- download or continue to download the distribution archives
	stop	- save the current installation state, to be resumed later

Task to do [configdist]: 

--------------------------------------
Are you going to download the distribution
from the internet or do you have it on local media?

Distribution is from (local, net)[local]: 

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

Preparing menu...
The following tasks are done: 
	configfs	- choose the type of file system to install
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)
	prepdisk	- subdivide plan 9 disk partition
	fmtfossil	- initialize disks for a fossil server
	mountfs	- choose and mount file system partition
	configdist	- choose the source of the distribution archive

The following unfinished tasks are ready to be done:
	mountdist	- locate and mount the distribution
	download	- download or continue to download the distribution archives
	stop	- save the current installation state, to be resumed later

Task to do [mountdist]: 

--------------------------------------
Please wait... Scanning storage devices...
	/dev/sd00/9fat
	/dev/sd00/data
	/dev/sd00/fossil
	/dev/sd00/nvram
	/dev/sd00/swap
	/dev/sd01/cdboot
	/dev/sd01/data

The following storage media were detected.
Choose the one containing the distribution.

	/dev/sd00/fossil (plan9 fossil)
	/dev/sd01/cdboot (microsoft fat)
	/dev/sd01/data (iso9660 cdrom)

Distribution disk [no default]: /dev/sd01/data
% 9660srv
/bin/9660srv 2676: serving /srv/9660
% mount /srv/9660 /n/distmedia /dev/sd01/data

Which directory contains the distribution?
Any of the following will suffice (in order of preference):
	- the root directory of the cd image
	- the directory containing plan9.iso
	- the directory containing plan9.iso.bz2
Typing `browse' will put you in a shell that you can use to
look for the directory.

Location of archives [browse]: 
This is a simple shell. Commands are:
	cd directory	- change to directory
	lc				- list contents of current directory
	exit			- exit shell

Move to the directory containing the distribution
and then exit.

/% lc
386          LICENSE.gpl  amd64        env          mips         sparc
68000        NOTICE       arm          fd           mnt          sparc64
68020        acme         bootdisk.img lib          n            sys
LICENSE      adm          cron         lp           power        tmp
LICENSE.afpl alpha        dist         mail         rc           usr
/% exit

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

Preparing menu...
The following tasks are done: 
	configfs	- choose the type of file system to install
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)
	prepdisk	- subdivide plan 9 disk partition
	fmtfossil	- initialize disks for a fossil server
	mountfs	- choose and mount file system partition
	configdist	- choose the source of the distribution archive
	mountdist	- locate and mount the distribution
The following unfinished tasks are ready to be done:
	copydist	- copy the distribution into the file system
	stop	- save the current installation state, to be resumed later

Task to do [copydist]:
Preparing menu...
The following tasks are done: 
	configfs	- choose the type of file system to install
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)
	prepdisk	- subdivide plan 9 disk partition
	fmtfossil	- initialize disks for a fossil server
	mountfs	- choose and mount file system partition
	configdist	- choose the source of the distribution archive
	mountdist	- locate and mount the distribution
	copydist	- copy the distribution into the file system

The following unfinished tasks are ready to be done:
	bootsetup	- create a boot floppy or configure hard disk to boot plan 9
	stop	- save the current installation state, to be resumed later

Task to do [bootsetup]: 
Task to do [bootsetup]: 

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

Initializing Plan 9 FAT configuration partition (9fat)

rc (bootsetup): null list in concatenation

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

Preparing menu...
The following tasks are done: 
	configfs	- choose the type of file system to install
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)
	prepdisk	- subdivide plan 9 disk partition
	fmtfossil	- initialize disks for a fossil server
	mountfs	- choose and mount file system partition
	configdist	- choose the source of the distribution archive
	mountdist	- locate and mount the distribution
	copydist	- copy the distribution into the file system

The following unfinished tasks are ready to be done:
	bootsetup	- create a boot floppy or configure hard disk to boot plan 9
	stop	- save the current installation state, to be resumed later

Task to do [bootsetup]: 

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

Initializing Plan 9 FAT configuration partition (9fat)

Initializing Plan 9 FAT partition.
add 9load at clust 2
Initializing FAT file system
type hard, 100 tracks, 64 heads, 32 sectors/track, 512 bytes/sec
Adding file /n/newfs/386/9load, length 217880
add 9load at clust 2
used 221184 bytes
% cp /n/newfs/386/9load /n/9fat/9load
% cp /n/newfs/386/9pcf /n/9fat/9pcf

There are myriad ways to boot a Plan 9 system.
You can use any of the following.

  floppy - create a boot floppy
  plan9  - make the plan 9 disk partition the default for booting
  win9x  - add a plan 9 option to windows 9x boot menu
  winnt  - add a plan 9 option to windows nt/2000/xp boot manager

If you are upgrading an extant third edition installation and booting
from something other than a floppy, you needn't run anything here.
Just type ctl-d.
Enable boot method (floppy, plan9, win9x, winnt)[no default]: plan9
If you use the Windows NT/2000/XP master boot record
or a master boot record from a Unix clone (e.g., LILO or
FreeBSD bootmgr), it is probably safe to continue using
that boot record rather than install the Plan 9 boot record.

Install the Plan 9 master boot record (y, n)[no default]: y
Setting Plan 9 partition active.

The Plan 9 partition is now marked as active.

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

Preparing menu...
The following tasks are done: 
	configfs	- choose the type of file system to install
	partdisk	- edit partition tables (e.g., to create a plan 9 partition)
	prepdisk	- subdivide plan 9 disk partition
	fmtfossil	- initialize disks for a fossil server
	mountfs	- choose and mount file system partition
	configdist	- choose the source of the distribution archive
	mountdist	- locate and mount the distribution
	copydist	- copy the distribution into the file system
	bootsetup	- create a boot floppy or configure hard disk to boot plan 9

The following unfinished tasks are ready to be done:
	finish	- finish the installation and reboot
	stop	- save the current installation state, to be resumed later

Task to do [finish]: 

--------------------------------------
We need to write the state of the current installation to the install floppy,
so that you can pick up from here if, for example, you want to set up
more boot methods.

Please make sure the install floppy is in the floppy drive and press enter.^T^Tr

ブートフロッピーの作成の段階で,"^T^Tr"と入力して,リブートする.

これでインストールはひとまず終了.後は,ターミナル版カーネルで起動する.初期ユーザとしてglendaが用意されている.

# xm create plan9term -c
create plan9term -c
Using config file "plan9term".
Started domain plan9

Plan 9
127 holes free
001b5000 01aa0000 26128384
26128384 bytes free
cpu0: 1598MHz GenuineIntel P6 (cpuid: AX 0x0695 DX 0xA7E9F9BF)
64M memory: 27M kernel data, 37M user, 165M swap
cpu0: spurious interrupt 101, last 0
sdxen: backend /local/domain/0/backend/vbd/7/2048/ secsize 512 sectors 2097152
#S/sd00/: part plan9 32 2097152
#S/sd00/: part 9fat 32 204832
#S/sd00/: part nvram 204832 204833
#S/sd00/: part fossil 204833 1892352
#S/sd00/: part swap 1892352 2097152
root is from (tcp, il, local)[local!#S/sd00/fossil]: 
user[none]: glenda
time...
fossil(#S/sd00/fossil)...version...time...

init: starting /bin/rc
#m/mousectl: rc: can't open: unknown device in # filename

init: starting /bin/rc
% rio
rio: can't open display: initdisplay: /dev/draw/new: unknown device in # filename
% lc
bin         lib         readme.acme readme.rio  tmp
% reboot

rioは起動できないね.そりゃそうか.とりあえず,今日はここまで.

*1:諸般の事情でLANが使えなかったので,今回はvifを無効化したが,有効にすべき.