Based on the builder code, to use this with a nanobsd image simply replace /dev/${MD}d with /dev/${MD}s3 in the mount command to reference the proper slice for the configuration. These scripts will only work for a full image, not an upgrade image. Note that you must use gunzip to decompress the image before using any of these scripts.
Modified script for nanobsd (also modified some parts to be less potentially destructive and work with absolute paths):
#!/bin/sh
# This script replaces the config file in the
# image with your specified config file.
# Usage {configfile} {imagefile}
# Example ./replace_conf.sh myconfig.xml pfSense.img
NEWCONFIG="$1"
IMGFILE="$2"
echo "Image file: $IMGFILE"
MD=`mdconfig -a -t vnode -f $IMGFILE`
echo "Image file device: $MD"
mkdir ${IMGFILE}.mnt
mount /dev/${MD}s3 ${IMGFILE}.mnt
cp $NEWCONFIG ${IMGFILE}.mnt/conf/config.xml
chmod 644 ${IMGFILE}.mnt/conf/config.xml
echo "Replaced config with $NEWCONFIG"
umount ${IMGFILE}.mnt
rmdir ${IMGFILE}.mnt
mdconfig -d -u ${MD}
If the new config should be the default when you reset to defaults, the config file should be placed at /conf.default/config.xml in the OS slices rather than /conf/config.xml in the configuration slice of the image:
#!/bin/sh
# This script replaces the default config file in the
# image with your specified config file.
# Usage {configfile} {imagefile}
# Example ./replace_def_conf.sh myconfig.xml pfSense.img
NEWCONFIG="$1"
IMGFILE="$2"
echo "Image file: $IMGFILE"
MD=`mdconfig -a -t vnode -f $IMGFILE`
echo "Image file device: $MD"
mkdir ${IMGFILE}.mnt
mount /dev/${MD}s1a ${IMGFILE}.mnt
cp $NEWCONFIG ${IMGFILE}.mnt/conf.default/config.xml
chmod 644 ${IMGFILE}.mnt/conf.default/config.xml
umount ${IMGFILE}.mnt
mount /dev/${MD}s2a ${IMGFILE}.mnt
cp $NEWCONFIG ${IMGFILE}.mnt/conf.default/config.xml
chmod 644 ${IMGFILE}.mnt/conf.default/config.xml
umount ${IMGFILE}.mnt
echo "Replaced default config with $NEWCONFIG"
rmdir ${IMGFILE}.mnt
mdconfig -d -u ${MD}
To make an update image from the first OS slice of a full image:
#!/bin/sh
# This script creates an update image from a full image.
# Usage {imagefile} {updatefile}
# Example ./make_update.sh pfSense.img pfSense-update.img
IMGFILE="$1"
IMGUPDATE="$2"
echo "Image file: $IMGFILE"
MD=`mdconfig -a -t vnode -f $IMGFILE`
echo "Image file device: $MD"
dd if=/dev/${MD}s1 of=$IMGUPDATE bs=64k
gzip $IMGUPDATE
echo "Update file created: ${IMGUPDATE}.gz"
mdconfig -d -u ${MD}
Additional information about some of the steps used in these scripts is on the documentation site at
http://doc.pfsense.org/index.php/Modifying_Embedded