# Cannot make buildworld after failed upgrade to 11.2



## jontheil (Aug 15, 2018)

Somehow I messed up an upgrade from 11.1-RELEASE to 11.2-RELEASE.

I can only boot into an old 11.0 kernel in single user mode.

`uname -a:

FreeBSD  11.0-RELEASE-p8 FreeBSD 11.0-RELEASE-p8 #0: Wed Feb 22 06:12:04 UTC 2017`

`freebsd-version

11.1-RELEASE-p11`

`freebsd-version -k

11.2-RELEASE`

`freebsd-version -u

11.1-RELEASE-p11`


```
svn info /usr/src

Path: /usr/src
Working Copy Root Path: /usr/src
URL: svn://svn.freebsd.org/base/releng/11.1
Relative URL: ^/releng/11.1
Repository Root: svn://svn.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 336092
Node Kind: directory
Schedule: normal
Last Changed Author: gordon
Last Changed Rev: 335466
Last Changed Date: 2018-06-21 07:18:08 +0200 (tor., 21 jun. 2018)
```

It is quite obvious that there is a mixture of different versions involved, and I can’t boot into the newest kernel. Some startup scripts are damaged and I can’t start /etc/rc.d/zfs

I'm not able to run make buildworld from a 11.1-RELEASE source tree. The first error was a missing include/__undef_min_max which I had to copy manyally:

`cp /usr/src/contrib/libc++/include/__undef_min_max /usr/include/c++/v1/`

Now I'm getting new errors like


```
/usr/include/c++/v1/__split_buffer:13:1: error: unknown type name '_LIBCPP_PUSH_MACROS'
```

and


```
/usr/include/c++/v1/__split_buffer:17:1: error: expected unqualified-id.
```

As some vital files and directories are on a zfs drive, there is a lot of stuff I can’t recover if I have to start from a clean install. My backups of the home/zfs partition are outdated, and I only have partial backups of the rest of the system.

I asked more or less the same question on the mailing list 

http://freebsd.1045724.x6.nabble.co...e-buildworld-from-11-0-RELEASE-td6268323.html and got a reply about the same kind of troubles with no directions.

Can anyone suggest a solution or part of one?

Thank you very much in advance


----------



## SirDice (Aug 15, 2018)

If you're going to stick to a -RELEASE why don't you simply use freebsd-update(8)?


----------



## jontheil (Aug 15, 2018)

SirDice said:


> If you're going to stick to a -RELEASE why don't you simply use freebsd-update(8)?


I actually tried that. Somehow I made some mistakes when merging various files. Do you think it is still an option even when the versions seem to be mixed?


----------



## ShelLuser (Aug 15, 2018)

jontheil said:


> I actually tried that. Somehow I made some mistakes when merging various files. Do you think it is still an option even when the versions seem to be mixed?


