Changes between Initial Version and Version 1 of FreeBSDOnEmbeddedDevice


Ignore:
Timestamp:
02/02/12 09:33:11 (12 years ago)
Author:
Rick van der Zwet
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FreeBSDOnEmbeddedDevice

    v1 v1  
     1[[PageOutline(1-3,"Table of Content")]]
     2This guide will tell you how-to put FreeBSD 9.x on an (ALIX) embedded device. For FreeBSD 8.x see the archived guide for hints [[wiki:Archive/FreeBSDOnEmbeddedDevice]]
     3
     4TODO: This is NOT complete yet.
     5
     6= Initial disk configuration =
     7{{{#!sh
     8## Hack to find memory card and have partion entries re-read
     9# - No cards:
     10#   dd: /dev/da0: Device not configured
     11# - Inactive card:
     12#   dd: /dev/da4: Operation not permitted
     13# - Active card:
     14#   0+0 records in
     15#   0+0 records out
     16#   0 bytes transferred in 0.000018 secs (0 bytes/sec)
     17}}}
     18build# ls /dev/da? | xargs -I %%DA%% -n 1 dd if=/dev/zero of=%%DA%% count=0
     19build# setenv DA /dev/da0
     20
     21Hack to __really__  have all old partition information is detroyed:
     22build# dd if=/dev/zero of=$DA bs=1m count=1
     23
     24build# fdisk -BI $DA
     25build# echo "a: * * 4.2BSD" | bsdlabel -R -B -m i386 ${DA}s1 /dev/stdin
     26build# newfs ${DA}s1a
     27build# mount ${DA}s1a /mnt
     28
     29= Disk population =
     30
     31build# setenv RELEASE 8.2-RELEASE
     32build# mkdir -p /usr/data/$RELEASE
     33build# cd /usr/data/$RELEASE
     34
     35build# mkdir kernels base manpages
     36build# (cd base; echo 'mget *' | ftp -i ftp://ftp.nl.freebsd.org/pub/FreeBSD/releases/i386/$RELEASE/base/)
     37build# (cd kernels; echo 'mget *' | ftp -i ftp://ftp.nl.freebsd.org/pub/FreeBSD/releases/i386/$RELEASE/kernels/)
     38build# (cd manpages; echo 'mget *' | ftp -i ftp://ftp.nl.freebsd.org/pub/FreeBSD/releases/i386/$RELEASE/manpages/)
     39
     40More sophisticated approach (rsync not in base):
     41build# rsync -vaz ftp.nl.freebsd.org::FreeBSD/releases/i386/$RELEASE/kernels .
     42
     43
     44build# setenv DESTDIR /mnt
     45
     46build# (cd base; cat base.?? | tar --unlink -xpzf - -C $DESTDIR)
     47build# (cd kernels; sh install.sh generic)
     48build# (cd manpages; sh install.sh)
     49
     50Tip: Soekris 2521 requires CPU_ELAN which is not included into the kernel by default. For optimal performance compile the kernel yourself
     51
     52Activate right kernel:
     53build# rm -r /mnt/boot/kernel/ ; mv /mnt/boot/GENERIC/ /mnt/boot/kernel
     54
     55= Disk configuration =
     56
     57Need resolving power at later stage inside chroot:
     58build# cp /etc/resolv.conf /mnt/etc/
     59build# chroot /mnt
     60
     61Important: if you FAIL to chroot and continue you will now start destroying your build system
     62
     63Need rw on first boot for ssh keys and such:
     64chroot# echo "/dev/ad0s1a / ufs rw,noatime 0 1" > /etc/fstab
     65Tip: On Soekris net4801 v1.33 Flash is secondary
     66net4801# echo "/dev/ad1s1a / ufs rw,noatime 0 1" > /etc/fstab
     67
     68Make sure to continue to check the disks on reboot, instead of waiting for user input:
     69chroot# echo "fsck_y_enable=YES" >> /etc/rc.conf
     70
     71{{{#!sh
     72chroot# cat <<EOF > /boot/loader.conf
     73console=comconsole
     74autoboot_delay=3
     75
     76hw.ata.ata_dma=0   # Soekris boot failure
     77EOF
     78}}}
     79
     80Serial console boot only:
     81chroot# echo "-h" > /boot.config
     82
     83Enable serial console:
     84chroot# sed '/ttyu0/ s/off/on /' /etc/ttys > /etc/ttys.new && mv /etc/ttys.new /etc/ttys
     85
     86Cosmetic: disable all vidconsoles as a soekris embedded device does not have any:
     87chroot# sed '/ttyv[0-7]/ s/on /off/g' /etc/ttys > /etc/ttys.new && mv /etc/ttys.new /etc/ttys
     88
     89== Accounting & access control ==
     90chroot# echo "sshd_enable=YES" >> /etc/rc.conf
     91chroot# pw usermod root -w random
     92
     93Administive user (admin for example):
     94chroot# setenv FTP_PASSIVE_MODE yes
     95chroot# pkg_add -r sudo
     96chroot# pw useradd admin -G wheel -c 'Admin User' -s /bin/csh -m -w random
     97chroot# echo '%wheel ALL=(ALL) ALL' >> /usr/local/etc/sudoers
     98
     99== Networking ==
     100chroot# echo "hostname=riff.vanderzwet.net" >> /etc/rc.conf
     101
     102Package installation using 7.2 kernel and 8.0-RC2 world is core dumping, postponing for later stage
     103
     104Make any other optional changes before first boot inside chroot(8):
     105chroot# vi /etc/rc.conf
     106
     107
     108chroot# exit
     109build# umount /mnt
     110
     111= Initial boot =
     112Note: NOT READY YET: Insert card into your embedded device and get yourself a prompt, using serial of ssh login.
     113== Package install ==
     114
     115=== dnsmasq ===
     116
     117dnsmasq used for local network dns and dhcp:
     118node# pkg_add -r dnsmasq
     119node# echo "dnsmasq_enable=YES" >> /etc/rc.conf
     120
     121{{{#!sh
     122node# cat <<EOF > /usr/local/etc/dnsmasq.conf
     123interface=sis0
     124
     125dhcp-range=192.168.42.100,192.168.42.200
     126
     127domain=vanderzwet.net
     128EOF
     129}}}
     130
     131=== ntp ===
     132node# echo "ntpd_enable=YES" >> /etc/rc.conf
     133{{{
     134node# cat <<EOF > /etc/ntp.conf
     135server 0.nl.pool.ntp.org
     136server 1.nl.pool.ntp.org
     137server 2.nl.pool.ntp.org
     138
     139driftfile /var/db/ntp.drift
     140EOF
     141}}}
     142
     143=== motd ===
     144
     145node# (sed '3,$ d' /etc/motd; echo "WWW: http://rickvanderzwet.nl" ) > /etc/motd.new; mv /etc/motd.new /etc/motd
     146
     147=== Flash disk protection ===
     148node# echo "update_motd=NO" >> /etc/rc.conf
     149node# echo "tmpmfs=YES" >> /etc/rc.conf
     150Tip: You could make /var completely read-only, but I hate the details like package management getting lost. Flash cards these days are cheap anyways, mine lived for 1 year after extensive use. Of course with read-only this will be _much_ longer.
     151node# echo "varmfs=YES" >> /etc/rc.conf
     152Tip: Having your flash living in read-only gives you added security and increases the live-time of your (older) Flash cards
     153node# sed '/1a/ s/rw/ro/' /etc/fstab > /etc/fstab.new; mv /etc/fstab.new /etc/fstab
     154
     155=== various ===
     156node# pkg_add -r tinyproxy sudo vim-lite
     157
     158= Put into production =
     159node# reboot
     160
     161= Adding packages =
     162Tip: As space is limited unpacking packages can result in I/O errors due to (memory) disks which run out of space. Installing for example the package apache22 goes as follows:
     163node# mkdir /usr/local/tmp
     164node# setenv PKG_TMPDIR /usr/local/tmp
     165node# pkg_add -r -t /usr/local/tmp/instmp.XXXXXX apache22