BeastieBoy

FreeBSD, Lisp, Emacs, PostgreSQL & co.

freebsd-update and corrupt metadata

freebsd-update and corrupt metadata

I was updating my laptop from FreeBSD 11.0 to FreeBSD 11.1 today, something I should have done already sometime ago, but let's forget about that. While doing so, doing the usual freebsd-update -r 11.1-RELEASE upgrade would give the following:

root@priest:/root # freebsd-update -r 11.1-RELEASE upgrade
Looking up update.FreeBSD.org mirrors... 3 mirrors found.
Fetching metadata signature for 11.0-RELEASE from update5.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata files... gunzip: (stdin): unexpected end of file metadata is corrupt.

Usually, this means that something went wrong while downloading the file, and trying again is likely to solve the issue. All you have to do then is remove the faulty metadata file first, and type the same command:

root@priest:/root # rm /var/db/freebsd-update/65ce95e4589bd0481b57091a9e476361c713dbb67a77136318cef1b7489c6b7a.gz
root@priest:/root # freebsd-update -r 11.1-RELEASE upgrade

This solves the issue 99% of the time. However, in my case, it did not, and I kept getting the same error again and again. What this is means is that the distant file is at fault, and that freebsd-update is downloading this very file each and every time. All it takes in this case is to instruct the command to select a different mirror. First, look into the file serverlist_tried which server (or mirror) you have been working with:

root@priest:/root # cat /var/db/freebsd-update/serverlist_tried
1 50 update5.freebsd.org

Next, open serverlist to see what the alternatives are:

root@priest:/root # cat /var/db/freebsd-update/serverlist
1 35 update4.freebsd.org
1 40 update6.freebsd.org
1 50 update5.freebsd.org

Now, remove the faulty file, and ask freebsd-update to use another mirror:

root@priest:/root # rm /var/db/freebsd-update/65ce95e4589bd0481b57091a9e476361c713dbb67a77136318cef1b7489c6b7a.gz
root@priest:/root # freebsd-update -s update4.freebsd.org -r 11.1-RELEASE upgrade

The upgrade should go flawlessly from then on.