It should be. The only thing which gets mixed as config files (such as those in /etc and those differences aren't all that heavy when doing a minor release upgrade.


----------



## SirDice (Aug 15, 2018)

jontheil said:


> Do you think it is still an option even when the versions seem to be mixed?


Yes, but you may need to coax freebsd-update(8) a bit because your versions are currently a bit of a mess. 

`freebsd-update -r 11.2-RELEASE --currently-running 11.1-RELEASE-p11 upgrade`


----------



## jontheil (Aug 15, 2018)

SirDice said:


> Yes, but you may need to coax freebsd-update(8) a bit because your versions are currently a bit of a mess.
> 
> `freebsd-update -r 11.2-RELEASE --currently-running 11.1-RELEASE-p11 upgrade`



I'ill try that and report back. Thanks.


----------



## Maelstorm (Aug 15, 2018)

Hmm...  What caused the update to fail in the first place?  What what the command that you used and what was the error?  The snv tool is pretty good about keeping things in sync.

I use the release branch.  I do a clean install between major versions and source upgrade for minor versions.  For example, going from 10.x to 11.1 I did a clean install.  But going from 11.1 to 11.2 I updated the source tree and rebuilt the system.  I can't really use freebsd-update because I am using custom kernels.  Although it would save time when rebuilding the system.


----------



## jontheil (Aug 15, 2018)

I cannot tell you all the mistakes I made... It is quite embarrassing. I don't usually use vi(1) as a text editor. Therefore, I might have introduced errors while merging. For example, I'm not absolutely sure what to do in the following case:

```
#!/bin/sh
#
# $FreeBSD: releng/11.2/etc/periodic/daily/480.leapfile-ntpd 325256 2017-11-01 01:03:44Z cy $
#

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

case "$daily_ntpd_leapfile_enable" in
    [Yy][Ee][Ss])
<<<<<<< current version
<<<<<<< current version
        if service ntpd oneneedfetch; then
            anticongestion
            service ntpd onefetch
        fi
        ;;
=======
        anticongestion
        service ntpd onefetch
=======
        if service ntpd oneneedfetch; then
            anticongestion
            service ntpd onefetch
        fi
>>>>>>> 11.2-RELEASE
        ;;
>>>>>>> 11.1-RELEASE
esac

exit $rc
```


----------



## Maelstorm (Aug 15, 2018)

When I updated my system, that file did not show up in mergemaster.  You might be able to use a rescue disk to install a generic kernel and the basic userland to get the system working again on FreeBSD 11.1.  Make a copy of some of your critical config files from /etc like fstab and rc.conf.  I don't know what zfs uses for configuration since I don't use zfs.  Once you have the binaries in sync, then you can redownload the source tree using svn.

I have found that the best teacher of what to do and what not to do is when you make mistakes and then correct or attempt to correct the aftermath of those mistakes.


----------



## ShelLuser (Aug 15, 2018)

Perhaps merge(1) can be of some help here?

```
<<<<<<< file A
              lines in file A
              =======
              lines in file B
              >>>>>>> file B
```
It's usually sufficient to remove one of the given alternatives.


----------



## SirDice (Aug 15, 2018)

jontheil said:


> I don't usually use vi(1) as a text editor


Set the EDITOR variable to your favorite editor beforehand.


----------



## jontheil (Aug 16, 2018)

Maelstorm said:


> When I updated my system, that file did not show up in mergemaster.  You might be able to use a rescue disk to install a generic kernel and the basic userland to get the system working again on FreeBSD 11.1.  Make a copy of some of your critical config files from /etc like fstab and rc.conf.  I don't know what zfs uses for configuration since I don't use zfs.  Once you have the binaries in sync, then you can redownload the source tree using svn.
> 
> I have found that the best teacher of what to do and what not to do is when you make mistakes and then correct or attempt to correct the aftermath of those mistakes.



You are absolutely right about learning from mistakes.

If I get the system back by using the a rescue disk, then I guess I will loose all the installed ports.


----------



## jontheil (Aug 16, 2018)

ShelLuser said:


> Perhaps merge(1) can be of some help here?
> 
> ```
> <<<<<<< file A
> ...



In my case, merge(1) seems to be run twice on the same file, once for 11.1 and once for 11.2. The output is hard to interpret since the markup doesn't use indentation or colors (which wouldn't be any help in my console).


----------



## SirDice (Aug 16, 2018)

You have a fairly recent source tree from your previous attempts. You can probably find a good copy of that file there. Good enough to compare and you could even use that copy instead.


----------



## Maelstorm (Aug 16, 2018)

jontheil said:


> You are absolutely right about learning from mistakes.
> 
> If I get the system back by using the a rescue disk, then I guess I will loose all the installed ports.



Actually, no.

What you do is copy the files from the rescue disk to the correct locations.  It does not affect ports/packages because they are loaded into a different location.  The main locations that you need to worry about are:


/boot
/etc
/bin
/sbin
/lib
/libexec
/usr/bin
/usr/sbin
/usr/lib
/usr/lib32
/usr/libexec
/usr/include
/usr/share
Everything to get the system up and running is there.  I found a couple of links for you to look at.

https://forums.freebsd.org/threads/install-freebsd-from-a-rescue-disk.66344/
https://forums.freebsd.org/threads/installing-freebsd-manually-no-installer.63201/

If you are concerned about your ports, I would copy the package database (and files from /etc) to somewhere safe and go from there.  I suspect that your disk layout is something similar to what I was using.  In your original post, you mention that critical files and directories are on a zfs partition.  I made a similar mistake by having my entire /usr directory on a separate harddisk which eventually failed, which put me in a similar situation that you are currently in.

Here's some more threads to read about disk layouts and such:

https://forums.freebsd.org/threads/partial-install-10-4.63763/
https://forums.freebsd.org/threads/strange-errors-on-boot-using-11-1.63815/

Hope this helps.


----------



## ShelLuser (Aug 16, 2018)

Worst case scenario: boot into rescue mode using an install CD and extract /usr/freebsd-dist/base.txz. Do keep in mind that this will _also_ overwrite /etc entirely.

But that can be a quick (and dirty) way to reset your system. Oh: don't forget about kernel.txz either.


----------



## jontheil (Aug 17, 2018)

Maelstorm said:


> Actually, no.
> 
> What you do is copy the files from the rescue disk to the correct locations.  It does not affect ports/packages because they are loaded into a different location.  The main locations that you need to worry about are:
> 
> ...



I will have a look at the links and your own explanation.

Thanks a lot.


----------



## ksb (Oct 1, 2018)

Any news on this?  I'm having nearly the exact same issue and would like to avoid having to go to the above "worst case scenario".


----------

