Make your Home Assistant Fast & Reliable - Moving to a Solid Sate Drive

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
are you a home assistant user that's sick and tired of having to replace a sd card every six to 12 months or do you just want more speed out of your raspberry pi and home assistant well on today's episode we'll show you how to configure your raspberry pi run home assistant off of a solid-state drive to get a much larger speed boost and increased reliability of your system ever since i've been using home assistant i've had an issue where about every 12 months i start having problems with my home assistant instance just randomly stopping i go downstairs i look at the pie and the network lights are on everything looks fine but it's just it just crashes it stops working well this is because the sd card that i use ends up wearing out sd cards are not meant to run operating systems off they're they have a limited numbers of reads and writes and after those get exceeded you start having reliability issues so i did some research and found this great guide on how to install home assistant on a solid state drive full credit goes to form user jpsy george wagner or wagner i'm not sure how that's pronounced he's written a excellent guide that has been updated numerous times on how to run home assistant on a solid state drive using a raspberry pi now this is something that's only been introduced on the pi 4s they have a special eep rom a bit of flashable memory where you can set um to boot from a usb device this is a very cheap and easy way to upgrade your home assistant instance into getting some of those more closer to desktop speeds that you would if you had a dedicated server now i have an intel nok running my linux server in the basement i'm actually running proxmox on it so it's running a bunch of virtual machines and i do have a virtual instance of home assistant i like having the redundancy of having a separate piece of hardware running my home assistant instance in case for some reason the virtual machine crashes or the virtual host crashes and i'm not able to access it i'm still able to see my home assistant devices i'm still able to control my lights and other things i still like to run mine on a separate raspberry pi 4. now last year i upgraded my pi 4 from a 1 gig to a 3 4 gig version and at that time i swapped out the sd card well after about six months i've been having problems again i figured this is a perfect opportunity to go ahead and switch over to a solid state drive and a great opportunity to make a video about it so the overall steps that we're going to be going through again i've got a link to this guide if you want to just skip the rest of the video and you just prefer to read through it view his excellent guide it has all the details but in this video i'm filling in some of the missing components that he just assumes that you know if you're a long time raspberry pi user or linux user so if you're looking for detailed steps that's what this video is for if you just want to skip through to the end feel free to click on the link in the description and go through his guide all right so let's look at what's needed for this all right so before we can start on the software portion on how to set this raspberry pi with a solid-state drive let's go over what hardware is required um i'll be using a four gigabyte raspberry pi 4b um there is i think variants that go from one all the way up to eight gigabytes now but uh the one i'm using is four gigs and i just have the standard off-the-shelf raspberry pi case i'm using the raspberry pi for official power down one of the notes on this guide is that it's important to use one with a high enough power output so that you can power both the raspberry pi and the solid state drive adapter this is important because if you start to run low on the amount of power available it will cause the solid state drive to be very flaky and the the drive adapter we're using does not have a external power supply on it next up is the solid state to usb 3.0 adapter this is the one from startech it's linked in the description below it's once recommended by the original author of the guide he states that it's important because this has a particular chipset that works with the raspberry pi 4 bootloader so make sure you get an adapter that is compatible not just one you find in a drawer somewhere then i'm using a 240 gig solid state drive this is just a generic solid state drive that i got from micro center i happen to have laying around really the size doesn't matter all that much as long as it's big enough to support your database which does get quite large and the files and the components in your home assistant instance so what you'll need is a standard micro sd card this one's 32 gigs but you can use anything probably eight gigs and bigger this is only to load the initial raspberry pi os on board so that way we can update the boot eprom on the raspberry pi 4. you can then recycle this uses for something another project later on but it's recommended to go ahead and keep one of these around just in case you run into problems booting off the ssd later on this can be used to recover the files off your solid state drive and optionally if you happen to have a micro hdmi adapter a monitor keyboard available you can use that to set up the raspberry pi but i'm going to show you a method that you can use just using ssh which i think is a lot easier and it requires less items all right so now that we know what hardware let's get started by flashing both the solid state drive and the sd card so we're going to go ahead and flash raspberry pi os on the sd card and then make one change to a file to enable ssh remote into the pi and flash that eprom let's go ahead and start by taking the sd card and putting it into usb adapter and then we'll get it flashed all right so before we can flash raspberry pi os on the drive we need to get downloaded so you can just go go there by either clicking the link in the description or in the lower third here or go to raspberrypi.org software so they have a nice built-in imager that will download the current version of raspberry pi and flash it to your sd card automatically so we'll go ahead and download that version for windows obviously if you're on mac os or ubuntu you can do that through the links listed here but once that downloads we'll go ahead and flash raspberry pi os and then make that modification to the sd card all right so that is downloaded we'll go ahead and run the imager and go go ahead and install it i'm sure i had an older version already on my so let's run it and so then we want to choose the os that we want to use here now we'll go ahead and do the 32-bit here because it really doesn't matter we're just using this to boot from this is the desktop version which we don't really need the desktop version because we're going to be accessing this via ssh so if you're more comfortable and you're going to be doing this with hdmi you can go ahead and select the desktop version so you'll get the gui interface if you just want to do the command line we can go ahead and grab the lite version with no desktop environment and go from there so i'm gonna go ahead and do the lights will be faster all right once you've selected the proper os we need to make sure we're flashing to the correct card so in this case i actually have a 128 gigabyte drive in my machine along with a 500 gig ssd so i want to make sure i don't overwrite those because that'd be very bad so i'm going to select this is the sd card device i have connected to my reader once you do those two things click right make sure you have the correct one and hit yes now this is going to go ahead and write it's going to split the drive up appropriately so the raspberry pi read it and we'll go ahead and skip through this all right now that the sd card has been flashed successfully we can click continue it tells you to go ahead and remove it from the reader but don't do that just quite yet we want to make a quick modification to the boot drive on the sd card so let's go ahead and open up windows explorer and let's navigate to the boot drive there you'll see all of the information on on the boot partition of the drive this is the only one that's readable by windows natively so what we need to do now is create a blank file called ssh so to do that we'll go ahead and open up notepad nope you can use notepad or notepad plus plus either one so i opened up notepad plus plus create a new document go to file save as navigate to that boot partition and then select all types this will allow you to create a file without a extension so not dot text or dot bat whatever it is so you're able to create just the blank file so you can call the file name ssh and then hit save and you can confirm that by going in to your boot partition and finding the file in here and there it is so the file has been created and it should be a file type of file because it has no extension on there in windows so what that's going to do is when your raspberry pi boots up and it sees that ssh file it will enable ssh then we have to go into the raspberry pi configuration on that first boot and change it to allow permanently allow ssh if you boot this raspberry pi up one time and then restart it again it'll remove that ssh file from the system and you won't be able to access it via ssh now let's go ahead and move on to getting the solid state drive flashed let's go ahead and get the installer ready for the ssd the solid state drive so to flash the solid-state drive i'd recommend downloading this application etcher it's free for windows and it seems to be the best kind of gold standard for flashing both sds and ssds so i already have it installed but you can you can click the link in the description or go to the shorter url url here at the bottom and download this and then once you get it downloaded and installed we'll go ahead and run it so now that we have the application to flash the ssd we need the software we need the software to download for that ssd so we're going to pop over here to the home assistant releases and grab the latest release 5 version which at the time of this recording is build 10 or 5.10 so i want to scroll down here to the assets portion of the page and we're going to look for hass os raspi4 rpi4 dash 64 dot dash the version number so again we're gonna be running the 64 64-bit version because that's the version recommended it used to be 32-bit was recommended on the raspberry pi 4 but now they recommend the 64-bit version so we want to download this dot img file here so we'll go and click on it and then save the file all right now that the file has been downloaded because we've installed the the raspberry pi os installer it automatically associated that file type with it which you could use that to flash the ssd but i find etcher's a little more reliable so we'll go ahead and use it so i'm going to select the image which in my case will be my downloads folder so again has os rpi 4-64.version number click open and then we're going to select the drive or you can flash the ssd you need to attach it to the adapter uh it's just a friction connection here so you'll just press it in and once it's held in there it's held pretty securely so you won't even need to place this in an enclosure or anything i'll actually just attach this to the wall where i place my pie down in the basement and then zip tie it to the pegboard i have there that way it stays up there and secure all right so now go ahead and attach the usb 3 port to your computer obviously attaches to a 3.0 port to make this flash go faster it should work with a 2.0 port but i'd recommend a 3.0 port if you have one available on the pc you're going to do the flashing on all right now that we have a solid state drive attached to the usb adapter and that's plugged in and successfully loaded into windows now we can go ahead and select the drive and we want to select this ssd 240 gig again make sure it's the correct one before you flash it because you don't want to overwrite on one of your existing drives click continue and then flash now it will pop up on windows and ask to run as administrator which is fine and we will go ahead and let this run shouldn't take too long because it's not a giant image and we're using the 3.0 bus so it should be pretty quick so it says about 10 minutes so we'll go ahead and skip this and then finish up the drive here in a minute all right now the solid state drive is finished being flashed home assistant so we can go ahead and disconnect it and we'll hold on to the solid state drive for the later step so now let's jump into connecting to the raspberry pi with raspberry pi os and getting it configured to flash the eprom now i noticed when i had the usb port plugged into one of my hubs i was getting an error in my device manager well that's because there wasn't enough power being applied to the solid state drive so if you plug the solid state drive adapter into your pc and it doesn't show up in windows or linux or mac make sure it's connected directly to the computer i had to break out one of my usbc to a adapters and plug it in straight into one of the ports of my laptop then it had enough power to go ahead and bring it up in windows so again like we said before you need to make sure you have enough power to both run the device and the adapter so just be aware of that if you do run into problems make sure it's connected directly to the computer on a usb 3.0 port so it has enough power all right now that you have the sd card flash with raspberry pi os go ahead and plug it into your raspberry pi and then we will power it up and once it comes up and it boots up all the way we'll be able to ssh into the pi itself and start making changes to flash the eeprom one thing i've noticed well is make sure that if you're going to be connecting raspberry pi and you want to do you want to be able to ssh into it make sure you connect it over ethernet if you do use your raspberry pi with home assistant over wi-fi we can configure that all later but for right now make sure using ethernet it will simplify the process a bunch all right so after about 10 minutes the raspberry pi should finish loading up the operating system and be ready to be sshed into now i had assumed that it would continue using the same ip address that i had before when it was just running home assistant but it looks like it pulled a different one probably because the operating system changed so make sure you use your router or whatever gives out dhcp leases on your network and use it to find the proper ip address of the raspberry pi in this case it was.128 on my network so i won't go over how to find the ip address using your router just google that that should be pretty simple once you have that one you'll need to use an ssh application like putty i like to use one called termis because it's kind of cross platform it's the same interface on ios android and windows it's a free download you can find links below once the pi boots up we can ssh into it and then we'll be able to start the next step all right now that the pi is booted up and we know its ip address one of the first things you want to do is make sure to ping it so you know you've got the correct ip address so in this case mine is 192.168.1.128 then we'll flip over to your ssh application of choice again i'm using terminus and you want to put in the give it a name put in the ip address and then the username and password is just the default which is the username is pi the password is raspberry once we do that we'll connect in the first time you connect you'll get a a warning about the keys just go ahead and accept that now we are logged in to the new pi again this is just the raspberry pi os running on the pi itself so the first thing we need to do is go ahead and enable ssh for good so we want to run sudo raspi dash config that'll bring up the raspberry pi raspberry pi software configuration tool go down to the interface options which is option three ssh and enable ssh that's it now if we have to reboot the pi we can get back into it the ssh since we don't have um we don't have a monitor connected all right so we'll go ahead and exit that and the first thing we're going to do is we're going to we're going to go ahead and create a firmware update file all right so let's go ahead and create a new file so sudo nano so we can go to the etc folder default and rpi dash e-e-p-r-o-m-update enter or it'll edit the file that's already there so what we want to do is we want to change this firmware release status from critical to stable so go ahead and remove the word critical and change it to stable then control x select yes to save the buffer and enter to write the file sudo ape apt update enter this is going to go ahead and update the pi and then we'll do a full upgrade after this all right so now we'll run sudo at full upgrade and yes so we want to select no because we don't want to overwrite the file that we just modified the beginning so we can hit enter all right now we'll go ahead and do a reboot sudo sudo reboot and it's of course going to kick us out of our ssh session so what we can do to monitor to make sure that when the pi comes back up again is you can just run that same ping command dash t and that will continue to run until you escape so we'll just let this run until we ping the device again then we'll go back in we'll resume the ssh session so now we're able to ping the pi so we'll go ahead and reconnect our ssh session and we're back in so now we want to run sudo rpi dash eeprom update it looks like our current our boot loader is in january 2021 so that's good it just needs to be after december 11th of 2020 so looks like we're up to date now we want to configure the raspberry pi to boot from the ssd as opposed to the sd card so we're going to go back into the raspberry pi configuration and then go down to the advanced options which is option six and then go to the bootloader version and we will want to do e1 which is the latest now it's going to ask here do you want to reset the rom to default so we're going to say don't know you want to use the latest one so hit no here all right not set to defaults okay so then under the advanced option let's go down let's go ahead and back go back down to advanced options go down to boot order a6 and allow usb boot okay so the usb device is now the default boot device so just like in windows now if you flash you plug in a bootable flash drive it's going to attempt to boot from that now instead of just using the onboard sd card so now we go down to the finish option all right so now that we're out of these raspberry pi config we can run a sudo shutdown dash h that'll halt the system and shut it down in approximately one minute so now you want to wait until the raspberry pi all the leds on the front of the pie go off so then you know it's shut down and safe to remove it and then move on to the next step now once everything's plugged in and powered up you can go to that same ip address colon 8123 to find the startup window for home assistant now you can use the dns entry of home assistant so go to your web browser type in home assistant colon 8123 i can't on mine because i have more than one home assistant running on my network and of course the first one booting will get that dns name so if you have trouble navigating to the home assistant colon 8123 then go ahead and put in the ip address that we used in the previous step so as you can see here it's going to give you this nice screen to let you know hey you've got everything's connected everything's configured we've booted off the ssd but now it's going to go ahead and unpack and set up home assistant it says it'll take up to 20 minutes it shouldn't take that long especially with the high speed solid state drive but this is a time you just have to wait until it finishes with the setup all right now the home assistant instance has started up now georg puts in his guide very specifically don't jump straight to the restore from a snapshot because there's some incompatibility issues here and you don't want to have to do this all over again so go ahead and set up your home assistant as just a test system you don't have to use your current username and password we're just going to set up the base home assistant and then install the google drive backup plugin so once we've done that we'll hit create account again this is not required at the moment because we are not going to actually use this instance we're going to restore it all right now that we have a functional version all right now that the raspberry pi is functional with a solid state drive let's go ahead and get our old instance restored onto this one so to do that we'll need to use this great add-on by steven beachen um this is an add-on for and you used to call hassio but now home assistant to both backup and restore from google drive he says here um all you have to do is just add the repository to your supervisor so we'll go to supervisor add-on store and then click the three dots go to repositories and we're going to add the repository here so we'll go into his grab this link and then paste it here to add repository hit add and it's going to add it in to our list of add-ons so it'll be here at the bottom so we can click google assistant drive backup and install it should take just a minute all right once it's installed we'll go ahead and start it and then open the web gui so you'll have to authenticate with google drive which i've already done on my other instance but we'll go ahead and do this anyway all right once i've entered my google information i'm going to go ahead and allow it to access these items and we'll so we'll copy this for safekeeping but then hit send credentials and it's going to go ahead and push that over to the system so in my instance it didn't work so i've already copied it to my clipboard and go back and i'm going to paste it here in this box and hit save all right and so since i am restoring this from an existing one i want to use the existing backup folder so i'm going to say use this folder it's going to find all of the ones in here and so as you see here now i can see all of my current snapshots and i keep four of them in google drive which consumes about seven gigs not too much so right here i took this one the snapshot right before i got started here so to restore this one to to my new home assistant instance i need to go to actions and upload so this is actually going to upload this to home assistant so you have an option you can down you can delete the existing snapshot which of course you don't want to do download it to the computer you're currently on or upload this to home assistant so we're going to select that option it says hey you want to make sure to upload the snapshot now it's going to place this into home assistant as one of its snapshots so then when it's finished we can restore to that snapshot so this will take a few minutes depending on the speed of your internet connection and you'll see up here it tells you what what progress it is downloading in all right now the snapshot's been uploaded to home assistant now it shows backed up so if i refresh this page refresh the page it's now showing it backed up so it's on the actual drive so now we can flip over to supervisor snapshots and right here we see the snapshot ready to go so we'll click on that snapshot and we want to go ahead and restore everything now obviously it's helpful that i had already updated myself to the latest version don't need all of these but i could probably get rid of a few of them but i'm gonna go ahead and restore everything so i don't forget something now this could take a while because these do have to unpack and upload so it's best just to leave this screen open and then wait until you can refresh the page and have it come back up in your instance so in my case i'm going to have a bunch of error messages because i don't have some of my usb devices connected right now but be able to see pretty quickly if this worked all right after waiting about 20 minutes and taking care of a couple of other items my home assistant instance did show up after a couple of refreshes now i need to log into it so this is um this is a restored image of my original instance but on a different ip address so i'll go ahead and log into the instance make sure everything looks good then i'll i will jump in to my router and change the ip address to the ip address of the old home assistant instance so that way things like my mqtt servers and stuff all work again then i'm going to shut it down and take it back downstairs and make sure it's ready to go so let's go ahead and log in and we'll go ahead and jump into lovelace interface of course i'm accessing it directly by its ip address i typically access mine either do through uh nabokasa or through my outside duck dns but i can't do that right now because it's pointing to the wrong ip address so you can either point your point your instance to the new ip address or in my case change the home assistant instance to the old ip address all right so i already i have ssh into my raspberry pi i've gone into my unifi network and changed the ip address to match the old one again this may not apply to you i'm gonna go ahead and restart the home assistant host by issuing the h-a-h-o reboot command and this should allow it to restart and then come back up with a proper ip address all right now after applying the new ip address and rebooting my loveless interface is coming up everything seems to be there the interface looks like i expected to so everything's done now i have to take it back downstairs plug it into the usb port on the ups and z-stick and we're off and running so i'm gonna go ahead and shut it down because i gotta move it downstairs but everything's complete as far as home assistant is concerned all right so there you go now you have a fully functional home assistant instance running on a solid-state drive on a raspberry pi 4. hopefully this will be a noticeable improvement for you going forward with your databases not corrupting like mine always seem to do with you not having to deal with sd cards that you have to replace periodically and hopefully just the system runs much faster i noticed that the boot up is much quicker now that's on the solid state drive and that initial initialization sequence was much much quicker so i definitely am seeing some speed improvements and i'll report back in the comments how it feels over the next few days hope you found this video helpful uh if you did please make sure to give it a thumbs up and if you haven't already subscribe to the channel uh trying to develop a community here uh so feel free to ask questions if you run into issues along the way um as soon as i can i'll try to respond to you i've been blown away with all the comments so far on my last few videos there's been a lot of questions on there and a lot of positive comments so if you did find this useful please make sure to subscribe to the channel for more content um i've got a lot of videos in the pipeline i just have to finish editing them that's difficult with a full-time job and kids and a family but if you have any suggestions for your videos going forward please make sure you leave them in the comments below or feel free to reach out on any of my social media accounts i try to be active on there i'm starting to get used to using twitter a second twitter and second instagram account so feel free to reach out on those platforms or like i said comment below and if you're interested interested into when i randomly release videos to ring the bell and that will notify you of any new videos that i release thank you again i hope you're all staying safe out there with covid and i will see you on the next video thanks a lot you
Info
Channel: This Smart House
Views: 13,970
Rating: undefined out of 5
Keywords: home asistant, home assistant, home assistant install, home assistant install on raspberry pi, home assistant raspberry pi 4, home assistant setup, home assistant setup guide, home assistant ssd, home automation, home automation 2021, home automation ideas diy, home automation ideas raspberry pi, home automation raspberry pi, raspberry pi, raspberry pi 4, smart home 2021, smart home hub, smart tech, solid state drive, ssd, raspberry pi 4 ssd boot
Id: ab8pst_3tL8
Channel Id: undefined
Length: 27min 52sec (1672 seconds)
Published: Mon Apr 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.