Mount nanobsd image, replace config?

  • The "Script to replace default config with your config" (,1998.0.html) doesn't work anymore, I can mount the image using mdconfig, but

    mount /dev/md0 test


    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:
    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)


    Based on,1998.0.html


    published in,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: ./ {newconfigfile} {pfsense NANOBSD imagefile}

    Example ./ myconfig.xml pfSense_nanobsd.img


    if [ ! -f ${NEWCONFIG} ]
    echo "There is no file at the path (${NEWCONFIG}) given for the configuration file"
    exit 1

    if [ ! -f ${IMGFILE} ]
    echo "There is no file at the path (${IMGFILE}) given for the pfSense image"
    exit 2

    if [ -d ${MOUNTPOINT} ]
    echo "Mountpoint ${MOUNTPOINT} already exists, please modify the script to use a different mountpoint to prevent problems"
    exit 3

    Mount 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}/conf

    restore 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 "" >> ${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!

Log in to reply