📜 ⬆️ ⬇️

Binary upgrade from FreeBSD 6.2 to 8.0

About two years ago I raised a sign for the server for the local lokalki tracker. The question of choosing the OS was not in principle, of course FreeBSD, and the version was taken up to date at that time - 6.2 i386. But the release of FreeBSD 8.0 took place, and I decided to try upgrading to version 8 on this server, still the tracker did not work for half a month because of a broken base during the next sudden power outage, and no one followed the server, so a couple of hours of downtime will not hurt anyone.

Task


Perform a binary upgrade of FreeBSD 6.2 i386 to 8.0 i386. I don’t want to initiate another holivar on the topic of “binary update vs rebuilding the kernel and the world from source”, I just wanted to quickly upgrade, and the machine there is pretty weak by today's standards, the reassembly of the world would take many, many hours. The task is aggravated by the fact that the server is accessible only remotely, all sorts of KVM, etc. there is simply no one to connect, the site is not serviced, and indeed there are none there anyway available. Therefore, options like “the kernel did not start after the reboot - load the old one”, or if something happens to a single mod, they don’t fit initially. In case of loss of network and ssh input, the task is considered failed.

Training


As a result of a long googling, a persistent impression has arisen that this is a bad job: first, they only recommend re-sampling from source, and, second, only a phased update 6.2 -> 6.3 -> 7.x -> 8.0. This option did not suit me due to time constraints, it was evening, rolling into the night, and I would like to get some sleep. Therefore, a little more googling the main reasons for possible jambs when updating, it was decided to take a chance.

First of all, the Release Notes to versions 7.0 and 8.0 were carefully examined for changes in hardware. And I must say, not in vain, because the server uses the motherboard on the nForce chipset and the network is used onboard, and the document clearly states
')
[amd64, i386] The nfe(4) driver, an open-source driver for nForce Ethernet devices, has been added, originally from OpenBSD. This driver has replaced the nve(4) driver in the GENERIC kernel.

In version 6.2, the network interface was called nve0, which means that in 7.0 and above it will be called nfe0, we will take this into account later when preparing /etc/rc.conf for updating, otherwise after the first reboot we lose the server, because without network interface settings the network will not rise, provider will not let.

We go further. Almost all the unsuccessful updates ended with the fact that after installing the new “world”, the basic commands cp, mv, ee, etc., refused to work. we cannot do anything further on the network. They refused because someone somewhere depended on obsolete libraries, which are removed during the update. As a possible solution to the problem, I decided to install the compat6x port, which contains all the necessary ones, and they will not be deleted after the update is completed. But this port is naturally absent in the ports tree of the 6th branch, so we will take it manually from the ports tree for the 8.x branch.

And one moment. Since the freebsd-update utility for binary updates first appeared just in version 6.2 and, in that form, did not support updating the system to a new version, I took freebsd-update from another server running FreeBSD 7.2.

Update


Before updating, it is highly desirable to update all ports to the latest versions, and we do. For this we will use / usr / ports / sysutils / portupgrade
# portsnap fetch update
# portupgrade -a

Download the updated freebsd-update to the server:
# cd /root && fetch http:// freebsd72.server/freebsd-update
# chmod +x freebsd-update

Install compatibility with compat6x 6th branch
# fetch ftp6.ua.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/misc/compat6x-i386-6.4.604000.200810_3.tbz
compat6x-i386-6.4.604000.200810_3.tbz 100% of 3060 kB 6805 kBps
# fetch ftp6.ua.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/misc/localedata-5.4.tbz
localedata-5.4.tbz 100% of 71 kB 2243 kBps
# pkg_add compat6x-i386-6.4.604000.200810_3.tbz
# pkg_add localedata-5.4.tbz

We stop all 3rd party demons, disable their autostart in /etc/rc.conf. We also remove from the file all the lines related to autorun or setting features that appeared as a result of rebuilding the kernel on the old system, for example: firewall_enable, firewall_type, gateway_enable, linux_enable, natd_enable, natd_interface, usbd_enable, enable_quotas. In general, all that may prevent us from booting on a clean system. We also correct the configuration of the ifconfig_nve0 network interface on ifconfig_nfe0, so that after installing the new kernel and reboot, the network has risen.

