freebsd-update very slow on spinning rust when installing many updates

I have this older box with spinning hdds and zfs. when doing freebsd-update -r it take hours mostly because installing all the new source files takes forever.
today i had 25k file to install and it took sever hours
looking at the code revealad that every file from INDEX-NEW in /var/db/freebsd-update/files is ungzipped in /var/db/freebsd-update and then installed with
install(1) in its proper location.
on my box this is frigging slow about 2-3 files per second so about 3 hours for 25k files
so i went to hack the script
here i have 3 variants, original, tmpfs add on, newer install(1) version
the zip files contains an INDEX-NEW and ~1000 files from clang source for the install test (they are pulled from a 14.4 box)
for the fi-ni.sh script to work you need install(1) from 14.5 (either test on 14.5 and fix the script to use install instead of /tmp/install or put the 14.5 install in /tmp)
the code in fi-std.sh is mostly pulled directly from /usr/sbin/freebsd-install just the install is done without setting user/group so it work as non root
the files are actually installed under /tmp/FI-script-name so you can delete those after testing
the fi-tmpfs.sh script will try to mount a tmpfs on ftmp but if you run as non root you must mount it before you run the script


here are the results (for 1000 files installed)
Code:
[SSDbox> ~/builds/fff]$ time scripts/fi-ni.sh >/dev/null
real    0m1.689s

[SSDbox> ~/builds/fff]$ time scripts/fi-std.sh >/dev/null
real    0m12.079s

[SSDbox> ~/builds/fff]$ time scripts/fi-tmpfs.sh >/dev/null
real    0m3.007s
=======================================================================================

[HDDbox> ~/builds/fff]$time scripts/fi-ni.sh >/dev/null
real    0m1.406s

[HDDbox> ~/builds/fff]$time scripts/fi-std.sh >/dev/null
real    5m17.404s

[HDDbox> ~/builds/fff]$time scripts/fi-tmpfs.sh >/dev/null
real    0m2.767s
zip file containing scripts and 1000 source files
attached without the gz files, only scripts + structure
 

Attachments

LE: if testing edit BASEDIR at the top of the scripts if your /tmp is on tmpfs / mfs so it gets more realistics. mine are on disks directly so i missed this possibility

tested on another hdd based box
same crappy performance

looks like using a 14.5 install on 14.4/ufs may set some weird flags on the files making it [a bit]difficult to delete after
 
it take hours mostly because installing all the new source files takes forever
It's probably quicker if you remove the source tree from freebsd-update(8) and update it separately using git(1).

Remove src from this line in /etc/freebsd-update.conf:
Code:
# Components of the base system which should be kept updated.
Components src world kernel
 
i could remove it but still would be slow in some cases. (less often though)
i have some INDEX-NEW files with over 20k files WITHOUT /usr/src
 
this tiny change will allow us to mount some tmpfs on /var/db/freebsd-update/xxx and speed it up 77x
if you don't mount xxx it's suckage as usual
Diff:
--- /usr/sbin/freebsd-update    2026-06-03 09:56:59.610608000 +0300
+++ /tmp/freebsd-update-fix    2026-10-20 23:15:49.206335000 +0300
@@ -2946,9 +2946,9 @@
             dir_conflict "${BASEDIR}/${FPATH}"
             if [ -z "${LINK}" ]; then
                 # Create a file, without setting flags.
-                gunzip < files/${HASH}.gz > ${HASH}
+                gunzip < files/${HASH}.gz > xxx/${HASH}
                 install -o ${OWNER} -g ${GROUP}        \
-                    -m ${PERM} ${HASH} ${BASEDIR}/${FPATH}
+                    -m ${PERM} xxx/${HASH} ${BASEDIR}/${FPATH}
                 rm ${HASH}
             else
                 # Create a hard link.
well xxx should be created with a mkdir above but still
 
Back
Top