== Why NetBSD? ==

NetBSD runs quite a bit better in small memory than linux does, and generally requires less disk space as well.  It is more stable under Xen than linux as well, and is very easily cross-compiled and bootstrapped if necessary for customization (most will probably not need this, but it is useful).  It also has an actual Xen DomU installer, which makes installation much easier than having to bootstrap and manually edit many configurations.  Clubwise, it supports Kerberos out of the box (the only thing which needs to be done is copy the config files).  OpenAFS is not supported, though ARLA may or may not work.  Lastly, it is always fun to try different things.

== How to Install NetBSD as a DomU on Club Infrastructure ==

On November 04, 2006, [http://netbsd.org/Releases/formal-3/NetBSD-3.1.html NetBSD 3.1] was released.  It included support for Xen 2 and Xen 3 DomU, and Xen2 Dom0.  Prior to this release, it was necessary to cross compile NetBSD-current, which could be rather time and disk consuming.  3.1 includes support out of the box, so this is no longer necessary.  So, the first step is obtain the installer:

 bohanlon@iodine:~/Documents/Projects/NetBSD$ '''wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-3.1/i386/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz'''

This is actually a gzipped kernel and ramdisk which are bootable in Xen.  I will assume that the disks are already set up, probably using lvm.  We need to do some special things in order to use NetBSD on a Linux Dom0.  First, because of the way that Xen figures out disks, we need to create a symbolic link in /dev:

 root@iodine:~/Documents/Projects/NetBSD# '''ln -s /dev/hda /dev/wd0d'''

This will allow NetBSD to find its disk.  Now, uncompress the installer image to /boot.  We then need to edit the DomU configuration file.  The important things are as follows:

 kernel = "/boot/netbsd-INSTALL_XEN3_DOMU" # This will change after installation
 root = "/dev/wd0d"

Edit the rest to suit your needs.  We are now ready to boot into the installer.  Assuming that the config is called "bohanlon",

 root@iodine:~# '''xm create bohanlon'''
 Using config file "/etc/xen/bohanlon".
 Started domain bohanlon
 root@iodine:~# '''xm console bohanlon'''

There will be a nice blue screen asking which language you desire to use to install.  The default options are English, French, German, Polish, and Spanish.  For this tutorial, we will use English.  After selecting a language, you will be asked what you desire to do.  You will probably want "Install NetBSD to hard disk", so choose that.  It will warn you about destroying info on your disk; choose to continue anyway.  Depending on your set up, it will say that it only found one disk "xbd0", or it will ask which one to configure.  We want to continue, and do a custom installation.  You will probably want to deselect X11 packages, and maybe games (though the BSD games are quite fun!)  The kernel that you choose here is irrelevant; you will not be booting of it.  When done, choose "install selected sets".

Now, you will be asked to set up the disklabel.  Typically, you will want partition "a" to be root, and "b" to be swap.  Partition "c" refers to the whole disk.  The rest can be set up however you like.  Remember that this disklabel is stored as one partition on the disk, so you need not have multiple virtual volumes for BSD.  When done, it will ask you to enter a name for your disk.  The default is probably okay; if not, choose your own.  It will then ask again whether to continue.  again, choose to do so.

It will slice the partition and create the filesystems.  Now, it asks whether to install the bootloader to use BIOS console, or a serial port.  I am not sure that this matters with Xen, but I always choose BIOS.  It then asks how you want to see the installation status; I like the progress bars, but again, it does not matter.  You will probably install from http or ftp, so choose one of those.  The network interface will be xennet0.  The network media type can be left blank; the DNS domain is club.cc.cmu.edu; the hostname is whatever you want; the ip address is whatever you want.  The gateway is 128.237.157.1; the name server is 128.237.157.12.  You probably do not want ipv6 autoconfig, but maybe you do.  It will now wait to bring up the network.  When done, it will ask you which directory to use for the tarballs; the default is probably okay.  Choose your servers for installation then (I find that ftp://ftp2.us.NetBSD.org is a good one), and it will download and install the sets for you.

You will be asked after the installation is done whether the networking information is good for regular use (it should be), and whether the installation tarballs should be deleted (they take up space).  After this, you are done with the nasty bit.

Now, you need to choose the timezone (most likely EST5EDT), as well as the encryption cypher.  Since you will probably be using kerberos, this does not matter as much, but choose one which would probably be good.  You will then be prompted to set the root password.  Do that.  Now, you must choose the shell for root.  /bin/ksh is probably a good choice, unless you like pure bourne or the c shell.  You are then informed that the installation is complete, and that you should edit /etc/rc.conf to suit you.  You are now done with the installation.

Exit the install system, and then type "halt -p".  Quit from the console (C-]), and then type "xm shutdown bohanlon".

== Booting and Configuring the New System ==

You now need to fetch the normal kernel, and then edit the config again

 bohanlon@iodine:~/Documents/Projects/NetBSD$ '''wget ftp://ftp2.us.netbsd.org/pub/NetBSD/NetBSD-3.1/i386/binary/kernel/netbsd-XEN3_DOMU.gz'''
 bohanlon@iodine:~/Documents/Projects/NetBSD$ '''su -m'''
 root@iodine:~/Documents/Projects/NetBSD# '''gunzip netbsd-XEN3_DOMU.gz'''
 root@iodine:~/Documents/Projects/NetBSD# '''cp netbsd-XEN3_DOMU /boot/'''
 root@iodine:~/Documents/Projects/NetBSD# '''vim /etc/xen/bohanlon'''

You need to change the kernel line of the config file to be the normal netbsd kernel:

 kernel = "/boot/netbsd-XEN3_DOMU"

Now, start up the domain.  You should see something like this on the console:

 NetBSD 3.1 (XEN3_DOMU) #0: Tue Oct 31 04:58:28 UTC 2006
        builds@b0.netbsd.org:/home/builds/ab/netbsd-3-1-RELEASE/i386/200610302053Z-obj/home/builds/ab/netbsd-3-1-RELEASE/src/sys/arch/i386/compile/XEN3_DOMU
 total memory = 61464 KB
 avail memory = 59972 KB
 mainbus0 (root)
 cpu0 at mainbus0: (uniprocessor)
 cpu0: Intel Pentium III (686-class), 497.43 MHz, id 0x672
 cpu0: features 383f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR>
 cpu0: features 383f9ff<PGE,MCA,CMOV,PAT,PSE36,MMX>
 cpu0: features 383f9ff<FXSR,SSE>
 cpu0: I-cache 16 KB 32B/line 4-way, D-cache 16 KB 32B/line 4-way
 cpu0: L2 cache 512 KB 32B/line 4-way
 cpu0: ITLB 32 4 KB entries 4-way, 2 4 MB entries fully associative
 cpu0: DTLB 64 4 KB entries 4-way, 8 4 MB entries 4-way
 cpu0: 32 page colors
 hypervisor0 at mainbus0
 debug virtual interrupt using event channel 3
 xenbus0 at hypervisor0: Xen Virtual Bus Interface
 xenbus0: using event channel 1
 xencons0 at hypervisor0: Xen Virtual Console Driver
 xencons0: console major 143, unit 0
 xencons0: using event channel 2
 npx0 at hypervisor0: using exception 16
 Xen clock: using event channel 4
 raidattach: Asked for 8 units
 Kernelized RAIDframe activated
 crypto: assign driver 0, flags 2
 crypto: driver 0 registers alg 1 flags 0 maxoplen 0
 crypto: driver 0 registers alg 2 flags 0 maxoplen 0
 crypto: driver 0 registers alg 3 flags 0 maxoplen 0
 crypto: driver 0 registers alg 4 flags 0 maxoplen 0
 crypto: driver 0 registers alg 5 flags 0 maxoplen 0
 crypto: driver 0 registers alg 17 flags 0 maxoplen 0
 crypto: driver 0 registers alg 6 flags 0 maxoplen 0
 crypto: driver 0 registers alg 7 flags 0 maxoplen 0
 crypto: driver 0 registers alg 15 flags 0 maxoplen 0
 crypto: driver 0 registers alg 8 flags 0 maxoplen 0
 crypto: driver 0 registers alg 16 flags 0 maxoplen 0
 crypto: driver 0 registers alg 9 flags 0 maxoplen 0
 crypto: driver 0 registers alg 10 flags 0 maxoplen 0
 crypto: driver 0 registers alg 13 flags 0 maxoplen 0
 crypto: driver 0 registers alg 14 flags 0 maxoplen 0
 crypto: driver 0 registers alg 11 flags 0 maxoplen 0
 crypto: driver 0 registers alg 18 flags 0 maxoplen 0
 xbd0 at xenbus0 id 768: Xen Virtual Block Device Interface
 xbd0: using event channel 5
 xennet0 at xenbus0 id 0: Xen Virtual Network Interface
 xennet0: MAC address 00:00:fe:eb:da:ed
 xennet0: using event channel 6
 xbd0: 3072 MB, 512 bytes/sect x 6291456 sectors
 Searching for RAID components...
 boot device: xbd0
 root on xbd0a dumps on xbd0b
 backend_changed backend
 mountroot: trying smbfs...
 mountroot: trying coda...
 mountroot: trying msdos...
 mountroot: trying cd9660...
 mountroot: trying ntfs...
 mountroot: trying nfs...
 mountroot: trying lfs...
 mountroot: trying ext2fs...
 mountroot: trying ffs...
 root file system type: ffs
 init: copying out path `/sbin/init' 11
 
 NetBSD/i386 (vorticon.club.cc.cmu.edu) (console)
 
 login:

You will now probably want to log in as root.  The first thing that you want to do is create a new user for yourself.  You will most likely copy the club /etc/passwd over, but for now, do not do that:
 
 vorticon# '''useradd -g wheel -m -s /bin/ksh -u 1251 bohanlon'''
 vorticon# '''passwd bohanlon'''

== Packages ==

Now, I recommend logging in as this user, then suing to root for rootish things.  You probably want to install some packages.  NetBSD uses the [http://www.netbsd.org/Documentation/software/packages.html pkgsrc] package system.  New packages are built and released around when new releases of NetBSD are made, as well as every three months.  Look at the ftp server to see what packages are available.  If the package that you want is not available as a binary, you can compile from source fairly easily (and this is what I prefer to do normally):

How to install packages:

 $ '''su -m'''
 Password:
 Nov 10 02:42:19 vorticon su: bohanlon to root on /dev/console
 # '''pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/packages-2006Q3/NetBSD-3.0/i386/shells/bash-3.1pl17.tgz'''
 # '''exit'''
 $ '''chsh'''

How to install from source:
 $ '''ftp ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc-current.tar.gz'''
 $ '''su -m'''
 # '''tar xzf pkgsrc-current.tar.gz -C /usr'''
 # '''cd /usr/pkgsrc/shells/bash'''
 # '''make install clean clean-depends'''

This will allow installation of packages.  Some things (shells, compilers, utilities) are available as packages, others may be available (zephyr, more esoteric programs), and some must be compiled from source (arla, and other things that require the kernel source in order to build).

More to come...

Other Informative Documentation/NetBSD DomU (last edited 2009-12-21 05:02:39 by localhost)