Resflash

From lippmann wiki
Revision as of 16:37, 14 June 2019 by Maarten (talk | contribs)
Jump to navigation Jump to search

Building

notes for building resflash for octeon (edgerouter lite). Octeon resflash images require a custom kernel. Resflash loads this into a fat partition, and the kernel needs to know where to find the root partition.

If you want to avoid cross compiling (I did), first do a basic install of openbsd on your octeon system (edgerouter) per here. Be sure to include the comp set.

example setlist:

   [X] bsd           [X] base65.tgz    [ ] game65.tgz    [ ] xfont65.tgz
   [X] bsd.mp        [X] comp65.tgz    [ ] xbase65.tgz   [ ] xserv65.tgz
   [ ] bsd.rd        [ ] man65.tgz     [ ] xshare65.tgz


change fstab, make sure it's noatime and softdep (less iops to your usb stick, make it live longer) , e.g. below:

18e644d1b751b565.b none swap sw
18e644d1b751b565.a / ffs rw,noatime,softdep 1 1
18e644d1b751b565.l /home ffs rw,noatime,softdep,nodev,nosuid 1 2
18e644d1b751b565.d /tmp ffs rw,noatime,softdep,nodev,nosuid 1 2
18e644d1b751b565.f /usr ffs rw,noatime,softdep,nodev 1 2
18e644d1b751b565.g /usr/X11R6 ffs rw,noatime,softdep,nodev 1 2
18e644d1b751b565.h /usr/local ffs rw,noatime,softdep,wxallowed,nodev 1 2
18e644d1b751b565.k /usr/obj ffs rw,noatime,softdep,nodev,nosuid 1 2
18e644d1b751b565.j /usr/src ffs rw,noatime,softdep,nodev,nosuid 1 2
18e644d1b751b565.e /var ffs rw,noatime,softdep,nodev,nosuid 1 2
192.168.12.15:/volume1/src  /usr/src nfs rw,wxallowed 0 0
192.168.12.15:/volume1/dest  /usr/dest nfs rw,wxallowed 0 0
192.168.12.27:/volume1/vnodes  /var/vnodes nfs rw,wxallowed 0 0


create a user to do the building.

useradd exampleuser
user mod -G wsrc exampleuser

Then mount /usr/src on external storage (to avoid unnecessary compile related iops to usb), like nfs. Doing wxallowed because later on we may be compiling stuff with python or other tools that require wx.

mount -o wxallowed nas:/volume1/src /usr/src

Get the (6.5 in this example) stable source:

su - exampleuser
cd /usr
cvs -qd anoncvs@anoncvs.ca.openbsd.org:/cvs checkout -rOPENBSD_6_5 -P src

Similarly mount /usr/release on external storage. I advise against nfs here. Maybe use iscsi, or create an image inside an nfs export and mount it via vnd. (think vmdk on an nfs export) Example below uses vnd0, adjust if that one is in use (vnconfig -l will show)

dd if=/dev/zero of=release.img bs=1m count=0 seek=4000 status=none
vnconfig <vnd0> release.img
disklabel -E vnd0
newfs /dev/vnd0a
mount /dev/vnd0a /release

Then run below script to create the kernel:

#!/bin/ksh
export DESTDIR=/usr/dest RELEASEDIR=/usr/release MACHINE='octeon' NCPU=1 MYKERNEL=GENERIC DATEARG='+%H:%M:%S' part=d 
mkdir ${RELEASEDIR}
chown build:wobj ${RELEASEDIR}
echo "$(date "${DATEARG}") ${0}: ----- Building bsd.${part} -----"
cd /usr/src/sys/arch/${MACHINE}/conf
sed "/^config.*bsd/s/config.*/config bsd root on sd0${part} swap on sd0b/" \
GENERIC > GENERIC.${part}
sed "/^include.*GENERIC/s/GENERIC/GENERIC.${part}/" GENERIC.MP > \
GENERIC.MP.${part}
config ${MYKERNEL}.${part}
rm GENERIC.${part} GENERIC.MP.${part}
cd ../compile/${MYKERNEL}.${part}
make -j ${NCPU}
cp obj/bsd ${RELEASEDIR}/bsd.${part}
cd ..
rm -rf ${MYKERNEL}.${part}
rm -rf /usr/obj/sys/arch/${MACHINE}/compile/${MYKERNEL}.${part}
cd ${RELEASEDIR}
cksum -a sha256 -b bsd.d >> SHA256.bsd.d

Now extract the distribution octeon sets from the matching release to /usr/release

cd /tmp/
ftp https://ftp4.usa.openbsd.org/pub/OpenBSD/6.5/octeon/base65.tgz
cd /usr/release
tar xzvphf /tmp/base65.tgz
tar xzvphf var/sysmerge/etc.tgz

get the latest version of resflash. Again, put it in an exported location like an nfs share (I mounted /var/local/resflash from an export)

cd /tmp
ftp https://gitlab.com/bconway/resflash/-/archive/master/resflash-master.tar.gz
cd /var/local/resflash
tar xvfz /tmp/resflash-master.tar.gz

and you should be able to run build_resflash.sh and create a working image for resflash. Be sure to run build_resflash.sh from an octeon system as well. Partitions created by build_resflash.sh on a different architecture are not mountable from an octeon system. example command:

./build_resflash.sh  -s 115200 7629 /usr/release/

put the image on your usb/sd card:

dd if=resflash-amd64-3814MB-com0_115200-20190427_2034.img of=/dev/rsd3c bs=1m

now boot from that usb stick and you are running a resflash modified version of openbsd on your edgerouter.