How to setup Openhab 2 on RPi4 with latest Raspian

I try to migrate my openhab 2 installation from my Pi Zero to my new Pi 4/8GB.
I installed the latest Raspian that automatically installs OH 3.1
Using the config tool I am unable to change the OH Version back to 2.
There is a menu that should allow you to do that, but it ends with an error message.
In the documentation it is mentioned that you cannot downgrade. I presume that applies to a configured installation not a blank installation.

So what would be the correct way to get OH2 on my new system?

Is there a specific need to not use OH3 ?

Straight after you flash sd card edit the openhabian config file before you put it in the pi.

Change the branch to stable.

To be fair, it’s a bit tricky to do it from a windows system, as the file openhabian.conf is placed in /etc/, that is part of /, which is on the second partition of the SD-Card, so no chance to edit from Windows directly.

If you have another SD-Card and an additional USB SD-Card Reader, the simplest way is to flash a Raspberry Pi OS Image on another SD-Card, start the Raspberry from this Card, add the SD-Card Reader and the SD-Card with openhabian to the Pi, get the name of the device via dmesg which will provide information about all stuff that is going on in the background in question of hardware (i.e. “oh, a new device is found, it’s a usb device, it’s a card reader… oh, another hardware found, it’s a storage device”) You can get information about the /dev/ path for the SD-Card (I guess it will be /dev/sda, but it could be any other path…)
Now to get access to the root partition (the second on the SD-Card), type

sudo mount /dev/sda2 /mnt

(replace sda with the correct device name).
Change directory:

cd /mnt/etc/

and edit the file

sudo nano openhabian.conf

after finishing the edit, save and exit. Finally leave the directory:

cd ~

and unmount the SD-Card:

sudo umount /mnt

power off the Pi, change SD-Cards, boot up.

If you don’t have another SD-Card or an external SD-Card Reader, you can use a vm from within Windows, but you can’t use Hyper-V, as it does not provide access to USB Host Hardware. vmware player should be fine, though.

Reading the docs is always a good idea, and expected from anyone before posting.

Thank you all for helping me with this.

I have read the docs before posting but I missed the one sentence that says you have to edit openhabian.config.

The reason that I did not realize that was the menu option in openhabian config that is supposed to downgrade the system from OH3 to OH2 but unfortunately that does not work.

The reason why I need OH2 :
I want to restore the backup I took on the pi zero.
I tried to do that in OH3 but this does not work. Also I cannot upgrade on the zero to oh3 as the installation is from 2018. So the most feasible way for me is to restore my OH2 installation on the pi4 and then upgrade to OH3.