Annotation of wikisrc/tutorials/how_to_install_netbsd_on_the_linksys_nslu2___40__slug__41___without_a_serial_port__44___using_nfs_and_telnet.mdwn, revision 1.3

1.1       mspo        1: **Contents**
                      2: 
                      3: [[!toc levels=3]]
                      4: 
                      5: #Introduction
                      6: 
                      7: The standard kernel that you build for the NSLU2 requires that the Slug be modified to provide a serial port so that you can interact with the Slug during the boot process and to log in. This page will show you how to boot your Slug into NetBSD using only an ethernet connection. The strategy is to configure and build the kernel so that it automatically finds and mounts the root disk through DHCP and NFS without requiring that we type in the location of the root drive through the serial port. The root disk is a modification of the typical setup that allows an insecure telnet login to the NetBSD kernel running on the NSLU2. Once logged in, you can set up a username and password, enable ssh, and close out the insecure telnet connection.
                      8: 
                      9: The command line instructions that follow are for a Linux system using bash. They should be pretty much the same for another *nix system, except for the differences due to the shell.
                     10: 
                     11: #Get the source code
                     12: 
                     13: To get the source code (current):
                     14: 
                     15:     $ mkdir ~/net
                     16:     $ export CVS_RSH="ssh"
                     17:     $ export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
                     18:     $ cd ~/net
                     19:     $ cvs checkout -A -P src
                     20: 
                     21: */!\ The CVS address didnt work for me. I used: **export CVSROOT="anoncvs@anoncvs.se.NetBSD.org:/cvsroot"** /!\*
                     22: 
                     23: This will create a directory ~/net/src with the source tree in it.
                     24: 
                     25: See the section below (*Versions that are known to work*) to get an older version of NetBSD-current that should build and boot correctly. This section also has an update for changes to build.sh. 
                     26: 
                     27: #Build the kernel
                     28: 
                     29: **Note: The procedure shown here works for versions of NetBSD before about August 5, 2008. See the section below (Versions that are known to work) for changes to the three build.sh command lines.**
                     30: 
                     31: First, build the tools.
                     32: 
                     33:     $ cd ~/net/src
                     34:     $ ./build.sh -m evbarm -a armeb tools
                     35: 
                     36: You need to get the Intel proprietary firmware for the NSLU2 ethernet controller. Follow the instructions at this location: <~/net/src/sys/arch/arm/xscale/ixp425-fw.README.> After building the firmware as described in the readme file, copy the file "IxNPEMicrocode.dat" to the directory ~/net/src/sys/arch/arm/xscale (the same directory as the README).
                     37: 
                     38: **NOTE:** *Versions 3.0 and later of the Intel firmware don't work.  Use version 2.3.2 or 2.4.*
                     39: 
                     40: We'll build three versions of the kernel, though only one will be used here. The other two kernels will be used when we move from mounting NetBSD using an NFS root to a disk drive connected to one of the USB ports. Add a configuration file, NSLU2_ALL, with the configuration for the three kernels. This file goes in the same directory as the standard NSLU2 configuration file. Note that we're including the standard file in our configuration file.
                     41: <pre><code>
                     42: $ cd ~/net/src/sys/arch/evbarm/conf
                     43: $ echo 'include "arch/evbarm/conf/NSLU2"' >NSLU2_ALL
                     44: $ echo 'config netbsd-nfs root on npe0 type nfs' >>NSLU2_ALL
                     45: $ echo 'config netbsd-sd0 root on sd0a type ffs' >>NSLU2_ALL
                     46: $ echo 'config netbsd-sd1 root on sd1a type ffs' >>NSLU2_ALL
                     47: $ cat NSLU2_ALL
                     48: include "arch/evbarm/conf/NSLU2"
                     49: config netbsd-nfs root on npe0 type nfs
                     50: config netbsd-sd0 root on sd0a type ffs
                     51: config netbsd-sd1 root on sd1a type ffs
                     52: </code></pre>
                     53: Now build everything. (Much appreciation to Iain Hibbert for his help in understanding build.sh and its numerous configuration variables!)
                     54: 
                     55:     $ cd ~/net/src
                     56:     $ ./build.sh -u -U -m evbarm -a armeb build
