Place Ghantoos

My first shot of NetBSD (5.0)

Tagged:

As I heard a lot about NetBSD lately, especially with NetBSD5.0 being released, I thought I would give it a try.

I admit, I had a preconceived idea of what I was going to face. I thought I would have to go a couple of time through the installer, try to understand how to use the partitioner, etc. But I was wrong. Ten minutes after booting up the iso image, my first NetBSD was up and running!

Even though all this documentation is available in the NetBSD guide, here are all the steps I went through to install my machine.

My installation was done using kvm-84 on a debian (testing) machine.

1- Installation

First create the image you want to use.
Make sure you create a QCOW2 image and NOT QCOW. It seems NetBSD doesn’t like writing on a QCOW image which makes your NetBSD installation _very_ slow.

$ qemu-img create img-netbsd5.0.img -f qcow2 10G

Here is the script I used to launch the installation (thank you iMil for the tdf & no-kvm-pit flags!). After the installation, you just need to comment out the “cdrom” line.

$ vi kvm_netbsd5.0.sh
--------------------------------------------------------------------------------
#!/bin/sh

/usr/local/bin/qemu-system-x86_64 -hda /home/ghantoos/kvm/img-netbsd5.0.img \
        -net nic,model=ne2k_pci,macaddr=10:01:02:03:04:13 \
        -net tap,ifname=tap6,script=/home/ghantoos/kvm/qemu-ifup \
        -m 512 \
        -smp 1 \
        -no-acpi \
        -localtime \
        -tdf \
        -no-kvm-pit \
        -cdrom /home/ghantoos/distrib/i386cd-5.0.iso -boot d
#        -curses

Note: When booting on a kvm based virtual machine, be careful to choose the 3rd boot option: Install NetBSD (no ACPI, no SMP).
The installation phase is quite straight forward. The part where you will have to enter “something” is when asked for the size of the partitions.
The partitions will be listed (no need to invent a partition table), you just need to enter the size of each slice. Here is what I did (this doesn’t mean that’s the way to do it):

Mount point        Size Allocated
/                  124M
/var               485M
/usr               3.9G
/home              1.2G

2- Configuration

Note: If you are testing this on a kvm based virtal machine, be careful to choose the boot 4th option: Disable ACPI & SMP.

* Network & sshd

The first thing to do now, is enable sshd & dhclient (if you are not using a dhcp server, refer to this doc to setup your network):

# vi rc.conf
--------------------------------------------------------------------------------
sshd=YES
dhclient=YES

Then you can start the two services this way:

# /etc/rc.d/dhclient start
# /etc/rc.d/sshd start
* Default boot option

This part only concerns those want to change the default boot option (especially KVM users, unless you want to choose manually at every boot).

# vi /boot.cfg
--------------------------------------------------------------------------------
menu=Boot normally:boot netbsd
menu=Boot single user:boot netbsd -s
menu=Disable ACPI:boot netbsd -2
menu=Disable ACPI and SMP:boot netbsd -12
menu=Drop to boot prompt:prompt
default=4  <--- changed from 1 to 4, as in "Disable ACPI and SMP"
timeout=5
* Add your user

By default, sshd doesn't accept root connections, which is a very good thing. So you should create a user, and give him enough rights by adding him to the wheel group:

# useradd -m ghantoos
# usermod -G wheel ghantoos

Note: At this point, what I did was halt my kvm virtual machine, uncomment the -curses (see Installation), and restart my virtual machine inside a screen ;)

* Install sets

In case you chose the minimal installation only 3 "sets" will be installed: base.tgz, etc.tgz and kern-GENERIC.tgz.
You can of course install other sets after the installation procedure. For example, you might want to install the man pages set (man.tgz) and the compiler set (comp.tgz) (installed by default in the full installation):

# ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.0/i386/binary/sets/man.tgz
# tar xvfzp man.tgz -C /

# ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.0/i386/binary/sets/comp.tgz
# tar xvfzp comp.tgz -C /
* Setup make options

You can now ssh to you machine, and start installing stuff.
Before installing anything, you should add the desired make option in /etc/mk.conf.
Considering that this machine will not use X, I added an option to prevent anything that is related to X from being built:

# vi /etc/mk.conf
--------------------------------------------------------------------------------
MKX11=no
CLEANDEPENDS=yes
MASTER_SORT=.fr .uk .de

"CLEANDEPENDS=yes": lets make install clean also clean the installed dependencies
"MASTER_SORT=.fr .uk .de": sets the preferred download site from .fr then .uk then .de, then all the rest
(thank you iMil for the tips!)

For more information about flags that can be set: man mk.conf
You must also read: pkgsrc's configuration page

* Setup pkgsrc

