echo y | pkg install cpu-microcode
cpu_microcode_load="YES"cpu_microcode_name="/boot/firmware/intel-ucode.bin"
echo 'microcode_update_enable="YES"' >> /etc/rc.conf
pkg install x86inforehashx86info -a | fgrep -i microcode
service microcode_update start
kldload -q cpuctl; x86info -a | fgrep -i microcode
root@OPNsense:~ # pkg search cpu-microcodecpu-microcode-1.0 Meta-package for CPU microcode updatescpu-microcode-amd-20230808 AMD CPU microcode updatescpu-microcode-intel-20230808 Intel CPU microcode updatescpu-microcode-rc-1.0 RC script for CPU microcode updates
root@OPNsense:~ # pkg install cpu-microcodeUpdating OPNsense repository catalogue...OPNsense repository is up to date.Updating mimugmail repository catalogue...mimugmail repository is up to date.All repositories are up to date.The following 4 package(s) will be affected (of 0 checked):New packages to be INSTALLED: cpu-microcode: 1.0 [OPNsense] cpu-microcode-amd: 20230808 [OPNsense] cpu-microcode-intel: 20230808 [OPNsense] cpu-microcode-rc: 1.0 [OPNsense]Number of packages to be installed: 4
#!/bin/sh# PROVIDE: microcode_update# REQUIRE: root mountcritlocal# KEYWORD: nojail# BEFORE: SERVERS## Add the following line to /etc/rc.conf to enable flow-capture:# microcode_update_enable (bool): Set it to "YES" to update microcode on startup# Set to "NO" by default.# microcode_update_datadir (str): Directory, microcode updates stored in.# Default is "/usr/local/share/cpucontrol"# microcode_update_cpus (str): A list of cpus to update on startup, or "ALL" for all.# Example: microcode_update_cpus="0 1"# Set to "ALL" by default. # microcode_update_flags (str): Flags for cpucontrol(.. /etc/rc.subrname="microcode_update"rcvar=microcode_update_enablestop_cmd=":"start_cmd="microcode_update_start"required_modules="cpuctl"CMT="/usr/sbin/cpucontrol"microcode_update_start(){ echo "Updating CPU Microcode..." if [ "${microcode_update_cpus}" = "ALL" ]; then ncpu=`/sbin/sysctl -n hw.ncpu` cpus=`jot ${ncpu} 0`; else cpus=${microcode_update_cpus} fi for i in ${cpus}; do ${CMT} -u ${microcode_update_flags} \ -d "${microcode_update_datadir}" /dev/cpuctl${i} 2>&1 | \ logger -p daemon.notice -t microcode_update || \ (echo "Microcode Update Failed." && exit 1) done if [ "${microcode_update_cpus}" = "ALL" ]; then CPUCONTROL_UPDATED=$(cpucontrol -h 2>&1 | grep -q -- -e; echo $?) if [ ${CPUCONTROL_UPDATED} -ne 0 ]; then echo "Please update your system in order to update CPU microcode." else ${CMT} -e /dev/cpuctl0 >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "Re-evalulation of CPU flags Failed." exit 1 fi fi fi echo "Done."}load_rc_config $name# Set default valuesif [ -n "${microcode_cpus}" ]; then if [ -n "${microcode_update_cpus}" ]; then echo "Warning: Ignoring deprecated rc variable, microcode_cpus." else echo "Warning: rc variable microcode_cpus is deprecated.Warning: Set microcode_udpate_cpus instead." microcode_update_cpus="${microcode_cpus}" fifi: ${microcode_update_enable="NO"}: ${microcode_update_datadir="/usr/local/share/cpucontrol"}: ${microcode_update_cpus="ALL"}: ${microcode_update_flags=""}run_rc_command "$1"
As for including cpu-microcode per default: It is not applicable for VM installations, so I second that it is not a core requirement.
4. (Optional) If you want to verify that the updates are working, you can install the package x86info. This is not contained in OpnSense, therefore you have to edit /usr/local/etc/pkg/repos/FreeBSD.conf to enable FreeBSD repositories temporarily. You can use these commands:Code: [Select]echo "FreeBSD: { enabled: yes }" > /usr/local/etc/pkg/repos/FreeBSD.confecho y | pkg install x86info"echo "FreeBSD: { enabled: no }" > /usr/local/etc/pkg/repos/FreeBSD.confrehashkldload -q cpuctlx86info -a | fgrep -i microcode
echo "FreeBSD: { enabled: yes }" > /usr/local/etc/pkg/repos/FreeBSD.confecho y | pkg install x86info"echo "FreeBSD: { enabled: no }" > /usr/local/etc/pkg/repos/FreeBSD.confrehashkldload -q cpuctlx86info -a | fgrep -i microcode
root@OPNsense:~ # echo y | pkg install x86infoUpdating FreeBSD repository catalogue...Fetching meta.conf: 100% 163 B 0.2kB/s 00:01Fetching packagesite.pkg: 100% 7 MiB 6.9MB/s 00:01Processing entries: 100%FreeBSD repository update completed. 34062 packages processed.Updating OPNsense repository catalogue...OPNsense repository is up to date.All repositories are up to date.New version of pkg detected; it needs to be installed first.The following 1 package(s) will be affected (of 0 checked):Installed packages to be UPGRADED: pkg: 1.19.2 -> 1.20.7 [FreeBSD]Number of packages to be upgraded: 1The process will require 21 MiB more space.9 MiB to be downloaded.[1/1] Fetching pkg-1.20.7.pkg: 100% 9 MiB 9.0MB/s 00:01 %Checking integrity... done (0 conflicting)[1/1] Upgrading pkg from 1.19.2 to 1.20.7...[1/1] Extracting pkg-1.20.7: 100%Updating FreeBSD repository catalogue...FreeBSD repository is up to date.Updating OPNsense repository catalogue...pkg: No SRV record found for the repo 'OPNsense'pkg: packagesite URL error for pkg+http://mirror.sfo12.us.leaseweb.net/opnsense/FreeBSD:13:amd64/23.7/latest/packagesite.pkg -- pkg+:// implies SRV mirror typepkg: packagesite URL error for pkg+http://mirror.sfo12.us.leaseweb.net/opnsense/FreeBSD:13:amd64/23.7/latest/packagesite.txz -- pkg+:// implies SRV mirror typeUnable to update repository OPNsenseError updating repositories!root@OPNsense:~ # echo "FreeBSD: { enabled: no }" > /usr/local/etc/pkg/repos/FreeBSD.confroot@OPNsense:~ # rehashroot@OPNsense:~ # kldload -q cpuctlroot@OPNsense:~ # pkg updateUpdating OPNsense repository catalogue...pkg: No SRV record found for the repo 'OPNsense'Fetching meta.conf: 100% 163 B 0.2kB/s 00:01pkg: packagesite URL error for pkg+http://mirror.sfo12.us.leaseweb.net/opnsense/FreeBSD:13:amd64/23.7/latest/packagesite.pkg -- pkg+:// implies SRV mirror typepkg: packagesite URL error for pkg+http://mirror.sfo12.us.leaseweb.net/opnsense/FreeBSD:13:amd64/23.7/latest/packagesite.txz -- pkg+:// implies SRV mirror typeUnable to update repository OPNsenseError updating repositories!
pkg add -f /var/cache/pkg/pkg-1.19.2.pkg