Platform detection

  • Currently pfSense detects which platform it is on using the file /etc/platform:

    # Set our operating platform
    PLATFORM=`cat /etc/platform`
    export HOME PATH
    # Set our current version
    version=`cat /etc/version`
    cat /etc/ascii-art/pfsense-logo-small.txt
    echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..."
    if [ "$PLATFORM" = "cdrom" ]; then
    if [ "$PLATFORM" = "embedded" ]; then

    However this requires a separate images to be generated for each version, an alternative is to just generate different kernels and then use the kernel ident to define the platform.  i.e.

    ident=`uname -i`
    # detect platform
    case "$ident" in
    *-embedded*)    platform=embedded ;;
    *)              platform=cdrom ;;
    # detect developer status
    case "$ident" in
    *DEV)           developer=true ;;
    echo "platform: $platform"
    echo "developer: $developer"

  • This is a interesting idea but will not work for all cases.

    Case in point, a lot of people like to run a full installation on a WRAP + Microdrive.  Using this method would not allow the user to override the settings.

  • I think this problem is similar to how to deal with JavaScript in web pages.  The preferred method should not be to detect the platform but to detect the features.  For instance ask what are the real reasons for requiring a platform tag?  The main ones are for the kernel and for system upgrades.  Both of these are available with the kernel ident.  For other situations where the platform tag is used they can be replaced by feature detection.  For example /dev/ttyv0 does not exist on embedded platforms, and /dev/ttyd0 will not exist on strange platforms without a serial port.  CD-ROM based environments can be detected because the root file system is a cd9660 mount point, NFS debug environments can be detected similarly, and HDD/CF installs will have a /dev/ufs GEOM label root fs.