fio HOWTO (3) Environment variables & Reserved keywords

Environment variables

Fio also supports environment variable expansion in job files. Any sub-string of the form ${VARNAME} as part of an option value (in other words, on the right of the '='), will be expanded to the value of the environment variable called VARNAME. If no such environment variable is defined, or VARNAME is the empty string, the empty string will be substituted.

As an example, let's look at a sample fio invocation and job file: $ SIZE=64m NUMJOBS=4 fio jobfile.fio

    ; -- start job file --
    [random-writers]
    rw=randwrite
    size=${SIZE}
    numjobs=${NUMJOBS}
    ; -- end job file --

This will expand to the following equivalent job file at runtime:

    ; -- start job file --
    [random-writers]
    rw=randwrite
    size=64m
    numjobs=4
    ; -- end job file --

Fio ships with a few example job files, you can also look there for inspiration.

Reserved keywords

Additionally, fio has a set of reserved keywords that will be replaced internally with the appropriate value. Those keywords are:

    $pagesize
        The architecture page size of the running system.

    $mb_memory
        Megabytes of total memory in the system.

    $ncpus
        Number of online available CPUs.

These can be used on the command line or in the job file, and will be automatically substituted with the current system values when the job is run. Simple math is also supported on these keywords, so you can perform actions like size=8*$mb_memory and get that properly expanded to 8 times the size of memory in the machine.