Binary Upgrade from FreeBSD 6.2 to 8.0

    About two years ago I raised a server for the local LAN tracker. The issue of choosing an OS was not in principle, of course, FreeBSD, and the version was taken relevant 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, all the same, the tracker hadn’t been working for half a month already due to a broken base at the next sudden power outage, and no one was monitoring the server, so a couple of hours of downtime nobody will be disturbed.

    Task


    Binary upgrade FreeBSD 6.2 i386 to 8.0 i386. I don’t want to initiate another holivar on the topic “binary update vs rebuilding the kernel and the world from source”, I just wanted to upgrade quickly, and the machine there is pretty weak by today's standards, rebuilding the world would take many, many hours. The task is compounded by the fact that the server is accessible only remotely, all sorts of KVM, etc. there’s simply no one to connect, the site is not serviced, and no, they are still there. Therefore, options such as "the kernel did not start after reboot - load the old one", or in which case the single mod - do not fit initially. In case of network loss and ssh login, the task is considered failed.

    Training


    As a result of prolonged googling, there was a strong impression that this was a disastrous thing: firstly, they recommend exclusively rebuilding from the sources, and, secondly, only a phased update of 6.2 -> 6.3 -> 7.x -> 8.0. This option did not suit me because of the limited time, it was evening turning into night, and I would like to sleep at least a little. Therefore, a little googling the main reasons for the possible jambs during the update, it was decided to take a chance.

    First of all, Release Notes for versions 7.0 and 8.0 was carefully studied for changes in hardware. And, I must say, not in vain, because the server uses a motherboard based on the nForce chipset and the on-board network is used, and the document clearly says

    [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 later it will be called nfe0, we will take this into account later in the preparation of /etc/rc.conf for the update, otherwise after the first reboot we lose the server, because without the network interface settings, the network will not rise, the provider will not let.

    We go further. Almost all unsuccessful updates ended with the fact that after installing the new “world” the basic commands cp, mv, ee, etc., refused to work, i.e. further down the network we can’t do anything. They refused because someone somewhere depended on outdated libraries that were deleted during the upgrade. 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 utility for binary update freebsd-update first appeared just in version 6.2 and in that form did not support updating the system to the new version, I took freebsd-update from another server running FreeBSD 7.2.

    Update


    Before upgrading, it is highly advisable to upgrade all ports to the latest versions, so we do. To do this, we will use / usr / ports / sysutils / portupgrade Download the updated freebsd-update to the server: Install any compatibility with the 6th branch compat6x
    # portsnap fetch update
    # portupgrade -a


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


    # 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 autorun in /etc/rc.conf. We also remove from the file all lines related to autorun or customization of 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 can prevent us from loading on a clean system. Here we fix the configuration of the network interface ifconfig_nve0 to ifconfig_nfe0, so that after installing a new kernel and reboot the network rises.

    We remove all tasks from the crown of all users, except for system ones (of course, we do not literally delete, comment).

    There is one more trick. The fact is that when binary updating 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 especially relevant with a relatively slow Internet connection, or in the early days of the release of the new version of FreeBSD, when the update servers are overloaded. Therefore, before updating, I delete the / usr / src directory so that the “updateer” thinks that the sources are not installed and did not pull up the update for them, and after the update I take the sources from the distribution package of the new version, which is laid out as a single file and downloads quickly enough .
    # rm -rf /usr/src


    Download update

    We begin. After downloading all the files for updating, the utility will try to update the system configuration files in automatic mode, if some file causes difficulty, the user will be offered a new version of the configuration file, with the ability to accept it, or edit the file manually. After merging all the 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 running system.
    # /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.



    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.


    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 previously deleted the system sources, and we need them when building our own kernel, we take them from the distribution of the new version: At this stage, you can build your own kernel if necessary, be sure to take the new GENERIC kernel config as a basis, making the necessary changes to it. Since I use the ISPmanager server control panel , I usually add such options to the kernel config: and rebuild But for a start, I decided to boot at least into GENERIC. Installing a kernel update
    # 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



    options IPFIREWALL
    options IPFIREWALL_VERBOSE
    options IPFIREWALL_VERBOSE_LIMIT=10
    options IPFIREWALL_DEFAULT_TO_ACCEPT
    options QUOTA


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




    # /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, then this usually happens at this stage - the system simply will not boot, for example, due to unaccounted changes in the drivers, and we will lose the server. Therefore, we cross our fingers and frantically ping the server: There is a contact! The system has risen, the network, too, log in to the server via ssh and see As I correctly noted at the preparatory stage, the network interface is now called differently.
    Обмен пакетами с tracker.server [123.123.123.123] с 32 байтами данных:
    Превышен интервал ожидания для запроса.
    ...
    Превышен интервал ожидания для запроса.
    Ответ от 123.123.123.123: число байт=32 время=13мс TTL=58


    # 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 mtu 1500
    options=10b
    inet 123.123.123.123 netmask 0xffffff00 broadcast 123.123.123.255
    ...



    World update

    Installing the world update Here I would advise rebooting the server, because in the process of upgrading other servers to FreeBSD 8.0 various undesirable effects appeared immediately after the installation of the world, such as eating ipfw processor time, a couple of awk freezes, etc. After the reboot, everything is quiet and calm. It took about 45 minutes for everything about everything, including downloading update files, which did not happen very quickly. Therefore, it is good that I saved freebsd-update from the need to update the system sources.
    # /root/freebsd-update install
    Installing updates...
    Completing this upgrade requires removing old shared object files.
    Please rebuild all installed 3rd party software (e.g., programs
    installed from the ports tree) and then run "./freebsd-update install"
    again to finish installing updates.


    # reboot



    Port Reassembly

    Now we need to rebuild absolutely all ports. To begin with, we rebuild ruby, on which portupgrade depends, with which in turn we will rebuild all other ports. At the same time, we delete the database of installed packages, because when changing the major version of the portupgrade system, for some reason, it believes that this database is broken. At the first start of portupgrade, immediately after updating the system, a new index of the ports tree / usr / ports / INDEX-8 will be downloaded and, for some reason, the /usr/ports/INDEX-8.db database will be created for it. Therefore, we delete it, along with the base of installed packages, and recreate them. If this is not done, portupgrade will swear at the broken bases one and the other at each start.
    # rm /var/db/pkg/pkgdb.db
    # portupgrade -f ruby\*


    # rm /var/db/pkg/pkgdb.db
    # rm /usr/ports/INDEX-8.db
    # portsdb -fu
    # pkgdb -fu

    Now we rebuild all installed ports. The FreeBSD site is advised to use portupgrade -fa, but in my case, portupgrade started swearing at unknown options in the old installed ports (do not forget, everything was set to 6.2), so I had to update the ports manually. etc., according to the list.
    # pkg_version -vI
    # portupgrade -f pcre
    # portupgrade -f perl
    # portupgrade -f python25
    # portupgrade -f lib\*
    # portupgrade -f auto\*
    # portupgrade -f p5-\*
    ...
    # portupgrade -f php5\*
    ...



    System update completion

    We remove obsolete libs We turn on the tasks of the crown of all users back, return autorun of all additional daemons to /etc/rc.conf, and restart for the last time. Everything, FreeBSD 6.2 was successfully remotely binary upgraded to 8.0.
    # /root/freebsd-update install
    Installing updates... done.


    # reboot



    ISPmanager Update

    ISPmanager is installed on the server, so we are updating it, support for the 8th branch appeared just the other day. We find the necessary distribution here: download.ispsystem.com/FreeBSD-8.0 We create a symlink for the extension for Apache the correct version and update the cache of installed packages and its configs That's all, we have a server with FreeBSD 8.0 installed and the latest software from the ports. In the process of preparation and updating, we used the experience of mankind set forth on sites that can be found through Google, in particular freebsd.org, opennet.ru and others. UPD: Thanks to everyone for karma, transferred to BSD
    # cd /root && fetch http:// download.ispsystem.com/FreeBSD-8.0/i386/ISPmanager-Lite/install.tgz
    # tar xvf install.tgz -C /usr/local/ispmgr/


    # cd /usr/local/ispmgr/lib/apache/
    # rm -rf mod_ispmgr.so
    # ln -s mod_ispmgr.2.2.0.so mod_ispmgr.so


    # killall ispmgr
    # /usr/local/ispmgr/sbin/pkgctl cache
    # /usr/local/ispmgr/sbin/pkgctl cache
    # rm -rf /usr/local/ispmgr/var/.xmlcache







    Also popular now: