# How to switch from STABLE to RELEASE



## macosxgeek (Apr 8, 2022)

Hi,

I'm running 12.2-STABLE at the moment. This morning I wanted to upgrade to v13. Unfortunately when I'm running `freebsd-update fetch`

I'm getting:



```
freebsd-update: Cannot upgrade from a version that is not a release
(including alpha, beta and release candidates)
using freebsd-update. Instead, FreeBSD can be directly
upgraded by source or upgraded to a RELEASE/RELENG version
prior to running freebsd-update.
Currently running: 12.2-STABLE
```

I wanted to do 2x things basically:

1. Switch from STABLE to RELEASE first
2. Upgrade from 12.2 to the latest v13-RELEASE

And hopefully find some easy way of upgrading OS going forward.
Can I ask how this can be achieved?

--
Best regards
macosxgeek


----------



## SirDice (Apr 8, 2022)

macosxgeek said:


> 1. Switch from STABLE to RELEASE first
> 2. Upgrade from 12.2 to the latest v13-RELEASE


Going from 12-STABLE to 13.0-RELEASE is doable, I've done similar switches in the past. But you will have to build(7) from source. Switch your source to the releng/13.0 branch (it should be on stable/12 now). Make sure /etc/make.conf and/or /etc/src.conf don't have any customization, you want to build and install a "full" world, preferably also with a GENERIC kernel. Once you have built and installed releng/13.0 from source you can use freebsd-update(8) from that point onward. Wait for the release of 13.1-RELEASE, then use freebsd-update(8) to upgrade from 13.0-RELEASE to 13.1-RELEASE.


----------



## obsigna (Apr 8, 2022)

The following works for me:

Download and unpack the 13.0-RELEASE image:
`fetch https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.0/FreeBSD-13.0-RELEASE-amd64-memstick.img.xz`
`xz -d FreeBSD-13.0-RELEASE-amd64-memstick.img.xz`


Mount the image using the memory disk facility:
`mdconfig -a -u 0 -t vnode -f FreeBSD-13.0-RELEASE-amd64-memstick.img`
`mount -o noatime,ro /dev/md0s2a /media`


Mount the FreeBSD partition to be updated:
`mount -o noatime /dev/adaXpY /mnt`


Clone the new FreeBSD system over the old one -- except the user’s stuff:
`clone -s -x /mnt/usr/home:/mnt/usr/local:/mnt/usr/ports:/mnt/usr/obj:/mnt/usr/src /media/usr /mnt/usr`

`clone -s /media/sbin /mnt/sbin`
`clone -s /media/rescue /mnt/rescue`
`clone -s /media/bin /mnt/bin`
`clone -s /media/libexec /mnt/libexec`
`clone -s /media/lib /mnt/lib`

`clone -s -x /media/etc/motd.template:/mnt/etc/crontab:/mnt/etc/csh.login:/mnt/etc/exports:/mnt/etc/fstab:/mnt/etc/group:/mnt/etc/hostapd.conf:/mnt/etc/localtime:/mnt/etc/master.passwd:/mnt/etc/motd:/mnt/etc/ntp.conf:/mnt/etc/passwd:/mnt/etc/pwd.db:/mnt/etc/rc.conf:/mnt/etc/rc.local:/mnt/etc/resolv.conf:/mnt/etc/spwd.db:/mnt/etc/ssh:/mnt/etc/ssl:/mnt/etc/sysctl.conf:/mnt/etc/ttys:/mnt/etc/unbound /media/etc /mnt/etc`

`clone -s -x /mnt/boot/loader.conf:/mnt/boot/modules /media/boot /mnt/boot`


Unmount everything:
`umount /mnt`
`umount /media`
`mdconfig -d -u 0`
The actual cloning utilizes sysutils/clone. I did this also once on a live system, but I felt a bit uncomfortable and later I used a separate FreeBSD boot environment for updating FreeBSD using an installer image.


----------



## grahamperrin@ (Apr 8, 2022)

Upgrading from -STABLE to -RELEASE
					

Hello,  I'm probably going to run 13.0-STABLE for a while (reason here), but I don't plan to keep running it once 13.1-RELEASE is available.  Will it be possible to upgrade from 13.0-STABLE to 13.1-RELEASE, and then use binary upgrades again as I'm used to? Is there anything in particular I...




					forums.freebsd.org
				




For what it's worth, I'd aim for 13.1 i.e. <https://cgit.freebsd.org/src/log/?h=releng/13.1>


----------



## macosxgeek (Apr 9, 2022)

SirDice said:


> Going from 12-STABLE to 13.0-RELEASE is doable, I've done similar switches in the past. But you will have to build(7) from source. Switch your source to the releng/13.0 branch (it should be on stable/12 now). Make sure /etc/make.conf and/or /etc/src.conf don't have any customization, you want to build and install a "full" world, preferably also with a GENERIC kernel. Once you have built and installed releng/13.0 from source you can use freebsd-update(8) from that point onward. Wait for the release of 13.1-RELEASE, then use freebsd-update(8) to upgrade from 13.0-RELEASE to 13.1-RELEASE.




It worked perfectly fine:

`FreeBSD hostname 13.0-RELEASE-p11 FreeBSD 13.0-RELEASE-p11 #17 releng/13.0-n244800-d7fd130ebe5`

Thank you SirDice!

Just one last question: do I need to do anything with existing ports tree? eg. remove the existing '/usr/ports/' directory and fetch new ports with:


`portsnap fetch extract` ?

Ideally I would like to switch from ports to packages going forward - but I'm not sure if it's possible.


----------



## grahamperrin@ (Apr 9, 2022)

<https://cgit.freebsd.org/ports/refs/> the ports tree has latest (`main` branch) and quarterly (currently `2022Q2`), the collections are not OS version-specific so removal should not be necessary.


----------

