Notes for creating a bootable FreeBSD pxe image
Category : Linux
This is my notes for creating a bootable pxe image for freebsd on foreman
# wget http://mfsbsd.vx.sk/files/images/11/mfsbsd-se-11.2-RELEASE-amd64.img # mkdir /mnt/loop # mdconfig -a -t vnode -f mfsbsd-se-11.2-RELEASE-amd64.img # mount /dev/md0p2 /mnt/loop # cd /mnt/loop # cp -p mfsroot.gz /tmp/ # cd /tmp # gzip -d mfsroot.gz # mdconfig -a -t vnode -f mfsroot # mkdir /mnt/mfsroot # mount /dev/md1 /mnt/mfsroot/ # cd /mnt/mfsroot # cp -p root.txz /tmp # cd /tmp # tar Jxvf root.txz # vim rw/etc/rc.local Add: #!/bin/sh # Foreman provisioning script # # try to fetch foreman URL via TFTP FOREMAN_URL= LFILES=`find /var/db -name 'dhclient.leases.*'` for LFILE in $LFILES; do if [ -z "$FOREMAN_URL" -a -f "$LFILE" ]; then INTERFACE=`cat $LFILE | grep -E -o 'interface .*[^;]' | head -1 | cut -d\" -f 2` SERVER=`cat $LFILE | grep -E -o 'next-server .*[^;]' | head -1 | cut -d' ' -f 2` if [ -n "$SERVER" -a -n "$INTERFACE" ]; then MAC=`ifconfig $INTERFACE | grep -o "ether .*" | head -1 | cut -d' ' -f 2` DMAC=01-`echo $MAC | sed -e 's/:/-/g'` cd /tmp echo "connect $SERVER mode binary get /pxelinux.cfg/$DMAC" | tftp FOREMAN_URL=`grep foreman_url= /tmp/$DMAC | awk -F"foreman_url=" '{ print $2 }'` fi fi done if [ -z $FOREMAN_URL ]; then FOREMAN_URL=http://foreman/unattended/provision fi fetch --timeout=10 --no-verify-hostname --no-verify-peer -a -m -q -o /tmp/install.sh $FOREMAN_URL sh /tmp/install.sh # rm root.txz # tar cfJv root.txz rw # mv root.txz /mnt/mfsroot/ # umount /mnt/mfsroot # mdconfig -d -u 1 # gzip mfsroot # mv mfsroot.gz /mnt/loop/ # umount /mnt/loop # mdconfig -d -u 0 # rm -R /tmp/rw /mnt/loop /mnt/mfsroot