pkgsrc is the NetBSD Packages Collection. In other words, you will use it to install the software you need on you NetBSD machine. By default the port collection is not installed. You can find a very detailed documentation in the pkgsrc guide. Here what I did:

$ su
# ftp ftp://ftp.netbsd.org/pub/pkgsrc/pkgsrc-2009Q1/pkgsrc-2009Q1.tar.gz
# tar xvfz pkgsrc-2009Q1.tar.gz -C /usr/

As the filename states, this is the port tree of 2009Q1 (1rst quarter of 2009). You should update it using one of the options listed here. I chose to update it using anonymous CVS. You can find your nearest anonCVS mirror here.
Note 1: cvs might not be installed by default, I installed it using pkg_add:
Note 2: You need to unset PKG_PATH after using pkg_add in order to use pkgsrc

# export PKG_PATH="ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/5.0/All" 
# pkg_add -v cvs
# unset PKG_PATH

Then update you pkgsrc tree:

# export CVSROOT=anoncvs@anoncvs.fr.NetBSD.org:/pub/NetBSD-CVS
# export CVS_RSH=ssh
# cd /usr/pkgsrc
# cvs update -dP
* Install ports

Now that your port tree is up-to-date. You can start installing the ports you need.
A port that is quite useful to search and find the ports inside the tree in pkgfind (I first tried to used make search key=foo, but it take a while to build its database, so ^C).

# cd /usr/pkgsrc/
# cd pkgtools/pkgfind
# make install clean

# pkgfind sudo  
games/fltk-sudoku: FLTK example Sudoku game creator and solver
games/sudoku-cli: Commandline version of sudoku board game
security/sudo: Allow others to run commands as root
wip/sudoscript: Audited shells with sudo(8) and script(1)

# cd /usr/pkgsrc/security/sudo
# make install clean
* Get the WIP ports

pkgsrc WIP means pkgsrc -work in progress-. Here you can find ports that haven't been included yet in the official pkgsrc port tree.
Note that packages in WIP are not guaranteed to work/install nicely as it is a "semi-public" port repository.
As explained in the pkgsrc-wip project page, here is how I got these ports:

# cvs -d:pserver:anonymous@pkgsrc-wip.cvs.sourceforge.net:/cvsroot/pkgsrc-wip login
# cvs -z3 -d:pserver:anonymous@pkgsrc-wip.cvs.sourceforge.net:/cvsroot/pkgsrc-wip checkout -P wip
# mv wip /usr/pkgsrc/

All WIP ports can now be found in /usr/pkgsrc/wip
To keep these ports up-to-date:

# cd /usr/pkgsrc/wip/
# cvs update -dP

3- Conclusion

I hope this will help some of you who haven't tried NetBSD, to go ahead and test it.

As I said in the "introduction" of this post, I was very surprised to discover how flawless the installation (and minimal configuration) of a NetBSD machine actually is.

In case you have any comment/suggestion please do not hesitate.

Cheers,
Ignace M -ghantoos-

Sources:

http://netbsd.org/docs/guide/en/
http://netbsd.org/docs/guide/en/chap-boot.html
http://www.netbsd.org/docs/pkgsrc/using.html
http://www.netbsd.org/docs/pkgsrc/getting.html
http://pkgsrc.se/
http://imil.net/wp/ (fr)
http://www.gcu.info/ (fr)
http://www.unixgarden.com/index.php/administration-systeme/zone0-le-serveur-presque-parfait (fr)

Tagged:

4 Responses

  1. j says:

    Glad to hear it went well.

    I hope one day you have an opportunity to run NetBSD on real hardware — like operating systems are really meant to be run.

  2. Patrick says:

    Thanks for this! After hours and hours of failed trial and error trying to get netbsd5 installed as a kvm guest *with* a functioning NIC, I finally found your tips here, and it got the job done.

    Typo alert: “# /etc/rc.d/ssd start” –> “# /etc/rc.d/sshd start”

    Also, at the end of install, I chose America/LosAngeles as my timezone. After restarting the guest, my installation was unbootable, even choosing boot option #4. I started the installation again from scratch and was careful to choose UTC instead. This time I had no such problem booting the installed system. Not sure if UTC is necessary or not, or what the deal was, but maybe it is worth noting.

  3. Thank you Patrick for pointing out this typo. It has been corrected.

    It is a weird bug you faced with the timezones. Thanks for telling us about it!

  4. [...] a goûté son premier verre de NetBSD, et il a aimé. Son billet sur cette experience décrit comment en deux coups de cuiller à pot, il s’est monté une gentille VM NetBSD 5.0 [...]

Leave a Reply

FireStats

  • Pages displayed : 497710
  • Unique visitors : 232051
  • Pages displayed in last 24 hours : 325
  • Unique visitors in last 24 hours : 210