Mount nanobsd image, replace config?
-
The "Script to replace default config with your config" (http://forum.pfsense.org/index.php/topic,1998.0.html) doesn't work anymore, I can mount the image using mdconfig, but
mount /dev/md0 test
gives
mount: /dev/md1 : Invalid argument
though md1 exists? ):
Any hint on this? How can I modify the image / replace the config before flashing it? Thanks!
-
I have posted a reply with a modified version that should work for the nanobsd images.
-
Thank you Efonne. I meanwhile also found out, that the slice (=partition?) was wrong. Theres a nice guide in the wiki: http://doc.pfsense.org/index.php/Modifying_Embedded
Based on this guide and the "Script to replace default config with your config " by rsw686 I also created a script. This script stops the initial configuration web wizard from running, changes the configuration and also fixes a boot problem I had by adding a 10 second delay (who does not want this: just remove the few lines - if you leave it in and don't have the boot problem, your boot progress will take 10 seconds longer, that's all)#!/bin/sh
Based on http://forum.pfsense.org/index.php/topic,1998.0.html
and http://doc.pfsense.org/index.php/Modifying_Embedded,
published in http://forum.pfsense.org/index.php/topic,53199.msg284324.html
The script replaces the default config file in the pfSense NANOBSD
image with your specified config file. Additionally it disables
the initial web configuration wizard and fixes the mountroot error.
In case you don't have the mountroot error, one can comment out the lines for it.
If you don't have the mountroot error and don't comment out the lines, all that
happens is that the boot process takes 10 seconds longer.
Usage: ./replace_conf.sh {newconfigfile} {pfsense NANOBSD imagefile}
Example ./replace_conf.sh myconfig.xml pfSense_nanobsd.img
MOUNTPOINT=/mnt/pfsense
NEWCONFIG=$1
IMGFILE=$2if [ ! -f ${NEWCONFIG} ]
then
echo "There is no file at the path (${NEWCONFIG}) given for the configuration file"
exit 1
fiif [ ! -f ${IMGFILE} ]
then
echo "There is no file at the path (${IMGFILE}) given for the pfSense image"
exit 2
fiif [ -d ${MOUNTPOINT} ]
then
echo "Mountpoint ${MOUNTPOINT} already exists, please modify the script to use a different mountpoint to prevent problems"
exit 3
fiMount image to memory disk
MD=
mdconfig -f $IMGFILE
Some infos
echo "new config: ${NEWCONFIG}"
echo "imagefile: ${IMGFILE}"
echo "mdconfig device: ${MD}"Create mountpoint, -p for non-standard mountpoints that maybe miss the parent
s3 is slice 3 = partition 3 (this is the partition containing the configuration)
mkdir -p ${MOUNTPOINT}
mount /dev/${MD}s3 ${MOUNTPOINT}Content of conf directory in configuration partition
echo "Content of conf directory in configuration partition:"
ls -lah ${MOUNTPOINT}/confrestore config and disable initial configuration wizard
MODEVALUE=
stat -f "%OLp" ${MOUNTPOINT}/conf/config.xml
cp ${NEWCONFIG} ${MOUNTPOINT}/conf/config.xml
chmod ${MODEVALUE} ${MOUNTPOINT}/conf/config.xml
rm ${MOUNTPOINT}/conf/trigger_initial_wizard
umount ${MOUNTPOINT}fix boot problem
mount /dev/${MD}s1a ${MOUNTPOINT}
echo "kern.cam.boot_delay=10000" >> ${MOUNTPOINT}/boot/loader.conf.local
umount ${MOUNTPOINT}rm -df ${MOUNTPOINT} #only delete empty folder!
mdconfig -d -u ${MD} -
push edited the script one post before this
Efonne, maybe you can additionally link this from the script thread? Thanks!