We remove from the crown of all users all tasks except the system ones (of course, we are not literally deleting, commenting).

There is another trick. The fact is that with a binary update of a system with installed sources, you need to download more than 2 times more files than when updating a system without sources. This problem is particularly relevant with a relatively slow connection to the Internet, or in the first days of the release of the new version of FreeBSD, when the update server is overloaded. Therefore, before updating, I delete the / usr / src directory so that the “update” would think that I did not install the source code and did not pull up an update for them, and after updating I take the source code from the new version distribution kit, which is uploaded in one file and downloaded quickly .
# rm -rf /usr/src


Download update

Getting started
# /root/freebsd-update upgrade -r 8.0-RELEASE
Looking up update.FreeBSD.org mirrors... 3 mirrors found.
Fetching metadata signature for 6.2-RELEASE from update5.FreeBSD.org... done.
Fetching metadata index... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic world/base world/catpages world/dict world/doc
world/games world/info world/manpages world/proflibs

The following components of FreeBSD do not seem to be installed:
kernel/smp src/base src/bin src/contrib src/crypto src/etc src/games
src/gnu src/include src/krb5 src/lib src/libexec src/release src/rescue
src/sbin src/secure src/share src/sys src/tools src/ubin src/usbin

Does this look reasonable (y/n)? y

Fetching metadata signature for 8.0-RELEASE from update5.FreeBSD.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.
Preparing to download files... done.
Fetching 13306 patches.....10....20....30....40....50............13280....13290....13300... done.
Applying patches... done.
Fetching 5413 files... done.


After downloading all the files for updating, the utility will try to update the system configuration files in automatic mode, if any file is difficult - the user will be offered a new version of the configuration file, with the option to accept it, or edit the file manually.
The following changes, which occurred between FreeBSD 6.2-RELEASE and
FreeBSD 8.0-RELEASE have been merged into /etc/passwd:
...
Attempting to automatically merge changes in files... done.

After merging all configs, a list of all files that will be deleted, added or updated will be displayed. Please note that at this stage no changes are made to the working system yet.
The following files will be removed as part of updating to 8.0-RELEASE-p0:
...
The following files will be added as part of updating to 8.0-RELEASE-p0:
...
The following files will be updated as part of updating to 8.0-RELEASE-p0:
...


Kernel update

Since we have previously deleted the source codes of the system, and we need them when building our own kernel, we take them from the distribution of the new version:
# cd /root && fetch ftp6.ua.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/8.0/8.0-RELEASE-i386-disc1.iso
# mkdir /mnt/freebsd80
# mount -rt cd9660 /dev/`mdconfig -a -t vnode -f "/root/8.0-RELEASE-i386-disc1.iso"` /mnt/freebsd80
# cd /mnt/freebsd80/8.0-RELEASE/src
# ./install.sh all

At this stage, you can assemble your kernel if necessary, necessarily taking as a basis the new config of the GENERIC kernel, making the necessary changes to it.
Since I use the ISPmanager server control panel, I usually add such options to the kernel config:
options IPFIREWALL
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=10
options IPFIREWALL_DEFAULT_TO_ACCEPT
options QUOTA

and rebuild
# cd /usr/src
# make buildkernel KERNCONF=MYKERNEL
# make installkernel KERNCONF=MYKERNEL

But for starters, I decided to boot at least into GENERIC.

Install the kernel update
# /root/freebsd-update install
Installing updates...
Kernel updates have been installed. Please reboot and run
"./freebsd-update install" again to finish installing updates.
# reboot

Reboot. If something can go wrong, it usually happens at this stage - the system simply does not boot, for example, due to unrecorded changes in the drivers, and we lose the server. Therefore, we cross our fingers and frantically ping the server:
tracker.server [123.123.123.123] 32 :
.
...
.
123.123.123.123: =32 =13 TTL=58

There is a contact! The system has risen, the network too, log in to the server via ssh and see
# uname -a
FreeBSD tracker.server 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:48:17 UTC 2009 root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
# ifconfig
nfe0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_MTU>
inet 123.123.123.123 netmask 0xffffff00 broadcast 123.123.123.255
...

As I correctly noted at the preparatory stage, the network interface is now called differently.

World update

Install the world update
# /root/freebsd-update install
Installing updates...
Completing this upgrade requires removing old shared object files.
Please rebuild all installed 3rd party software (eg, programs
installed from the ports tree) and then run "./freebsd-update install"
again to finish installing updates.

Here, I would advise you to reboot the server, as the process of upgrading other servers to FreeBSD 8.0 manifested various undesirable effects immediately after installing the world, such as devouring ipfw processor time, a couple of awk hung processes, etc. After rebooting everything is quiet and peaceful.
# reboot

It took about 45 minutes to do everything, including downloading the update files, which did not happen very quickly. Therefore, it’s good that I didn’t freebsd-update from having to update the system’s sources.

Port Reassembly

Now we need to rebuild absolutely all ports. To begin with, we rebuild ruby, on which portupgrade depends, which, in turn, will reassemble all other ports. At the same time, we delete the base of the installed packages, because when changing the major version of the portupgrade system, for some reason, this base is broken.
# rm /var/db/pkg/pkgdb.db
# portupgrade -f ruby\*

At the first start of portupgrade, immediately after upgrading the system, a new index of the ports tree / usr / ports / INDEX-8 will be downloaded and a base /usr/ports/INDEX-8.db will be created for it, for some reason, broken. Therefore, we delete it, together with the base of installed packages, and re-create them. If this is not done, portupgrade will swear on the broken bases one and the other each time it is started.
# rm /var/db/pkg/pkgdb.db
# rm /usr/ports/INDEX-8.db
# portsdb -fu
# pkgdb -fu

Now we reassemble all installed ports. On the FreeBSD website, it is advised to use portupgrade -fa, but in my case portupgrade started swearing at unknown options in the old installed ports (remember, everything was set to 6.2), so I had to update the ports manually.
# pkg_version -vI
# portupgrade -f pcre
# portupgrade -f perl
# portupgrade -f python25
# portupgrade -f lib\*
# portupgrade -f auto\*
# portupgrade -f p5-\*
...
# portupgrade -f php5\*
...

etc. according to the list.

Completion of system update

We delete obsolete ones
# /root/freebsd-update install
Installing updates... done.

Turn on the crown tasks of all users back, return to /etc/rc.conf autorun of all additional daemons, and reboot the last time
# reboot

That's it, FreeBSD 6.2 has been successfully remotely binary updated to 8.0.

ISPmanager update

ISPmanager is installed on the server, so we are updating it too; support for the 8th branch appeared just recently. Find the distribution you need here: download.ispsystem.com/FreeBSD-8.0
# cd /root && fetch http:// download.ispsystem.com/FreeBSD-8.0/i386/ISPmanager-Lite/install.tgz
# tar xvf install.tgz -C /usr/local/ispmgr/

Create a symlink for the apache extension for the correct version.
# cd /usr/local/ispmgr/lib/apache/
# rm -rf mod_ispmgr.so
# ln -s mod_ispmgr.2.2.0.so mod_ispmgr.so

and update the cache of installed packages and its configs
# killall ispmgr
# /usr/local/ispmgr/sbin/pkgctl cache
# /usr/local/ispmgr/sbin/pkgctl cache
# rm -rf /usr/local/ispmgr/var/.xmlcache


That's all, we have a server with FreeBSD 8.0 installed and the latest versions of the software from the ports.

In the process of preparation and updating, the experience of mankind was used, which was set out on websites that can be found through Google, in particular freebsd.org, opennet.ru and others.

UPD: Thank you all for your karma, transferred to BSD

Source: https://habr.com/ru/post/77685/


All Articles