I have been slacking in terms of managing my Hassbian install. I should probably just bite the bullet and migrate to hassio but every time I try I run into some hurdles that just seems like more effort to resolve than its worth. Whatever. Hassbian is what we are talking about today. And with the release of Home Assistant 0.96 that laziness has a real cost.
Turns out that openssl in Home Assistant 0.96 is built on the binaries in Debian Buster. My Hassbian is built on Debian Stretch. That means if you upgrade to 0.96 while still using Stretch flavored Hassbian you are going to have issues. Your connection to Nabu Casa / Home Assistant Cloud is one of them.
So I decided that it was time to upgrade Hassbian. Turns out there isn’t a lot of docs on how to do that, specific to Hassbian, which may mean that a lot of people surf right by. Of course you could just download the newest Hassbian image and rebuild your HA server. If I was just running HA on my device that might be a good choice. As it stands, I have a lot of other scripts and assets HA uses that I would have to migrate or redo, and that just seems like more work.
So here is a quick guide to Upgrading Hassbian from Stretch to Buster.
First, I would make sure you are at the most recent version of the Hassbian you are running. I do this just to minimize potential issues later. After all, your are upgrading the operating system. This is not a minor update. There be dragons here. And by dragons I mean potential for major catastrophe, and by major catastrophe I mean quite possibly having to build the device from a fresh image. Granted the chances may be small, but it's not zero. I speak from expeirence. Not with Raspbian,but other linux flavors. YMMV.
Now that I have drop enough warnings lets see if we can pop some wheelies in this thing.
- ssh into your pi
- download the latest updates using
sudo apt-get update
- then apply the updates using
sudo apt-get -y upgrade
Once that has run (it won’t take too long) then you can get on to updating Hassbian to a new version. If you want to take a detour and reboot your device to check and make sure everything is still functioning that would be acceptable. If you haven’t made a good backup of all the things you would need to put back on this device if things go bad you are running out of chances.
To get ready for the upgrade, you need to update the apt-get sources with buster sources. These sources are simply the location for all the buster related packages your OS will need. This process consists of replacing ever occurrence of “stretch” with “buster” in these files. You can do it by hand, but sed is your best friend in these cases.
To do a massive find and replace run these three commands:
sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/raspi.list sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/hassbian.list
Your device may not have all three of these files. That is ok. Ignore the ones you dont have.
After you have updated the source files to point to the new package repositories lets update apt-get so it knows all the packages out there.
sudo apt-get update
We are now at the point of no return. Before you go on I strongly suggest you have a back up plan in mind. Hopefully a back up plan that involves an actual backup of important HA data.
Now that we have updated our Hassbian sources, we are ready to light this candle.
This process on my pi3b took about 3 1/2 hours from when I hit enter until I could reboot. So I suggest using screen to run this step. Screen, if you don’t know, allows you to detach your process from your terminal session so you can log off. Really useful if you want an interactive command to keep running but you want to be able to kill the ssh connection. If you don’t use screen you will need to make sure you can leave the ssh session open. Dropping the ssh session either on purpose or accidentally would be bad.
So fire up screen:
If screen is not installed
sudo apt-get screen will get it for you.
Once you are in screen and at a prompt start the upgrade
sudo apt-get -y dist-upgrade
Now sit back and wait. There will be a couple of times the upgrade prompts you for input.
You will get asked if you want to update then limits.conf, I told it to keep the one on the machine by answering N.
You will get asked if you want to keep the smb.conf. You will want to keep this one. So Answer N.
You will get asked if you want to keep the sshd.conf. You will want to keep this one too. So Answer N.
There are a couple of others. If it prompts you because it found an old file you are probably best saying N to replacing it. If you say Y no big deal. It just may mean you need to redo a config because it will more than likely replace it with a default one that is missing your specific parameters.
If you are using screen and need to leave at anytime just detach the screen by hitting Ctrl+A, D
Once you are back at a prompt you can safely exit. When you return, just execute:
And you should be abck to looking a termianl of text scrolling by. Thats basically it. After a while of updating files you will find your self at a blank prompt. At that point it is time to reboot.
Once everything comes back verify that Home Assistant is running as expected. You can verify that you are on the latest version of Hassbian, which at the time of this was 10. Just execute the following:
If all went well you are now running the future. Well at least for a few minutes. Enjoy it while you can.
Let's Automate this thing.