Changes between Initial Version and Version 1 of FreeBSD7.2_Guide


Ignore:
Timestamp:
Feb 22, 2010, 12:05:54 PM (16 years ago)
Author:
huub
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FreeBSD7.2_Guide

    v1 v1  
     1'''Howto build a 'nodefactory' based on FreeBSD 7.2'''[[BR]]
     2
     3----
     4
     5
     6= Procedure =
     7
     8Please note that you can find the supporting files in the subdirectory [source:nanobsd]. Also keep a close look at the ''INFO'' ''WARN'' ''ERR'' directives as they guide you through some common pitfalls. This is the original guide written for FreeBSD 7.2. As there are a lot of (positive) changes in the wireless stack, we now prefer the use of FreeBSD 8.0.
     9
     10==  A. Setup a FreeBSD host ==
     11----
     12WARN: Make sure ''/usr'' is '''at least 5GB''' in size building as building images require quite some space [[BR]]
     13WARN: Make sure you install the '''i386''' release of FreeBSD also when your system does support amd64, as cross compiling can give some nasty surprises [[BR]]
     14----
     15Get yourself a fresh i386 freebsd host with ports and subversion installed as follows:
     16
     17 A.1. Run the basic CD installer of 7.2.
     18The procedure below has been tested with 7.2-RELEASE (standard developer install - no ports - will fit our needs). Installing FreeBSD is outside the scope of this document, take a look into [http://www.freebsd.org/doc/en/books/handbook/install.html the FreeBSD handbook Chapter 2 Installing FreeBSD] if you do not know the details.
     19
     20 Please do mind that all commands below need to be executed as root, due to the many mounts and unmounts done in various phases.
     21
     22 Internet connection is required.
     23
     24 Set correct date/time, e.g.
     25 {{{
     26 $ ntpdate -s pool.ntp.org
     27 }}}
     28
     29 A.2. get latest sources
     30 {{{
     31 $ csup  -h cvsup.nl.freebsd.org /usr/share/examples/cvsup/standard-supfile
     32 }}}
     33
     34 
     35 A.3 fetch ports
     36 {{{
     37 $ portsnap fetch extract
     38 }}}
     39
     40 A.4 set some usefull variables
     41 
     42 Edit the shell configuration file .cshrc:
     43 {{{
     44 vi /root/.cshrc
     45 }}}
     46 check whether ftp is set to passive mode, to avoid potential firewall issues:
     47 {{{
     48 setenv FTP_PASSIVE_MODE YES
     49 }}}
     50 set a default password for the images that you will produce
     51 {{{
     52 setenv CFG_ROOT_PASSWORD [default password]
     53 }}}
     54 and define the svn download directory:
     55 {{{
     56 setenv R /root/nanobsd
     57 }}}
     58
     59 A.5. install subversion .
     60 NOTE: Install all packages via ports to prevent issues later on!
     61 {{{
     62 $ cd /usr/ports/devel/subversion; make install clean BATCH=yes
     63 }}}
     64
     65 A.6. OPTIONAL, every developer has his own preferences, these are mine ;-)
     66 {{{
     67 $ (cd /usr/ports/editors/vim-lite; make install clean BATCH=yes)
     68 $ (cd /usr/ports/security/sudo; make install clean BATCH=yes)
     69 $ (cd /usr/ports/sysutils/screen; make install clean BATCH=yes)
     70 }}}
     71
     72== B. Build environment ==
     73
     74 B.1 Download the environment from the Wireless Leiden svn repository
     75 {{{
     76 $
     77 $ svn checkout http://svn.wirelessleiden.nl/svn/projects/iris/nanobsd $R
     78 $ cd $R
     79 }}}
     80 Note: if svn is not found: svn is in /usr/local/bin, alternatively log out and in, or use {{{rehash}}} in a {{{csh}}} shell to make it available.
     81
     82 B.2. Compile all required packages using
     83 {{{
     84 $ /root/nanobsd/tools/package-build.sh
     85 }}}
     86 
     87 B.3. Set your favorite root password to be used in the image
     88
     89 Note: you can skip this step if you are satisfied with the default password set in step A.4 above.
     90
     91 {{{
     92 $ setenv CFG_ROOT_PASSWORD `dd if=/dev/random bs=10k count=10 | & tr -cd '[a-zA-Z0-9]' | cut -c -15`
     93 $ echo $CFG_ROOT_PASSWORD
     94 }}}
     95 If you like a simple password, substitute the {{{ `dd if=/dev/random bs=10k count=10 | & tr -cd '[a-zA-Z0-9]' | cut -c -15` }}} with your password.
     96
     97 B.4 Apply kernel patch for pcmcia LAN cards and USB-LAN adapter
     98
     99 If you want to be able to use pcmcia LAN cards, like the Xircom RealPort2 Cardbus Ethernet10/100 R2BE-100, you have to apply the patch to the cardbus driver before compiling the kernel:
     100 {{{
     101 cd /usr/src/sys/dev/cardbus
     102 patch < /root/nanobsd/misc/patches/cardbus_cis.c.patch
     103 }}}
     104
     105 For use of a Davicom DM9601 USB network controler you have to patch usbdevs and the if_udav driver:
     106 {{{
     107 cd /usr/src/sys/dev/usb/
     108 patch < /root/nanobsd/misc/patches/usbdevs.patch
     109 patch < /root/nanobsd/misc/patches/if_udav.c.patch
     110 }}}
     111
     112 B.5. Build nanobsd (make sure to prepare some coffee;-) )
     113 {{{
     114 $ sh /usr/src/tools/tools/nanobsd/nanobsd.sh -c /root/nanobsd/cfg/nanobsd.wleiden
     115 }}}
     116 Note 1: Take a coffee of go for a hike, this normally takes 2 - 8 hours depending on the machine configuration
     117
     118 Note 2: even this little script got flags, check the output of {{{sh /usr/src/tools/tools/nanobsd/nanobsd.sh -h}}}
     119 {{{
     120-b suppress builds (both kernel and world)
     121-k suppress buildkernel
     122-w suppress buildworld
     123-c specify config file
     124...
     125 }}}
     126
     127
     128== C. Fetch node configuration onto image, write to CF disk or remotely update ==
     129
     130C.1. Fetch configuration
     131
     132 {{{
     133 $ /root/nanobsd/tools/config-image.sh
     134 }}}
     135
     136The script is connecting to the [http://svn.wirelessleiden.nl/svn/node-config/genesis/nodes/ Wireless Leiden 'genesis' database]. First make sure that the configuration file is up to date by clicking the 'update' button on [http://wlconfig.wirelessleiden.nl/freebsd/iris/ http://wlconfig.wirelessleiden.nl/freebsd/iris/] Pick your situation!
     137
     138You can inspect the image bij mounting as memory disk:
     139{{{
     140mdconfig -a -t vnode -f /usr/obj/nanobsd.wleiden/_.disk.full
     141mount /dev/md0s1a /mnt
     142ls /mnt
     143umount /mnt
     144mount /dev/md0s3 /mnt
     145ls /mnt
     146umount /mnt
     147mdconfig -d -u 0
     148}}}
     149
     150
     151C.2. Write the correct image to CF (media based on SLC and not MLC flash seem to perform much better).
     152----
     153    ''NOTE:'' '''''_.disk.full''''' is required for '''new CF cards''' as it contains two base systems and one configuration. [[BR]]
     154              '''''_.disk.image''''' on the other hand can be used to update an '''existing CF card'''
     155----
     156
     157    a. '''New image''': Put full image on compact flash disk (attach a card reader/writer with a CF disk of minimum 1 GB)
     158    {{{
     159    $ dd bs=64k if=/usr/obj/nanobsd.wleiden/_.disk.full of=/dev/da0
     160    }}}
     161    (assuming {{{/dev/da0}}} is your compact flash entry; this takes about 15 minutes; you may wish to check afterwards with fdisk whether there
     162    are three partitions on the disk, you can also mount /dev/da0s1a and /dev/da0s3 and check the configuration)
     163
     164    a. '''Existing image''': Put partial image on slice (slice 2) (attach a card reader/writer with the CF disk containing the existing image)
     165    {{{
     166    $ dd bs=64k if=/usr/obj/nanobsd.wleiden/_.disk.image of=/dev/da0s2
     167    }}}
     168
     169    a. '''Existing image remote update''' (slice 2) (network connection to machine 172.x.y.z required)
     170
     171    For remotely updating an existing configuration use:
     172    {{{
     173    dd if=/usr/obj/nanobsd.wleiden/_.disk.image bs=10k | ssh root@172.x.y.z /tools/updatep2
     174    }}}
     175 
     176   You may adjust the block size to make the transfer more efficient (additionally ssh -C is possible) and you can use Ctrl-T to check progress.
     177
     178   NOTE: in case of a remote update from 7.2 to 8.0 you also have to run the configuration script (/tools/wl-config) because the configuration file rc.node.local is different.
     179 
     180== D. Check the cf card and apply last minute changes ==
     181
     182 D.1. Check cf card
     183
     184While the cf card is still in your flash card reader you can check whether the image has been written correctly. Check whether you can mount the partitions, e.g.
     185{{{
     186mount /dev/da0s1a /mnt
     187ls /mnt
     188umount /mnt
     189}}}
     190and the configuration partition:
     191{{{
     192mount /dev/da0s3 /mnt
     193ls /mnt
     194}}}
     195
     196If you cannot mount the partitions, take a fresh cf card and start again with writing the image.
     197
     198 D.2 apply wi-driver hack, if applicable
     199
     200If you are using wi-drivers in master mode (hostap) you may have to adjust the rc.node.local file on /dev/da0s3. There is a bug in the wi-driver: the channel is always set to 1. You can set the correct channel by adding a line to rc.node.local like:
     201{{{
     202ifconfig_wi0_alias0="channel {channel number}"
     203}}}
     204
     205 D.3 adjust lvrouted conf
     206If the node has a /28 subnet that should be routable modify the /conf/base/etc/rc.conf file:
     207{{{
     208lvrouted_flags="-u -m 28 -s s00p3rs3kr3t"
     209}}}
     210(for a /24 subnet use -m 24)
     211
     212 == E. All done! Load the machine ==
     213 Place the new CF disk in the machine and boot it up (existing nodes: just reboot), you should be good to go! Especially first time booting can take a long time, depending also on hardware. In a Soekris4521 this takes about ten minutes. You can follow the boot process using e.g. minicom or tip, via a serial connection (communication parameters: 9600 8N1).
     214
     215  Note 1. For subsequent nodes you can skip the build and go directly for step C, or take a look at development if you have to rebuild the image (after small changes).
     216
     217  Note 2. Check your bios version in case of booting problems (note: default communication setting for alix is 38400 8N1, bios should be 0.99h)
     218 
     219== F. Applying Updates ==
     220 For small changes there is a shortcut in the build (to save you some coffee ;-)). Pick the situation applicable
     221 1. First lets pump it's source to the latest version
     222 {{{
     223 $ svn up /root/nanobsd
     224 }}}
     225 2. Set your favorite root password to be used in the image
     226 {{{
     227 $ setenv CFG_ROOT_PASSWORD `dd if=/dev/random bs=10k count=10 | & tr -cd '[a-zA-Z0-9]' | cut -c -15`; echo $CFG_ROOT_PASSWORD
     228 }}}
     229 If you like a simple password, substitute the {{{ `dd if=/dev/random bs=10k count=10 | & tr -cd '[a-zA-Z0-9]' | cut -c -15` }}} with your password.
     230 3. Next step depends on the kind of changes:
     231    a. Only changes in kernel options - `kernel.wleiden` altered - ETA 0:45
     232    {{{
     233    $ sh /usr/src/tools/tools/nanobsd/nanobsd.sh -w -c /root/nanobsd/cfg/nanobsd.wleiden
     234    }}}
     235    a. Only changes in world options - `CONF_{BUILD,COMMON,INSTALL}` in  `nanobsd.wleiden` altered - ETA 2:00 - 6:00
     236    {{{
     237    $ sh /usr/src/tools/tools/nanobsd/nanobsd.sh -k -c /root/nanobsd/cfg/nanobsd.wleiden
     238    }}}
     239    a. _NO_ changes in build options - any other file altered - ETA 0:10
     240    {{{
     241    $ sh /usr/src/tools/tools/nanobsd/nanobsd.sh -b -c /root/nanobsd/cfg/nanobsd.wleiden
     242    }}}
     243
     244= G, Development =
     245
     246== Handy tools ==
     247Some handy tools are available in the /tools directory, such as
     248 * /tools/wl-version : to get information on the configuration that is running
     249 * /tools/image-build.sh for building images (replaces long command lines and prevents unintentional, time-consuming rebuilds; do not forget to '''setenv the root password'''!)
     250
     251== Light based packages suggestions ==
     252 * dnsmasq has been implemented instead of isc-dhcp30-server and bind
     253 * thttpd instead of apache
     254
     255== Further research ==
     256 * stumber `/usr/src/tools/tools/net80211/stumber`
     257
     258== Background ==
     259 * Packages needed are to be found in source:/nanobsd/tools/package-build.sh
     260 i.e.
     261 {{{
     262  $PORTSDIR/dns/dnsmasq
     263  $PORTSDIR/www/py-cherrypy
     264  $PORTSDIR/www/tinyproxy
     265  $PORTSDIR/editors/vim-lite
     266  $PORTSDIR/net-mgmt/net-snmp
     267  $PORTSDIR/net-mgmt/nrpe2
     268  $PORTSDIR/benchmarks/iperf
     269  $PORTSDIR/net/pen
     270  $PORTSDIR/net/rsync
     271  # Wireless Leiden ports at $WL_PORTSDIR
     272  $WL_PORTSDIR/net/lvrouted
     273  $WL_PORTSDIR/net/transproxy
     274  }}}
     275
     276== Testing Images ==
     277 * [wiki:KnownErrorMessages]
     278 * [wiki:TestingViaNFS]
     279 * [wiki:TestMatrix]
     280
     281== Hardware ==
     282 * Soekris 4521, bios version 1.23, 1.31b, 1.32, 1.33
     283 * Alix 2D3, only use latest bios: 0.99h
     284
     285 Note on updating Soekris bios (CTRL+P to enter): no luck with minicom, used cu on linux (Ubuntu: sudo apt-get install lrzsz cu):
     286{{{
     287chown uucp /dev/ttyS0
     288cu -l /dev/ttyS0 -s 9600
     289> download -
     290Start sending file using XMODEM/CRC protocol.
     291~+sx -X b4501_133.bin
     292Sending b4501_133.bin, 608 blocks: Give your local XMODEM receive command now.
     293Bytes Sent:  77824   BPS:892
     294Transfer complete
     295File downloaded succesfully, size 608 Blocks.
     296}}}
     297reboot
     298
     299= H. Hints =
     300 * You could always decide to install your FreeBSD base instance into a [http://www.freebsd.org/doc/en/books/handbook/virtualization-guest.html virtual environment]
     301 * {{{cvsup.nl.freebsd.org}}} is the local dutch cvsup mirror, replace `nl` with your proper country code
     302 * It seems tempting to follow {{{/usr/share/examples/cvsup/stable-supfile}}} instead of {{{/usr/share/examples/cvsup/standard-supfile}}} please __DO NOT__ unless your like big trouble as stable-supfile is the stable __DEVELOPMENT__ branch e.g. upcoming stable.
     303 * Default username/password = root/<blank>, so please do mind, _when no password is set ssh login is disabled_.
     304 * Always use `cu` or `putty` for serial communication minicom, screen, putty all issues of some kind.
     305= Comments, questions or remarks? =
     306Feel free to edit this page or [mailto:techniek@lijst.wirelessleiden.nl?subject=NanoBSD%20odefactory%improvement send an email] to our [http://lijst.wirelessleiden.nl/mailman/listinfo/techniek techniek mailinglist]
     307 * Handy .cshrc hints
     308{{{
     309alias quicknano sh /usr/src/tools/tools/nanobsd/nanobsd.sh -b -c /root/nanobsd/cfg/nanobsd.wleiden
     310alias slownano  sh /usr/src/tools/tools/nanobsd/nanobsd.sh -c /root/nanobsd/cfg/nanobsd.wleiden
     311alias slownewkernelnano sh /usr/src/tools/tools/nanobsd/nanobsd.sh -w -c /root/nanobsd/cfg/nanobsd.wleiden
     312alias slownewworldnano sh /usr/src/tools/tools/nanobsd/nanobsd.sh -k -c /root/nanobsd/cfg/nanobsd.wleiden
     313alias prepare-nfs  /root/nanobsd/tools/prepare-nfs.sh -f -n
     314}}}