Upgrading FreeBSD from and to

    As often happens, having hooked on one, at first glance, a small topic, with the desire to quickly learn everything and set everything up, you have to dig into dense wilds and read more than one article and / or manual. And so it happened to me this time. Initially, there was a desire to just learn how to update ports (or source codes of ports) so that if you wish, install not outdated software, but you had to dig a little deeper.
    This article is intended only for beginners in FreeBSD, experienced pros will not find anything new here, I think they will not find for themselves. Therefore, if you are on a “you” with this system, you can safely skip further text.
    There is enough information on this topic, but from 6-10 notes and articles I took, so to speak, the best practices and experience, and wrote them down in one, with links to more complete articles, so that if you wish you can get more detailed information on each item .
    The content of the article:
    1) The choice of software for updating the source code.
    2) The process of updating the source code of the system and ports.
    3) System update (core and world).
    4) Upgrading ports using pkg_ *, portupgrade, portdowngrade.
    5) Conclusion
    6) Further reading.

    Choosing software to update the sources


    So, when updating the source code, I highlighted 2 subsections - these are the source code of the system and the source code of the ports.
    1) When updating the source code of the system, you can use either the CVS or SVN repository. SVN is a newer development and is intended to replace obsolete cvs; accordingly, svn has wider functionality when working with source versions. But since I use FreeBSD as a gateway and every few days I am not going to update the system and do not intend to use additional utilities, it was decided to dwell on the good old cvs, because svn doesn’t require installing a small number of additional software, but I haven’t seen any global advantages for my tasks in svn. To work with the cvs repository to use utility csup(the same as cvsup but written in C), which is part of the standard composition of freebsd, that is, you don’t need to install anything else (updating via SVN is discussed in the additional literature at the end of the article).
    2) Updating the source code for ports is possible only from the CVS repository, for this you can use either csup or portsnap. Portsnap is the recommended system for updating ports and it is also pre-installed on the system, we will use it.

    The process of updating the system source and ports.


    Configuring csup to update system sources.

    To configure the update parameters, we create the file / etc / supfile: examples of tags for the src-all tree: RELENG_8 - FreeBSD branch 8-STABLE RELENG_8_1 - FreeBSD 8.1 branch which contains the security patches RELENG_8_1_0_RELEASE - “Frozen” snapshot of the status of the FreeBSD 8.1 code at the time of its release Everything is ready, we start the update: You can add the -z switch (compression) to save traffic. If the configuration file has just been created, and this program has never been used before, then you can start to worry if everything goes well ... There is an easy way for a trial run without affecting your precious files. Just create an empty directory somewhere and place it as an additional command line argument:
    *default host=cvsup6.ru.FreeBSD.org
    *default base=/var/db
    *default prefix=/usr
    *default release=cvs
    *default delete use-rel-suffix
    *default compress
    #*default release=cvs tag=RELENG_8_1_0_RELEASE
    *default release=cvs tag=RELENG_8
    src-all








    # csup -L 2 /etc/supfile



    # mkdir /var/tmp/dest
    # cvsup supfile /var/tmp/dest

    The specified directory will be used as the destination for all updates. CVSup will work with files from / usr / src, but will not modify or delete them. Instead, all file updates will be placed in / var / tmp / dest / usr / src. When launched in this way, CVSup will also leave the base directory untouched. New versions of these files will be written to the specified directory. If you have read permissions to the / usr / src directory, you don’t even need to work as root to perform a trial upgrade.

    Upgrading ports through portsnap

    For the first launch: For all subsequent launches:
    $ portsnap fetch
    $ portsnap extract


    $ portsnap fetch
    $ portsnap update


    Fastest cvsup

    The task of the fastest_cvsup utility is to find the server with the CVS repository that is optimal in access speed. Application:
    $ cd /usr/ports/sysutils/fastest_cvsup/
    $ make install clean & rehash


    $ fastest_cvsup -q -c ru

    System update (core and world), theory.


    Suppose we installed a freshly baked FreeBSD 8.1-RELEASE, and wanted to upgrade it to the FreeBSD 8-STABLE branch. We need to synchronize the source texts that we have on the disk with the repository - download new parts.
    The sequence of actions is as follows:
    1) compile the supfile and put the list directive in it. In which we indicate under what name the checkouts file should be saved:
    src-all tag = RELENG_8_1_0_RELEASE list = RELENG_8
    2) We carry out the first synchronization, with the command (#csup -L 2 / etc / supfile), with the frozen branch of our release RELENG_8_1_0_RELEASE
    3) Delete our supfile directive list:
    src-all tag = RELENG_8
    4) We carry out the second synchronization with the RELENG_8 branch - we update the sources to STABLE

    The essence of the idea is as follows: when working with csup, it uses checkouts files to compare information about file versions on the local disk and on the server, and synchronize only those that have changed. Immediately after installing the system, in the / var / db / sup directory there are no checkouts files for the collections we synchronize yet. The trick is to create them first. Since we have release 8.1 and the source code is installed from it, after conducting the first “synchronization” with the “frozen” tag of the same release RELENG_8_1_0_RELEASE we can build the current checkouts files. The first synchronization essentially does not synchronize, but only enumerates files on the disk and in the repository, and builds a database - a checkouts file. After the first synchronization, we will get the src-all subdirectory in the / var / db / sup directory.
    It will have a file called checkouts.cvs: RELENG_8 - because we specified it in the list directive. As soon as we start the second synchronization with the server, csup will know exactly which file versions to transfer and what to delete. Synchronization will be performed more cleanly, take less time and require less traffic.

    Flashing system (core and world), prkatika.


    uname –v- we find out the current version of the kernel
    uname –r- we find out the current version of the system The
    update is best broken into 2 parts, assembly - compilation of source codes and further installation. It’s not necessary to do this often because of this, for me, it’s best to do everything schematically, it’s easier to catch possible jambs.

    I) Assembly

    1. Kernel
    1) cd /usr/src/
    2) rm -R /usr/obj/*
    (If the deletion showed errors about the set flags, then you need to run the command #chflags -R noschg * )
    3) make clean && make clean
    4) make -sj4 buildkernel KERNCONF=YOUR_KERNEL_HERE
    (YOUR_KERNEL_HERE is the name of the kernel that is in the / usr / src / sys / i386 / conf folder. But note, you don’t specify the path, but specify only the file name .. I advise you to rename the file so that the new kernel
    compiles , and not what it was before the system update) Where j4 - compile into 4 streams. Recommended for uniprocessor machines, as compilation is more demanding on the input-output system, rather than the processor. For multiprocessors, this value can be increased. s - reduces the amount of information displayed on the screen.)

    2. World (system)
    1) cd /usr/src/
    2) rm -R /usr/obj/*
    3)make cleandir && make cleandir- (make cleandir recommends doing a handbook twice)
    4)make -sj4 buildworld

    II) Installation

    1. Kernel
    1) make installkernel KERNCONF=YOUR_KERNEL_HERE
    2) reboot
    2. World (system) The
    world is a user program - such as: grep, awk, sh, chmod, and more. In short, everything that is not included in the kernel and kernel modules. Before assembling, it is recommended to return to the standard view /etc/make.conf. In case of problems - if something is not going to be installed or not installed - it is worth seeing what is there and removing the excess.
    In the process of installing the world, ideally you need to run the mergemaster program. This program determines the difference between your configuration files in the / etc directory and the configuration files from the / usr / src / etc source tree. This is the recommended way to synchronize system configuration files with those located in the source tree.
    To rebuild the world, it is better to go into single-user mode (
    1) mount -u /
    2) mount -a
    3) rm -R /usr/obj/*
    4) /usr/src/usr.sbin/mergemaster –p
    If there are differences, a message about this appears on the screen.
    The first line in it is the name of the file, which does not meet the new requirements, and below the differences themselves.
    The “-” sign marks the lines that the utility is about to delete,
    and “+” - which will be added.
    At the end, the following options are offered:
    d - delete the proposed option and leave the old one;
    i - install the proposed option by deleting the old one;
    m - compare line by line the old and proposed options;
    v - see the differences in the files again.
    5)cd /usr/src/
    6) make installworld
    7) mergemaster
    8) reboot
    9) cd /usr/src/
    10)make delete-old

    Upgrading ports using pkg_ *, portupgrade, portdowngrade.


    1) #portsnap fetch update- port update.
    2) # pkg_version -v | grep “need”- Listing the ports that need to be updated
    3) #pkg_create -b port_name- Ability to create packages for the necessary ports with subsequent installation via pkg_add
    4) #pkg_add -i -f port_name.tbz- Installing the package without dependencies. After such an installation, the easiest way is to roll back to the previous version.

    Using portupgrade Utility

    You can find it here - / usr / ports / ports-mgmt / portupgrade
    1) portupgrade -nr port_name- displays detailed information about the future installation of the package (which files and dependencies will be updated)
    2) The -iportupgrade -ir port_name
    switch indicates that when upgrading the user is polled when there is selections (yes / no). The -r switch instructs to update the downstream port dependency chain. When updating with portupgrade, an important trump card is the settings file /usr/local/etc/pkgtools.conf, which contains the parameters that are passed to the port during assembly (MAKE_ARGS hash). It is useful to edit such settings in this file to your needs and subsequent updates will take place without unnecessary problems.



    Also, the necessary parameters can be torn out in case of reinstalling the port or when switching to some new version, and it is also useful to maintain compatibility of installations between servers. For example, the varied encoding of the installed mysql can kill a lot of nerves when moving a site between servers.
    There are times when it is necessary to prohibit iron updates for a specific port. The names of such ports can be specified in the HOLD_PKGS hash in the pkgtools.conf file, for example, we prohibit the midnight commander update:
    HOLD_PKGS = [
    'mc-*',
    ]

    Portdowngrade utility

    Allows you to roll back to the previous version.
    Installation: Use: - displays a list of previous port versions and makes it possible to select and install the desired version.
    # cd /usr/ports/ports-mgmt/portdowngrade
    # make DEFAULT_CVS_SERVER="anoncvs@anoncvs1.FreeBSD.org:/home/ncvs" install clean



    #portdowngrade port_name

    Conclusion


    Here is such a manual for a complete upgrade of FreeBSD. I just study this OS for this I do not pretend to discover something new, but personally it is much more convenient for me to use one article than the 5th, 6th, etc. for each individual utility, for this I compiled a manual for myself, but maybe it will turn out to be useful to someone as well!

    Literature


    Version control in Subversion
    Updating sources: cvsup, csup, svn, portsnap
    Using csup
    Examples of finer source control
    Additional information on running mergemaster
    portdowngrade - roll back the desired port to any earlier version of
    portupgrade - `update 'installed ports.

    Also popular now: