How to build NetBSD on Linux

From NetBSD Wiki

Jump to: navigation, search

Contents

why build NetBSD on Linux ?

It is easy to do.

It could be very practical - in daily usage for sysadmins or just for evaluating the latest (current or release / stable) NetBSD for newbies.

There are many situations peoples need this.

build netbsd easy

This script is a easy way to take a look into the latest NetBSD for peoples wich are new to netbsd.

But a lot of peoples run a linux host within their network to provide and distribute many different open source distributions and builds for different machines. Most Xen hosts (Dom0) are linux based currently and many Xen admins provides a shared / automated pool of DomU installations and distributions from their Xen Dom0.

If you plan to use netbsd too this script is a easy way to get a current NetBSD installation CD (iso image), install sets for different installation types (by DOS, PXE network boot, floppies etc) and a full distribution tree for your target machine(s).

netbsd under XEN

In a Xen environment this distribution includes a specialized NetBSD kernel (XEN3_DOMU_NIELS) - optimized for high load servers and many users. The official XEN_DOMU build from NetBSD is not suitable for bigger server installations - but NetBSD is a very perfect server operating system.

customize your netbsd XEN DOMU kernel

You can customize your XEN DOMU kernel if you want.

For this just uncomment these two lines before you run the script netbsd-build.sh:

## uncomment the following two lines like this in case you will make / edit your own kernel config
$EDITOR ~/netbsd/XEN3_DOMU_NIELS
$EDITOR ~/netbsd/XEN2_DOMU_NIELS

i want no i386 netbsd (cross building)?

No prob, just change the ./build.sh machine option MARCH= (defaults to i386) to your target arch or machine as required (not tested yet, sorry).

Configuration

You have the option to change the configuration of this script if necessary. Just change it if you are knowing what you are doing.

If not the default config should work for most ursers and situations.

running the script

You should be on a shell (root is not necessary).

Download netbsd-build.sh and / or Copy this script "netbsd-build.sh" - i.e. to somewhere within your home directory.

Just run it by

sh netbsd-build.sh

The script creates a directory netbsd within your current home directory. Alternatively you can choose any other directory where you have write access.

The whole build would be done under this directory ($BUILDPATH).

#!/bin/sh
#####################################################
## netbsd-build.sh
## v1.0rc3
## this script builds a complete current netbsd
## distribution and a ready to use install CD/DVD
## image (iso image)
##
## features:
## - includes GENERIC netbsd kernel
## - includes a customized XEN DOMU kernel
## - optimized XEN DOMU for high load internet servers
## - includes or excludes X11
##
## (should be usable under each linux distribution
## and most unixes)
##
## by Niels Dettenbach <nd@syndicat.com>
## http://dettenbach.de
## licensed under the GPL

### usage:
## just copy this script to your home directory and
## execute i by:
## chmod +x ./netbsd-build.sh && ./netbsd-build.sh
##
## or just by:
## sh netbsd-build.sh

#####################################################
### CONFIGURATION
#
# The default configuration should work for most
# guys around. However - change configuration by
# comment / uncomment lines.

## target path of the netbsd build ##################

#build within home directory (~/netbsd/)
BUILDPATH=~
# or another path
#BUILDPATH=/mnt/backup2/soft/netbsd2


### select a CVS host ###############################

# main netbsd server
CVSHOST=anoncvs.netbsd.org
# sweden
#CVSHOST=anoncvs.se.netbsd.org
# UK
#CVSHOST=cvsup.uk.NetBSD.org



### select a NetBSD release #########################
#
# change this to select a particular netbsd release
# or branch

# builds a stable NetBSD 4.0 (latest stable)
#RELEASE=netbsd-4-0-RELEASE
RELEASE=netbsd-4-0-1-RELEASE
#RELEASE=netbsd-5
# NetBSD current (devel branch)
#RELEASE=.


### target machine ###################################
MARCH=i386



### select editor ##################################�#
# if you want to further edit kernel confiuration
# files

$EDITOR=nano
#$EDITOR=vi


#####################################################
cd $BUILDPATH
mkdir ./netbsd
cd ./netbsd
mkdir kernel obj release src tools xsrc

## get extra kernel config for XEN DOMU internet servers
cd $BUILDPATH/netbsd/kernel
wget http://www.syndicat.com/pub/netbsd/kernel/XEN3_DOMU_NIELS
wget http://www.syndicat.com/pub/netbsd/kernel/XEN2_DOMU_NIELS

## uncomment the following two lines in case you will make your own kernel config
#$EDITOR $BUILDPATH/netbsd/XEN3_DOMU_NIELS
#$EDITOR $BUILDPATH/netbsd/XEN2_DOMU_NIELS

## cvs checkpout the current cvs sources
cd $BUILDPATH/netbsd/
export CVSROOT=anoncvs@$CVSHOST:/cvsroot
export CVS_RSH=ssh
cvs co -r $RELEASE -P src
cvs co -r $RELEASE -P xsrc

## link in custom kernel config
ln -s $BUILDPATH/netbsd/kernel/XEN3_DOMU_NIELS $BUILDPATH/netbsd/src/sys/arch/$MARCH/conf/
ln -s $BUILDPATH/netbsd/kernel/XEN2_DOMU_NIELS $BUILDPATH/netbsd/src/sys/arch/$MARCH/conf/

## build run
## see $BUILDPATH/netbsd/src/BUILDING for details about all the nice build.sh options
cd $BUILDPATH/netbsd/src
sh build.sh -m $MARCH -O ../obj -T ../tools -X ../xsrc/ -R ../release -j2 -U -u -r tools kernel=XEN3_DOMU_NIELS release releasekernel=XEN3_DOMU_NIELS iso-image

## show all generated kernels:
echo "Your generated kernels:"
ls -alh $BUILDPATH/netbsd/release/$MARCH/binary/kernel/

## go to and show the install CD image (iso)
echo "Here you get your NetBSD ISO image (install CD):"
cd $BUILDPATH/netbsd/release/iso/
pwd && ls -alh
echo "burn it on CD-ROM and boot it"
echo "have a lot of fun with NetBSD!"
### end ###############################################

If the script does his job as expected you should see something like:

-r--r--r-- 1 niels users 165M 23. Sep 13:13 i386cd.iso

This is your NetBSD installation ISO image - burn it to a CD or use it within virtualisation (Xen, VMware, Virtualbox etc.) or mount it locally (as a virtual cdrom) by:

mount -o loop /home/'your username'/netbsd/release/iso/i386cd.iso /mnt/cdrom

links

weblinks

Personal tools