1.2       riastrad   57:     $ ./build.sh -u -U -m evbarm -a armeb -V ALL_KERNELS=NSLU2_ALL release
1.1       mspo       58: 
                     59: When finished, you'll find all of the necessary files in ~/net/src/obj/releasedir/evbarm/binary/sets.
                     60: <pre><code>
                     61: $ ls -la ~/net/src/obj/releasedir/evbarm/binary/sets/
                     62: total 116200
                     63: drwxr-xr-x 2 owner owner     4096 2008-03-07 10:22 .
                     64: drwxr-xr-x 5 owner owner     4096 2008-03-07 10:19 ..
                     65: -rw-rw-r-- 1 owner owner 24189627 2008-03-07 10:21 base.tgz
                     66: -rw-rw-r-- 1 owner owner      272 2008-03-07 10:22 BSDSUM
                     67: -rw-rw-r-- 1 owner owner      366 2008-03-07 10:22 CKSUM
                     68: -rw-rw-r-- 1 owner owner 33559987 2008-03-07 10:21 comp.tgz
                     69: -rw-rw-r-- 1 owner owner   369051 2008-03-07 10:21 etc.tgz
                     70: -rw-rw-r-- 1 owner owner  3233648 2008-03-07 10:21 games.tgz
                     71: -rw-rw-r-- 1 owner owner 25920807 2008-03-07 10:19 kern-ADI_BRH.tgz
                     72: -rw-rw-r-- 1 owner owner  1267036 2008-03-07 10:19 kern-IXM1200.tgz
                     73: -rw-rw-r-- 1 owner owner  8615170 2008-03-07 10:19 kern-NSLU2_ALL.tgz
                     74: -rw-rw-r-- 1 owner owner  2872331 2008-03-07 10:19 kern-NSLU2.tgz
                     75: -rw-rw-r-- 1 owner owner  8455973 2008-03-07 10:22 man.tgz
                     76: -rw-rw-r-- 1 owner owner      632 2008-03-07 10:22 MD5
                     77: -rw-rw-r-- 1 owner owner  3318310 2008-03-07 10:22 misc.tgz
                     78: -rw-rw-r-- 1 owner owner     1820 2008-03-07 10:22 SHA512
                     79: -rw-rw-r-- 1 owner owner      274 2008-03-07 10:22 SYSVSUM
                     80: -rw-rw-r-- 1 owner owner  3815709 2008-03-07 10:22 tests.tgz
                     81: -rw-rw-r-- 1 owner owner  3073516 2008-03-07 10:22 text.tgz
                     82: </code></pre>
                     83: The kern-ADI_BRH.tgz and kern-IXM1200.tgz are kernels for other ARM boards that are built automatically when you specify -m evbarm. We won't use them. 
                     84: 
                     85: #Set up the NFS file system
                     86: 
                     87: To setup the NFS server, see http://www.netbsd.org/docs/network/netboot/nfs.html and http://www.netbsd.org/docs/network/netboot/files.html. NOTEThe instructions that follow are written for system configurations where the NFS/tftp/DHCP server is a different machine than your build machine. If they are the same system, then ignore the ssh and scp commands.
                     88: 
                     89: Log into the nfs server using ssh, and setup the NetBSD file structure:
                     90: 
                     91:     $ sudo mkdir -p /export/client/root/dev
                     92:     $ sudo mkdir /export/client/home
                     93:     $ sudo touch /export/client/swap
                     94:     $ sudo dd if=/dev/zero of=/export/client/swap bs=4k count=4k
                     95:     $ sudo chmod 600 /export/client/swap
                     96:     $ sudo mkdir /export/client/root/swap
                     97: 
                     98: Copy the necessary files from the build machine to the NFS system. On your build machine:
                     99: 
                    100:     $ cd ~/net/src/obj
                    101:     $ scp -r releasedir/evbarm/binary/sets nfsserver:/export/client
                    102: 
                    103: Build the NetBSD root file system on the NFS server:
                    104: 
                    105:     $ cd /export/client/root
                    106:     $ sudo tar --numeric-owner -xvpzf /export/client/releasedir/evbarm/binary/sets/base.tgz
                    107:     $ sudo tar --numeric-owner -xvpzf /export/client/releasedir/evbarm/binary/sets/comp.tgz
                    108:     $ sudo tar --numeric-owner -xvpzf /export/client/releasedir/evbarm/binary/sets/etc.tgz
                    109:     $ sudo tar --numeric-owner -xvpzf /export/client/releasedir/evbarm/binary/sets/games.tgz
                    110:     $ sudo tar --numeric-owner -xvpzf /export/client/releasedir/evbarm/binary/sets/man.tgz
                    111:     $ sudo tar --numeric-owner -xvpzf /export/client/releasedir/evbarm/binary/sets/misc.tgz
                    112:     $ sudo tar --numeric-owner -xvpzf /export/client/releasedir/evbarm/binary/sets/tests.tgz
                    113:     $ sudo tar --numeric-owner -xvpzf /export/client/releasedir/evbarm/binary/sets/text.tgz
                    114: 
                    115: The next part is slightly more complicated for the two-system configuration. To make the /dev directory for the NFS file system, mount the NFS file system on your build machine:
                    116: 
                    117:     $ sudo mount -t nfs nfsserver:/export/client/root /mnt/root
                    118:     $ cd /mnt/root/dev
                    119: 
                    120: Then execute the MAKEDEV shell script from your build machine. Skip the mounting part if you use only one system.
                    121: 
                    122:     $ sudo sh ./MAKEDEV -m ~/net/src/obj/tooldir.YOUR.SYSTEM.HERE/bin/nbmknod all
                    123: 
                    124: Save the original NetBSD /etc directory, just in case you would like to refer to it later:
                    125: 
                    126:     $ sudo cp -r /export/client/root/etc /export/client/root/orig.etc
                    127:     $ cd /export/client/root/etc
                    128: 
                    129: Setup the various files in the exported etc so that the system will boot up and allow logins via telnet. The edit command is shown, along with the final file configuration, except for inetd.conf which is very long.
                    130: 
                    131: ##/export/client/root/etc/hosts
                    132: 
                    133:     $ sudo nano hosts
                    134: <pre><code>
1.3     ! sevan     135: #      $NetBSD: how_to_install_netbsd_on_the_linksys_nslu2___40__slug__41___without_a_serial_port__44___using_nfs_and_telnet.mdwn,v 1.2 2015/05/28 21:08:14 riastradh Exp $
1.1       mspo      136: #
                    137: # Host Database
                    138: # This file should contain the addresses and aliases
                    139: # for local hosts that share this file.
                    140: # It is used only for "ifconfig" and other operations
                    141: # before the nameserver is started.
                    142: #
                    143: #
                    144: ::1                    localhost localhost.
                    145: 127.0.0.1              localhost localhost.
                    146: #
                    147: # RFC 1918 specifies that these networks are "internal".
                    148: # 10.0.0.0     10.255.255.255
                    149: # 172.16.0.0   172.31.255.255
                    150: # 192.168.0.0  192.168.255.255
                    151: 192.168.1.102  nfsserver  # my NFS server
                    152: 192.168.1.240  slug1           # my NSLU2
                    153: </code></pre>
                    154: 
                    155: ##/export/client/root/etc/fstab
                    156: 
                    157:     $ sudo nano fstab
                    158: 
                    159:     #/etc/fstab
                    160:     nfsserver:/client/swap   none  swap  sw,nfsmntpt=/swap
                    161:     nfsserver:/client/root   /     nfs   rw 0 0
                    162: 
                    163: ##/export/client/root/etc/ifconfig.npe0
                    164: 
                    165:     $ sudo nano ifconfig.npe0
                    166: 
                    167:     inet client netmask 255.255.255.0 broadcast 192.168.1.255
                    168: 
                    169: ##/export/client/root/etc/inetd.conf
                    170: <pre><code>
                    171: $ sudo nano inetd.conf
                    172: 
                    173: Change the two lines:
                    174: 
                    175: #telnet         stream  tcp     nowait  root    /usr/libexec/telnetd    telnetd -a valid 
                    176: #telnet         stream  tcp6    nowait  root    /usr/libexec/telnetd    telnetd -a valid 
                    177: 
                    178: to
                    179: 
                    180: telnet          stream  tcp     nowait  root    /usr/libexec/telnetd    telnetd 
                    181: telnet          stream  tcp6    nowait  root    /usr/libexec/telnetd    telnetd 
                    182: </code></pre>
                    183: ##/export/client/root/etc/rc.conf
                    184: <pre><code>
                    185: $ sudo nano rc.conf
                    186: 
1.3     ! sevan     187: #      $NetBSD: how_to_install_netbsd_on_the_linksys_nslu2___40__slug__41___without_a_serial_port__44___using_nfs_and_telnet.mdwn,v 1.2 2015/05/28 21:08:14 riastradh Exp $
1.1       mspo      188: #
                    189: # see rc.conf(5) for more information.
                    190: #
                    191: # Use program=YES to enable program, NO to disable it. program_flags are
                    192: # passed to the program on the command line.
                    193: #
                    194: # Load the defaults in from /etc/defaults/rc.conf (if it's readable).
                    195: # These can be overridden below.
                    196: #
                    197: if [ -r /etc/defaults/rc.conf ]; then
                    198:         . /etc/defaults/rc.conf
                    199: fi
                    200: 
                    201: # If this is not set to YES, the system will drop into single-user mode.
                    202: #
                    203: rc_configured=YES
                    204: # Add local overrides below
                    205: #
                    206: sshd=YES
                    207: hostname="slug1"
                    208: defaultroute="192.168.1.1"
                    209: nfs_client=YES
                    210: auto_ifconfig=NO
                    211: net_interfaces=""
                    212: </code></pre>
                    213: 
                    214: ##/export/client/root/etc/ttys
                    215: <pre><code>
                    216: $ sudo nano ttys
                    217: 
