Goal
Installing TinyBSD (FreeBSD) on embedded machines with onboard flashcards.
I am using FreeBSD 7.0 as host.
How to read
text
## tip or instruction command man(1) => referring to a manualpage usage man 1 man
example
This is an example abount man(1)
## see details in manpage man 1 man
Disclaimer
Please read License at the end of this document.
Precautions
DON'T do this on a network where there are other people working. Running dhpcd might confuse other users and upset adminstrators. Tftp is not safe by design. I am not putting any effort to make this setup secure. If would would like to so I suggest to use an extra ethernetcard for this network. Use a ipnat(4) or pf(4) to protect the pxeboot network.
Installation
In the howto TinyBSD is described how to install and update 7.0
Install ports as well.
Packages
I need some additional packages:
- isc-dhcpd
cd /usr/ports/net/isc-dhcp3-server make install
Configs
Location of the files in the PXEboot tree. According to many doc's have read the files are in /tftpboot. However I always end up having a shortage of diskspace in /. Therefore is place it in /usr/tftpboot/
sudo mkdir /usr/tftpboot
Dhcpd is offering a host:
- ipnumber
- name of pxeboot(8) file
- location of the root tree.
in /usr/local/etc/dhcpd.conf
option domain-name "pxe.example.com";
option domain-name-servers 10.1.1.1;
default-lease-time 600;
max-lease-time 7200;
authoritative;
ddns-update-style ad-hoc;
log-facility local7;
server-name "10.1.1.1";
filename "pxeboot";
server-identifier 10.1.1.1;
next-server 10.1.1.1;
option root-path "10.1.1.1:/usr/tftpboot";
subnet 10.1.1.0 netmask 255.255.255.0 {
range 10.1.1.2 10.1.1.3;
option routers 10.1.1.1;
}
With this information the bios and the pxe networdcard can load the first stage loader by using a tftpclient.
Copy the pxeboot file to the tree and make executable
sudo cp /boot/pxeboot/ /usr/tftpboot chmod 755 /usr/tftpboot/pxeboot
Tftp(1) is offering a pxeboot file. Tftp is run by inetd(8) and configured by /etc/inetd.conf.
sudo vi /etc/inetd.conf ## change this line #tftp tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot ## in tftp tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /usr/tftpboot
nfsd(8)
sudo vi /etc/exports ## add this line /usr/tftpboot -maproot=0 -alldirs 10.1.1.1 10.1.1.2 10.1.1.3 127.0.0.1
Extracting the file tree
Since this is written in the scope of TinyBSD I use this image. See TinyBSD for:
- building an image
- mounting it
- create a backup in ~/image_tree.tgz
cd /usr/tftpboot tar -xfvz ~/image_tree.tgz
NFS needs resolvers. I fix it in both hosts files. I could also be resolved with configuring name(8) and named.conf(5)
/etc/hosts on image and host
vi sudo /etc/hosts ## add these lines 10.1.1.1 mother.example.com 10.1.1.2 pxe2 10.1.1.3 pxe3
Enabling all daemons in rc.conf
sudo vi /etc/rc.conf ## check these lines (I have rl0 a ethernetcard) ifconfig_rl0=10.1.1.1/24 portmap_enable="YES" mountd_enable="YES" mountd_flags="-r" dhcpd_enable="YES" nfs_server_enable="YES" rpcbind_enable="YES" inetd_enable="YES" rpc_lockd_enable="YES" rpc_statd_enable="YES"
The TinyBSD Kernel won't always PXEboot. I use a custom kernel on the host. This one I copie to the image. The kernel config is here.
sudo cp //boot/kernel/kernel /usr/tftpboot/boot/kernel
configure root for image
sudo vi /usr/tftpboot/etc/fstab ## change this to # /dev/ad0a / ufs ro 1 1 10.1.1.1:/usr/tftpboot / nfs ro 0 0
reboot? Here I always get confused to restart which daemon first. Mostly I end up rebooting.
sudo reboot
When the host is back it time to start some testing. For this I use a Soekris board or a Wrap or soon Alix board.
set the correct baudrate in /etc/remote
sudo vi /etc/remote ## 9600 is the baudrate here sio0|com1:dv=/dev/cuad0:br#9600:pa=none:
Connect a serial NULLmodem cable on host and the soekris. Or use a usb-to-serial adapter. Read ucom(4) for driversupport. When using ucom change the serial interface to /dev/cuaU0.
sudo vi /etc/remote sio0|com1:dv=/dev/cuaU0:br#9600:pa=none:
open a serial connection with tip(1)
sudo tip com1
Connect a crosscable to the host and the soekris
From here boot the soekris.
## power on ## interrupt bios with control P (CTRL-P) ## from bios command line interface boot f0
Install on flash
Just copy the image to /usr/tftpboot
sudo cp /usr/src/tools/tools/tinybsd.bin /usr/tftpboot/ cat tinybsd.bin > /dev/ad0 Or see the [wiki:TinyBSD TinyBSD] howto for more options.
Debugging
- usage of tcpdump(1) that provides critacal information in most stages of debugging.
sudo tcpdump -i rl0 -vvvv
- The board gets no ipnumber:
- network (interfaces cables) check led's on interfaces
- ifconfig for 10.1.1.1/24
- ps ax | grep dhcpd
- no bootloader
usage of tftp(1)
%tftp localhost tftp> get pxeboot Received 256838 bytes in 0.5 seconds tftp>quit
- no kernel
usage of mount(8)
sudo mount -t nfs 10.1.1.1:/usr/tftpboot /mnt ls /mnt
4 no login
sudo vi /usr/tftpboot/etc/ttys ## check these lines ttyv0 "/usr/libexec/getty Pc" cons25 on secure ## or ttyd0 "/usr/libexec/getty std.9600" dialup on secure ## or ttyd0 "/usr/libexec/getty std.9600" ansi on secure
License
- This document may be copied.
- This document may be modified.
- This document may be redistributed.
THIS DOCUMENTATION IS PROVIDED "AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Feedback is welcome, please mail it to info at martenvijn.nl
cheers,
Marten
