# Upgrading FreeBSD - how to fix



## Kryol (Aug 8, 2013)

Hi all,

I am trying to upgrade from 8.2 to 8.4. On 8.2 I have a custom kernel. Before the upgrade I accidentally put a generic kernel into /boot/generic instead of /boot/GENERIC. Now after reboot with the GENERIC kernel I see:

```
FreeBSD xxx.yyy.local 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
```

How to fix this and get the 8.4 version?


----------



## Savagedlight (Aug 8, 2013)

Select 'Escape to loader prompt' at the boot menu, then type 'boot generic'.


----------



## Kryol (Aug 8, 2013)

I can boot generic with `nextboot -k generic` or rename generic to GENERIC and `nextboot -k GENERIC`. But my GENERIC says 8.2 instead of 8.4. It's not updated. Files modification date for the kernel is 8.2 installation time. But /bin, /sbin etc. are 8.4 I think. At least I compare some file sizes with 8.4. They are identical. Could I just install the new GENERIC and continue or do I need to repeat the full upgrade process?


----------



## SirDice (Aug 8, 2013)

How did you upgrade? From source or freebsd-update(8)?


----------



## Kryol (Aug 8, 2013)

SirDice said:
			
		

> How did you upgrade? From source or freebsd-update(8)?



I upgraded with freebsd-update.


----------



## SirDice (Aug 8, 2013)

That should provide you with the kernel sources in /usr/src/, so {build,install}kernel should install the new 8.4 kernel.


----------



## Kryol (Aug 8, 2013)

SirDice said:
			
		

> That should provide you with the kernel sources in /usr/src/, so {build,install}kernel should install the new 8.4 kernel.



I have 8.4 kernel sources in /usr/src. Could I install new kernel under 8.2?


----------



## kpa (Aug 8, 2013)

Yes you can. Note that you can not update kernel alone but a new "world" has to be installed as well. The procedure is roughly like this:

`cd /usr/src`

`make buildworld buildkernel`
`make installkernel`

`nextboot -o "-s" -k kernel`

`shutdown -r now`

The system will come up in single user mode, press enter when asked for shell (defaults to /bin/sh)

`adjkerntz -i`
`mount -a -t ufs`
`mergemaster -p -Ui`
`cd /usr/src`
`make installworld`
`mergemaster -Ui`

`make delete-old`
`make delete-old-libs`

`reboot`

There's one downside to using this method, there is no way to go back to using freebsd-update(8) once you have done a source based upgrade.


----------



## SirDice (Aug 8, 2013)

kpa said:
			
		

> Yes you can. Note that you can not update kernel alone but a new "world" has to be installed as well.


Yes, but I have a feeling @Kryol's freebsd-update updated the rest of the system but failed to install a correct kernel because he was running a custom one. So my guess is that just a kernel build will be enough. Once you have a 8.4 kernel running I'd run freebsd-update(8) once more to make sure the rest of the base OS is correct.

If I'm not mistaken freebsd-update(8) only provides the kernel sources, not the complete source tree. Rebuilding the whole system is still possible but he'd have to fetch a complete source tree first.


----------



## kpa (Aug 8, 2013)

I haven't used freebsd-update(8) in a long time but it looks like you can control which components are updated by it using the Components directive in freebsd-update.conf(5):


```
Components 	      The parameters following this keyword are the
			      components or sub-components of FreeBSD which
			      will be updated.	The components are ``src''
			      (source code), ``world'' (non-kernel binaries),
			      and ``kernel''; the sub-components are the indi-
			      vidual distribution sets generated as part of
			      the release process (e.g., ``src/base'',
			      ``src/sys'', ``world/base'', ``world/catpages'',
			      ``kernel/smp'').	Note that prior to
			      FreeBSD 6.1, the ``kernel'' component was dis-
			      tributed as part of ``world/base''.
```


----------



## SirDice (Aug 8, 2013)

Yeah, I think I tried that in the past but it doesn't seem to fetch a full source tree. As I understood it it will update the source but only if it's already there. It may work if you extract src.txz from the install image, then run freebsd-update. In the end I gave up and switched to subversion to fetch my sources.


----------



## Kryol (Aug 9, 2013)

SirDice said:
			
		

> That should provide you with the kernel sources in /usr/src/, so {build,install}kernel should install the new 8.4 kernel.



It seems to work. Thanks


----------