1.3     ! sevan     218: #      $NetBSD: how_to_install_netbsd_on_the_linksys_nslu2___40__slug__41___without_a_serial_port__44___using_nfs_and_telnet.mdwn,v 1.2 2015/05/28 21:08:14 riastradh Exp $
1.1       mspo      219: #
                    220: #      from: @(#)ttys  5.1 (Berkeley) 4/17/89
                    221: #
                    222: # name getty                           type    status          comments
                    223: #
                    224: console        "/usr/libexec/getty default"    vt100   on secure
                    225: ttyp0  "/usr/libexec/getty Pc"         vt100   off secure
                    226: ttyE0  "/usr/libexec/getty Pc"         vt220   off secure
                    227: ttyE1  "/usr/libexec/getty Pc"         vt220   off secure
                    228: ttyE2  "/usr/libexec/getty Pc"         vt220   off secure
                    229: ttyE3  "/usr/libexec/getty Pc"         vt220   off secure
                    230: tty00  "/usr/libexec/getty default"    unknown off secure
                    231: tty01  "/usr/libexec/getty default"    unknown off secure
                    232: tty02  "/usr/libexec/getty default"    unknown off secure
                    233: tty03  "/usr/libexec/getty default"    unknown off secure
                    234: tty04  "/usr/libexec/getty default"    unknown off secure
                    235: tty05  "/usr/libexec/getty default"    unknown off secure
                    236: tty06  "/usr/libexec/getty default"    unknown off secure
                    237: tty07  "/usr/libexec/getty default"    unknown off secure
                    238: </code></pre>
                    239: 
                    240: #Setup the tftp, NFS, and DHCP servers
                    241: 
                    242: Now, setup tftp, NFS, and DHCP. On my Fedora 7 system, I use the following setup. Please note that the files shown below are believed to be correct, but if tftp, NFS, or DHCP isn't working for you, try Googling “<service name> <operating system> howto”. Also, check your SELinux settings – mine were preventing the slug from attaching to the NFS files. Remember - the kern-NSLU2_ALL.tgz was copied to the NFS server /export/client directory in the previous section. (NB: It wouldn't be a bad idea for somebody to add the settings required for a NetBSD system here.) As in the previous section, edit or create the files as necessary using nano or your favorite text editor.
                    243: 
                    244:     $ cd /export/client/root
                    245:     $ sudo tar --numeric-owner -xvpzf /export/client/releasedir/evbarm/binary/sets/kern-NSLU2_ALL.tgz
                    246:     $ cp *.bin /tftpboot
                    247:     $ sudo chmod 666 /tftpboot/*bin
                    248: 
                    249: ##/etc/hosts
                    250: 
                    251:     192.168.1.240           slug1 
                    252:     192.168.0.1             redboot 
                    253:     192.168.1.102              your_host_name #use your host address
                    254: 
                    255: ##/etc/hosts.allow
                    256: 
                    257:     in.tftpd:   192.168.0.1
                    258:     rpcbind:    192.168.1.240 
                    259:     lockd:      192.168.1.240 
                    260:     rquotad:    192.168.1.240 
                    261:     mountd:     192.168.1.240 
                    262:     statd:      192.168.1.240 
                    263: 
                    264: ##/etc/xinetd.d/tftp
                    265: <pre><code>
                    266: service tftp 
                    267: { 
                    268:         disable = no 
                    269:         socket_type             = dgram 
                    270:         protocol                = udp 
                    271:         wait                    = yes 
                    272:         user                    = root 
                    273:         server                  = /usr/sbin/in.tftpd 
                    274:         server_args             = -s /tftpboot 
                    275:         per_source              = 11 
                    276:         cps                     = 100 2 
                    277:         flags                   = IPv4 
                    278: } 
                    279: </code></pre>
                    280: 
                    281: ##/etc/dhcpd.conf
                    282: <pre><code>
                    283: ddns-update-style ad-hoc; 
                    284: option subnet-mask 255.255.255.0; 
                    285: option broadcast-address 192.168.1.255; 
                    286: option domain-name-servers xxx.xxx.xxx.xxx; #Use your nameserver address
                    287: default-lease-time 2592000; 
                    288: allow bootp; 
                    289: allow booting;  
                    290: 
                    291: #option ip-forwarding    false;  # No IP forwarding 
                    292: #option mask-supplier    false;  # Don't respond to ICMP Mask req  
                    293: 
                    294: subnet 192.168.1.0 netmask 255.255.255.0 { 
                    295:         option routers        192.168.1.1; 
                    296:         range 192.168.1.110 192.168.1.189; 
                    297:         } 
                    298: 
                    299: group   { 
                    300:       next-server 192.168.1.102;          # IP address of your TFTP server 
                    301:       option routers 192.168.1.1; 
                    302:       default-lease-time 2592000; 
                    303:       host slug1 { 
                    304:                 hardware ethernet 00:18:39:a2:26:7c; 
                    305:                 fixed-address 192.168.1.240;
                    306:                 option root-path "/client/root"; 
                    307:                 } 
                    308:         } 
                    309: </code></pre>
                    310: 
                    311: ##/etc/exports
                    312: 
                    313: /export/client/root 192.168.1.0/255.255.255.0(rw,sync,no_root_squash)
                    314: /export/client/swap 192.168.1.0/255.255.255.0(rw,sync,no_root_squash)
                    315: 
                    316: #Interrupting Slug bootup using telnet
                    317: 
                    318: Unless we modify the flash memory of the Slug, the normal boot process is to load RedBoot, wait a few seconds, then load a kernel and memory disk image from flash and execute it. This process can be interrupted if you install a serial port by typing a ^C within two seconds after seeing the following message appear on the serial port screen:
                    319: 
                    320:     RedBoot(tm) bootstrap and debug environment [ROMRAM]
                    321:     Red Hat certified release, version 1.92 - built 15:16:07, Feb  3 2004
                    322:     
                    323:     Platform: IXDP425 Development Platform (XScale)
                    324:     Copyright (C) 2000, 2001, 2002, Red Hat, Inc.
                    325: 
                    326:     RAM: 0x00000000-0x02000000, 0x000723a0-0x01ff3000 available
                    327:     FLASH: 0x50000000 - 0x50800000, 64 blocks of 0x00020000 bytes each.
                    328:     == Executing boot script in 2.000 seconds - enter ^C to abort
                    329: 
                    330: 
                    331: The good people at www.nslu2-linux.org have also documented a way to do the same thing with telnet. This means you can use telnet to interrupt the boot process and instruct the Slug to load an executable using tftp. Of course, the Slug will still revert back to the serial port as the login console, but the changes we made above will also allow you to login in as root using telnet. Note that this process requires two different telnet sessions, even though they are to the same device (in general, they will use two different IP addresses), since one is to RedBoot and the second will be to NetBSD.
                    332: 
                    333: There are several methods described for using telnet to interrupt RedBoot, which you can find at <http://www.nslu2-linux.org/wiki/HowTo/TelnetIntoRedBoot>. My personal preference is the one near the bottom of the web page entitled “C program using Berkeley Sockets”. Just copy the source code from the web page, paste it into a file (telnet_slug.c) using any editor, and compile. I had to add two header files, string.h and stdlib.h, to get the program to compile using Fedora 8 and gcc 4.1.2. The first three lines in my file look like:
                    334: 
                    335:     #include <stdio.h> 
                    336:     #include <string.h> 
                    337:     #include <stdlib.h> 
                    338: 
                    339: Then,
                    340: 
                    341:     $ gcc telnet_slug.c -o telnet_slug
                    342: 
                    343: to compile the program. You also need to set your network configuration so that your computer can respond to the Slug when it starts up with IP address 192.168.0.1. For my Fedora 8 system, I use the following:
                    344: 
                    345:     $ sudo /sbin/ifconfig eth0:1 inet 192.168.0.2 broadcast 192.168.0.255 netmask 255.255.255.0 
                    346: 
                    347: You'll find other suggestions for other operating systems at the top of the aforementioned web page. Now, run the program before you power on the Slug and you should see:
                    348: 
                    349:     $ ./telnet_slug
                    350:     == Executing boot script in 1.950 seconds - enter ^C to abort 
                    351:     Telnet escape character is '~'. 
                    352:     Trying 192.168.0.1... 
                    353:     Connected to 192.168.0.1. 
                    354:     Escape character is '~'. 
                    355:     RedBoot> 
                    356: 
                    357: What could be easier? Occasionally, the system trying to telnet into RedBoot will be a little too slow, so if you don't see anything happening after a minute or so, try again. For reference, my Slug with the clock speed-up modification, takes 12 seconds from power on to the RedBoot prompt. Presumably, it will take 24 seconds if you have an older Slug without the modification.
                    358: 
                    359: #Booting the Slug with NFS
                    360: 
                    361: Now, start up the NSLU2 and interrupt the boot process as described above:
                    362: <pre><code>
                    363: $ ./telnet_slug
                    364: == Executing boot script in 1.960 seconds - enter ^C to abort
                    365: Telnet escape character is '~'.
                    366: Trying 192.168.0.1...
                    367: Connected to 192.168.0.1.
                    368: Escape character is '~'.
                    369: RedBoot> ip_address -h 192.168.0.2
                    370: IP: 192.168.0.1/255.255.255.0, Gateway: 192.168.0.1
                    371: Default server: 192.168.0.2, DNS server IP: 0.0.0.0
                    372: RedBoot> load -r -b 0x200000 netbsd-nfs.bin
                    373: Using default protocol (TFTP)
                    374: Raw file loaded 0x00200000-0x004a2ba7, assumed entry at 0x00200000
                    375: RedBoot> g
                    376: ~
                    377: 
                    378: telnet> q
                    379: Connection closed.
                    380: 
                    381: $ telnet slug1
                    382: Trying 192.168.1.240...
                    383: Connected to slug1.
                    384: Escape character is '^]'.
                    385: 
                    386: NetBSD/evbarm (slug1) (ttyp0)
                    387: 
                    388: login: root
                    389: Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
                    390:     2006, 2007, 2008
                    391:     The NetBSD Foundation, Inc.  All rights reserved.
                    392: Copyright (c) 1982, 1986, 1989, 1991, 1993
                    393:     The Regents of the University of California.  All rights reserved.
                    394: 
                    395: NetBSD 4.99.54 (NSLU2_NFS) #0: Fri Feb 15 23:04:29 EST 2008
                    396: 
                    397: Welcome to NetBSD!
                    398: 
                    399: This system is running a development snapshot of the NetBSD operating system,
                    400: also known as NetBSD-current.  It is highly possible for it to contain serious
                    401: bugs, regressions, broken features or other problems.  Please bear this in mind
                    402: and use the system with care. 
                    403: 
                    404: You are encouraged to test this version as thoroughly as possible.  Should you
                    405: encounter any problem, please report it back to the development team using the
                    406: send-pr(1) utility (requires a working MTA).  If yours is not properly set up,
                    407: use the web interface at: http://www.NetBSD.org/support/send-pr.html 
                    408: 
                    409: Thank you for helping us test and improve NetBSD.
                    410: We recommend creating a non-root account and using su(1) for root access.
                    411: slug1#
                    412: </code></pre>
                    413: The first time I booted the Slug using NFS, it took several minutes to setup up files and such, so be patient.
                    414: 
                    415: #Using sysinst to install NetBSD onto a USB drive
                    416: 
                    417: If you're new to NetBSD, you might feel more comfortable using the NetBSD installer to set up NetBSD on your USB thumb or hard disk. Everything you need was built during the kernel build steps above. The installer consists of five files; one is the executable and the other four are the installation messages in German, French, Spanish, and Polish. To use the installer, move it to the NFS server used above to boot up the NSLU2 and add the installation directory to the exported NFS directories in /etc/exports on the NFS server. Don't forget to update the exports list.
                    418: 
                    419:     $ cd ~/net/src/distrib/evbarm/instkernel/ramdisk/obj/work/
                    420:     $ scp sysinst* nfsserver:/export/client/
                    421:     $ sudo nano /etc/exports
                    422:     $ sudo /usr/sbin/exportfs -ra
                    423: 
                    424: NFS server's /etc/exports:
                    425: 
                    426:     /export/client     192.168.1.0/255.255.255.0(rw,sync,no_root_squash)
                    427:     /export/client/root 192.168.1.0/255.255.255.0(rw,sync,no_root_squash)
                    428:     /export/client/swap 192.168.1.0/255.255.255.0(rw,sync,no_root_squash)
                    429: 
                    430: Boot up the slug as before, and mount the newly exported directory.
                    431: <pre><code>
                    432: slug1# mkdir /mnt/inst
                    433: slug1# mount -t nfs nfsserver:/export/client /mnt/inst
                    434: slug1# ls -la /mnt/inst
                    435: total 18064 
                    436: drwxrwxrwx   6 root  wheel      4096 Mar  7 19:41 . 
                    437: drwxr-xr-x   5 root  wheel      4096 Mar  7 19:52 .. 
                    438: drwxr-xr-x   2 root  wheel      4096 Feb 26 21:53 home 
                    439: drwxr-xr-x   3 500   501        4096 Mar  7 16:03 releasedir 
                    440: drwxr-xr-x  20 root  wheel      4096 Mar  7 16:05 root 
                    441: -rw-------   1 root  wheel  16777216 Feb 28 03:15 swap 
                    442: -r-xr-xr-x   1 500   501     1571140 Mar  7 19:41 sysinst 
                    443: -r--r--r--   1 500   501       23994 Mar  7 19:41 sysinstmsgs.de 
                    444: -r--r--r--   1 500   501       23727 Mar  7 19:41 sysinstmsgs.es 
                    445: -r--r--r--   1 500   501       23785 Mar  7 19:41 sysinstmsgs.fr 
                    446: -r--r--r--   1 500   501       21140 Mar  7 19:41 sysinstmsgs.pl 
                    447: drwxr-xr-x   2 root  wheel      4096 Feb 26 21:53 usr 
                    448: </code></pre>
                    449: Make sure that NetBSD recognizes your USB drive.
                    450: 
                    451:     slug1# dmesg | grep sd 
                    452:     sd0 at scsibus0 target 0 lun 0: <SanDisk, U3 Cruzer Micro, 3.21> disk removable 
                    453:     sd0: 3919 MB, 7964 cyl, 16 head, 63 sec, 512 bytes/sect x 8027793 sectors 
                    454: 
                    455: Change to the directory with the installer and run it. You'll see the following messages on your telnet terminal.
                    456: <pre><code>
                    457: slug1# cd /mnt/inst
                    458: slug1# ./sysinst 
                    459: 
                    460: Welcome to sysinst, the NetBSD-4.99.55 system installation tool.  This menu-driven tool is designed 
                    461: to help you install NetBSD to a hard disk, or upgrade an existing NetBSD system, with a minimum of work. 
                    462: [...snip (Select your language preference)...]
                    463: 
                    464: 
                    465:          +-----------------------------------------------+ 
                    466:          ¦ NetBSD-4.99.55 Install System                 ¦                                                                                                                                                                   
                    467:          ¦                                               ¦ 
                    468:          ¦                                               ¦ 
                    469:          ¦>a: Install NetBSD to hard disk                ¦ 
                    470:          ¦ b: Upgrade NetBSD on a hard disk              ¦ 
                    471:          ¦ c: Re-install sets or install additional sets ¦ 
                    472:          ¦ d: Reboot the computer                        ¦ 
                    473:          ¦ e: Utility menu                               ¦ 
                    474:          ¦ x: Exit Install System                        ¦ 
                    475:          +-----------------------------------------------+ 
                    476: 
                    477: </code></pre>
                    478: First, select the utility menu option. From here, set up your network so that the installation program can generate the necessary files in /etc. When done, return to the install system menu and select the "Install NetBSD to hard disk" option and follow the instructions. When you get to the third menu, select "Custom installation". Then mark the following items “Yes”:
                    479: <pre><code>
                    480: The following is the list of distribution sets that will be used. 
                    481: 
                    482:     Distribution set         Selected 
                    483:     ------------------------ -------- 
                    484:  a: Kernel (ADI_BRH)             No 
                    485:  b: Kernel (INTERGRATOR)         No 
                    486:  c: Kernel (IQ80310)             No 
                    487:  d: Kernel (IQ80321)             No 
                    488:  e: Kernel (TEAMASA_NPWR)        No 
                    489:  f: Kernel (TS7200)              No 
                    490:  g: Base                        Yes 
                    491:  h: System (/etc)               Yes 
                    492:  i: Compiler Tools              Yes 
                    493:  j: Games                        No 
                    494:  k: Online Manual Pages         Yes 
                    495:  l: Miscellaneous               Yes 
                    496:  m: Test programs               Yes 
                    497:  n: Text Processing Tools       Yes 
                    498:  o: X11 sets                    None 
                    499: >x: Install selected sets 
                    500: </code></pre>
                    501: Continue with the normal installation. When asked for the location of the distribution files, select “Local Directory”.
                    502: <pre><code>
                    503: Your disk is now ready for installing the kernel and the distribution sets.  
                    504: As noted in your INSTALL notes, you have several options.  For ftp or nfs, 
                    505: you must be connected to a network with access to the proper machines. 
                    506: 
                    507: Sets selected 7, processed 0, Next set base. 
                    508: 
                    509:               +-------------------------+ 
                    510:               ¦ Install from            ¦ 
                    511:               ¦                         ¦ 
                    512:               ¦ a: CD-ROM / DVD         ¦ 
                    513:               ¦ b: FTP                  ¦ 
                    514:               ¦ c: HTTP                 ¦ 
                    515:               ¦ d: NFS                  ¦ 
                    516:               ¦ e: Floppy               ¦ 
                    517:               ¦ f: Unmounted fs         ¦ 
                    518:               ¦>g: Local directory      ¦ 
                    519:               ¦ h: Skip set             ¦ 
                    520:               ¦ i: Skip set group       ¦ 
                    521:               ¦ j: Abandon installation ¦ 
                    522:               +-------------------------+ 
                    523: 
                    524: </code></pre>
                    525: Next screen:
                    526: 
                    527:     Enter the already-mounted local directory where the distribution is located.
                    528:     Remember, the directory should contain the .tgz files. 
                    529:     
                    530:     >a: Base directory            /mnt/inst/releasedir 
                    531:      b: Set directory             /evbarm/binary/sets 
                    532:      x: Continue 
                    533: 
                    534: 
                    535: Make sure you enter a password for the root user, since we are going to use secure shell to login to the NSLU2. Once the installation is finished, NetBSD checks the file system to see if everything looks OK. Since we didn't install a kernel to the disk, NetBSD will think that the installation is incomplete. You can ignore the warning message. Exit the installation, which unmounts the USB disk, and remount the disk. Edit the two files below, then reboot the NSLU2.
                    536: 
                    537:     slug1# mkdir /mnt/d0
                    538:     slug1# mount /dev/sd0a /mnt/d0
                    539:     slug1# cd /mnt/d0/etc
                    540:     slug1# vi rc.conf
                    541:     slug1# vi ssh/sshd_config
                    542:     slug1# reboot
                    543: 
                    544: Slug's rc.conf:
                    545: <pre><code>
                    546: #
                    547: # see rc.conf(5) for more information.
                    548: #
                    549: # Use program=YES to enable program, NO to disable it. program_flags are
                    550: # passed to the program on the command line.
                    551: #
                    552:  
                    553: # Load the defaults in from /etc/defaults/rc.conf (if it's readable).
                    554: # These can be overridden below.
                    555: #
                    556: if [ -r /etc/defaults/rc.conf ]; then
                    557:         . /etc/defaults/rc.conf
                    558: fi
                    559: 
                    560: # If this is not set to YES, the system will drop into single-user mode.
                    561: #
                    562: rc_configured=YES
                    563: 
                    564: # Add local overrides below
                    565: #
                    566: hostname=slug1.
                    567: defaultroute="192.168.1.1"
                    568: sshd=YES
                    569: </code></pre>
                    570: Slug's ssh/sshd_config:
                    571: <pre><code>
1.3     ! sevan     572: #       $NetBSD: how_to_install_netbsd_on_the_linksys_nslu2___40__slug__41___without_a_serial_port__44___using_nfs_and_telnet.mdwn,v 1.2 2015/05/28 21:08:14 riastradh Exp $
1.1       mspo      573: #       $OpenBSD: sshd_config,v 1.75 2007/03/19 01:01:29 djm Exp $
                    574: 
                    575: # This is the sshd server system-wide configuration file.  See
                    576: # sshd_config(5) for more information.
                    577: 
                    578: # The strategy used for options in the default sshd_config shipped with
                    579: # OpenSSH is to specify options with their default value where
                    580: # possible, but leave them commented.  Uncommented options change a
                    581: # default value.
                    582: 
                    583: [...snip...]
                    584: PermitRootLogin yes 
                    585: [...snip...]
                    586: </code></pre>
                    587: After rebooting, use the method described above for interrrupting the boot process with telnet, assign the host ip address and use tftp to load the kernel netbsd-sd0.bin, which uses sd0a as the root drive. Remember, this is one of the three kernels we built earlier. You should be able to ssh to your Slug and login as root.
                    588: <pre><code>
                    589: $ ./telnet_slug 
                    590: == Executing boot script in 1.640 seconds - enter ^C to abort 
                    591: Telnet escape character is '~'.  
                    592: Trying 192.168.0.1... 
                    593: Connected to 192.168.0.1. 
                    594: Escape character is '~'. 
                    595: RedBoot> ip_address -h 192.168.0.2 
                    596: IP: 192.168.0.1/255.255.255.0, Gateway: 192.168.0.1 
                    597: Default server: 192.168.0.2, DNS server IP: 0.0.0.0 
                    598: RedBoot> load -r -b 0x200000 netbsd-sd0.bin 
                    599: Using default protocol (TFTP) 
                    600: Raw file loaded 0x00200000-0x004a2b9f, assumed entry at 0x00200000 
                    601: RedBoot> g
                    602: ~
                    603: telnet> q 
                    604: Connection closed. 
                    605: $ ssh root@slug1
                    606: Password:
                    607: 
                    608: Last login: Thu Mar 20 21:51:38 2008 from 192.168.1.105
                    609: 
                    610: NetBSD 4.99.55 (NSLU2_ALL) #0: Sat Mar 8 11:33:58 EST 2008
                    611: 
                    612: 
                    613: 
                    614: Welcome to NetBSD!
                    615: 
                    616: 
                    617: [...snip...]
                    618: 
                    619: Terminal type is xterm.                                                 
                    620: 
                    621: We recommend creating a non-root account and using su(1) for root access.
                    622: 
                    623: slug1#
                    624: </code></pre>
                    625: 
                    626: #Troubleshooting
                    627: ##Can't format USB drive with sysinstall
                    628: 
                    629: On occasion, I've had trouble with sysinst failing to install to the USB drive. The symptom(s) seen most often is the slug hanging up when formatting the disk or untarring the distribution tarballs. I've had some success deleting the disklabel for the USB drive and then restarting sysinst. To do this (reference: To clear the disklabels), exit the install system and enter at the root prompt:
                    630: 
                    631:     dd if=/dev/zero of=/dev/sd0c bs=8k count=1
                    632: 
                    633: Then, restart the installer and try again. Of course, make sure you use the device that corresponds to the USB drive you want to work on.
                    634: 
                    635: ##Build error with some versions of Linux
                    636: 
                    637: With certain version of Linux (notably Fedora 7), I get an error that looks like:
                    638: 
                    639:     checking for i686-pc-linux-gnu-gcc... cc
                    640:     checking for C compiler default output file name... configure: error: C compiler cannot create executables
                    641:     See `config.log' for more details.
                    642:     nbgmake: *** [configure-gcc] Error 1
                    643: 
                    644:     *** Failed target:  .build_done
                    645:     (more error output)
                    646: 
                    647: Try defining the following two variables, then follow the build instructions above:
                    648: 
                    649:     $ export HOST_CC=/usr/bin/gcc
                    650:     $ export HOST_CXX=/usr/bin/g++
                    651: 
                    652: You can find additional suggestions in ~/net/src/BUILDING.
                    653: 
                    654: #Versions that are known to work
                    655: 
                    656: Since, at the time of this writing, you must use -current to get a version of NetBSD that will run on the Slug, you will occasionally find that the kernel doesn't boot quite right. Don't complain - that's what -current is for. Here, we'll try to keep track of the latest version of NetBSD that is known to build and boot correctly. You can get these versions by changing the CVS command line. To get an older version of NetBSD-current use:
                    657: 
                    658:     $ export CVS_RSH="ssh"
                    659:     $ export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
                    660:     $ cd ~/net
                    661:     $ cvs checkout -D 20080420-UTC src
                    662: 
                    663: The script build.sh has changed since this article was first written. The following worked on August 23, 2008:
                    664: 
                    665:     export CVS_RSH="ssh"
                    666:     export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
                    667:     cvs checkout -D 20080821-UTC src
                    668: 
                    669: **Note:** A checkout date of 20081215-UTC built and ran correctly.
                    670: **Note:** There have been some reported problems with the 20081215 build.
                    671: 
                    672: Get the NPE code from Intel, as above. Setup the kernel configuration files as above. Then, build as follows:
                    673: 
                    674: ./build.sh -O ../obj -T ../tools -m evbarm-eb tools
                    675: ./build.sh -O ../obj -T ../tools -U -u -m evbarm-eb distribution
                    676: ./build.sh -O ../obj -T ../tools -U -u -m evbarm-eb -V KERNEL_SETS=NSLU2_ALL release
                    677: 
                    678: The files you'll need are now in *~/net/obj/releasedir/evbarm/binary/sets*. 
1.3     ! sevan     679: 
        !           680: #To add USB audio support
        !           681: 
        !           682: 
        !           683: Create the kernel configuration file: 
        !           684:     
        !           685:     $ echo 'include "arch/evbarm/conf/NSLU2"' >NSLU2_AUDIO
        !           686:     $ echo 'uaudio* at uhub? port ? configuration ?' >>NSLU2_AUDIO 
        !           687:     $ echo 'audio* at uaudio?' >>NSLU2_AUDIO 
        !           688:     $ echo 'config netbsd-aud-npe0 root on npe0 type nfs' >>NSLU2_AUDIO
        !           689:     $ echo 'config netbsd-aud-sd0 root on sd0a type ffs' >>NSLU2_AUDIO
        !           690:     $ echo 'config netbsd-aud-sd1 root on sd1a type ffs' >>NSLU2_AUDIO
        !           691:     
        !           692: 
        !           693: Build as described in the above link, except change the final build command line to: 
        !           694:     
        !           695:     $ ./build.sh -u -U -m evbarm -a armeb -V KERNEL_SETS=NSLU2_AUDIO release
        !           696:     
        !           697: 
        !           698: ##  Boot the kernel
        !           699: 
        !           700: Use tftp to load the kernel as described in the link above. You should see the following lines (or something similar) in your dmesg or console output. The order of the lines may be slightly different. You may not see anything about "uhub3" unless you have an external hub. 
        !           701:     
        !           702:     uhub0 at usb1: vendor 0x1033 OHCI root hub, class 9/0, rev 1.00/1.00, addr 1    
        !           703:     uhub0: 2 ports with 2 removable, self powered                                   
        !           704:     uhub1 at usb2: vendor 0x1033 EHCI root hub, class 9/0, rev 2.00/1.00, addr 1    
        !           705:     uhub1: 5 ports with 5 removable, self powered                                   
        !           706:     uhub2 at usb0: vendor 0x1033 OHCI root hub, class 9/0, rev 1.00/1.00, addr 1    
        !           707:     uhub2: 3 ports with 3 removable, self powered                                   
        !           708:     ehci0: handing over full speed device on port 1 to ohci0                        
        !           709:     uaudio0 at uhub2 port 1 configuration 1 interface 0: C-Media INC. USB Sound Device, rev 1.10/0.10, addr 2                                                       
        !           710:     uaudio0: audio rev 1.00                                                         
        !           711:     audio0 at uaudio0: full duplex, independent                                     
        !           712:     uhub3 at uhub1 port 2: vendor 0x0409 product 0x005a, class 9/0, rev 2.00/1.00, addr 2
        !           713:     
        !           714: 
        !           715: Note in particular the line that says "ehci0: handing over full speed device on port 1 to ohci0." The NetBSD USB ehci driver can not handle isochronous devices (required for audio), but the ohci driver can. Unfortunately, it also appears that NetBSD can not handle an attached hub with the ohci driver, so you can't plug the USB audio device into a hub - it must be plugged directly into one of the two USB ports on the back of the device. 
        !           716: 
        !           717: ##  Add the device entry in /dev
        !           718: 
        !           719: As root, enter the following: 
        !           720:     
        !           721:     # cd /dev
        !           722:     # ./MAKEDEV audio
        !           723:     
        !           724: 
        !           725: You should now be able to play music to /dev/audio. If you want to play mp3 files, I recommend using _madplay_, which can be added using packages. 
        !           726: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb