SOLVED: Injecting config file in embedded *.img

  • I'm referring to the 3 years old sticky in this forum…

    Is this still the most relevant way to inject a config file into an *.img file?

  • Yeah, AFAIK, the easiest way to do this is to have a FreeBSD box to work on the image. The script just mounts the image and replaces the config. If you want to do this manually, just use the commands in the script as a starting point.

  • Thank you for replying.

    I do want to make this work, as I can't have my firewall down for a long time… So I installed freebsd 7.2 as guest OS on my esxi server. Working well, but I run into problems - here's what the script outputs:

    # ./ config.xml
    Working Directory: /usr/home/testuser/pf
    Image File:
    Image File Device: md0
    mount: /dev/md0d : No such file or directory
    mv: rename /usr/home/testuser/pf/config.xml to /usr/home/testuser/pf/d/conf/config.xml: No such file or directory
    chmod: /usr/home/testuser/pf/d/conf/config.xml: No such file or directory
    Repalced Config With config.xml
    umount: /usr/home/testuser/pf/d: not a file system root directory

    The script is cut from the sticky:

    # The script replaces the default config file in the
    # image with your specified config file.
    # Usage {configfile} {imagefile}
    # Example ./ myconfig.xml pfSense.img
    echo "Working Directory: $WORKDIR"
    echo "Image File: $IMGFILE"
    MD=`mdconfig -a -t vnode -f $WORKDIR/$IMGFILE`
    echo "Image File Device: $MD"
    mkdir $WORKDIR/d
    mount /dev/${MD}d $WORKDIR/d
    mv $WORKDIR/$NEWCONFIG $WORKDIR/d/conf/config.xml
    chmod 640 $WORKDIR/d/conf/config.xml
    echo "Repalced Config With $NEWCONFIG"
    umount $WORKDIR/d
    rm -rf $WORKDIR/d
    mdconfig -d -u ${MD}

    So - does this mean I'll need a cf adapter connected? Or am I missing something?


  • You're missing the last argument on the script, the pfsense.img file.
    Try something like:

    ./ config.xml pfSense-1.2.2-Embedded.img.gz

    If you still have problems, try running the commands in the script manually, replacing the variables appropriately.

  • OMG! I am sorry (and very tired) - I retyped the name of the script instead of the image file  :-[ - now everything runs well.

    Thank you for pointing this out so quick!  :)

Log in to reply