{"id":311,"date":"2021-03-26T16:39:32","date_gmt":"2021-03-26T16:39:32","guid":{"rendered":"https:\/\/andrejacobs.org\/?p=311"},"modified":"2022-04-11T20:24:23","modified_gmt":"2022-04-11T20:24:23","slug":"100-days-of-learning-day-18-setup-raspberry-pi-to-boot-of-a-ssd-via-usb-for-home-assistant","status":"publish","type":"post","link":"https:\/\/andrejacobs.org\/100-days-challenge\/100-days-of-learning-day-18-setup-raspberry-pi-to-boot-of-a-ssd-via-usb-for-home-assistant\/","title":{"rendered":"100 Days of Learning: Day 18 \u2013 Setup Raspberry Pi to boot of a SSD via USB for Home Assistant"},"content":{"rendered":"\n
Photo by Jainath Ponnala<\/a> on Unsplash<\/a><\/p>\n\n\n\n Here is my Log book<\/a><\/p>\n I am running Home Assistant<\/a> on a Raspberry Pi 3B that I am using as part of learning about home automation. At the moment the Raspberry Pi is running off a 64GB SD card and I want to swap it over to booting from an external SSD.<\/p>\n Home Assistant is known to either fill up the SD card or the SD card gets corrupted. I believe this is a general Raspberry Pi running 24\/7 issue.<\/p>\n @ThePiHut confirmed<\/a> that the SSD to USB 3.0 cable will work fine on a Raspberry Pi 3 using only USB 2.0.<\/p>\n Logged into the dashboard and applied Updates to the OS and Home Assistant Core.<\/p>\n <\/p>\n After reading a couple of forum posts<\/a> it seems the best way for me to migrate from the SD card over to the new SSD would be to backup and restore. Meaning I will deploy a fresh copy of Home Assistant onto the SSD using balenaEtcher<\/a> boot it up and then try to restore from a snapshot.<\/p>\n Go to Supervisor \u2192 Snapshots.<\/p>\n Create a Full snapshot. I also gave it a descriptive name.<\/p>\n <\/p>\n Once the snapshot is complete, ensure you download it locally and also back this up somewhere safe.<\/p>\n <\/p>\n It appears that the snapshots are stored at Next I need to shut down the Rasperry Pi so that I can connect the SSD etc. Go to Supervisor \u2192 System \u2192 Host \u2192 Shutdown Host.<\/p>\n I want to boot the Raspberry Pi 3B completely from the SSD that is connected to USB and not require the SD card.<\/p>\n Just as before when I originally setup Home Assistant<\/a>.<\/p>\n I followed the official guide<\/a> for installing Home Assistant and downloaded the \u201cRaspberry Pi 3 Model B and B+ 64-bit\u201d image. The official guide has changed a bit and now lets you "Flash from URL". Instead I prefer to download the image locally first and then flash.<\/p>\n I used balenaEtcher<\/a> to install the image \u201chassos_rpi3-64-5.12.img.xz<\/a>\u201d to the 240GB SSD.<\/p>\n <\/p>\n Next I need to enable USB host boot mode<\/a> on the Raspberry Pi 3B. Unfortunately I don’t have a SD card currently with Raspberry Pi OS installed so I downloaded the latest Raspberry Pi OS Lite and flashed it to a SD card (again using balenaEtcher. Also note I used a different SD and not the working Home Assistant one).<\/p>\n Ejected the SD and reinserted it into my Mac.<\/p>\n Edited the Added a file called Inserted the SD card into the Raspberry Pi and booted it. I waited a minute or so and then used nmap to find the IP address. Note: Normally "raspberrypi.local" can just be found on the network.<\/p>\n SSH into it to verify that the USB host boot mode has been enabled.<\/p>\n 3020000a is the correct value.<\/p>\n Next I shutdown the Raspberry Pi (sudo shutdown -h now) and removed the program_usb_boot_mode line from config.txt file just incase I use this SD card in another Pi I did not want to write this one time programming bit to.<\/p>\n I attached the SSD via USB to the Raspberry Pi 3B and turned it on. Waited a few minutes.<\/p>\n Opened http:\/\/homeassistant.local:8123\/<\/a> in the browser.<\/p>\n <\/p>\n Voila!<\/strong> Booted the Raspberry Pi from an SSD attached via USB. Amazing!<\/p>\n I made the mistake of not seeing the link to restore from a snapshot on the very first onboarding screen. So I proceeded to add a username and password. Turns out that there is no easy way to restart the onboarding process and you have to delete the configs directory or just continue until the onboarding is finished.<\/p>\n Upload the snapshot by going to Supervisor \u2192 Snapshots \u2192 3 dot menu (top right) \u2192 Upload snapshot.<\/p>\n <\/p>\n Confirm that you are happy to wipe the system and then the Raspberry Pi will be rebooted.<\/p>\n After a few minutes I was able to login and the system is running just as it was when it was still on the SD card.<\/p>\n <\/p>\n Since the system is back up and running, now is a good time to take another full snapshot and back it up locally.<\/p>\n Next actions?<\/strong><\/p>\n Alex Ellis<\/a> released a new workshop on how to setup netbooting<\/a>. Once I get a bit of time to setup my Raspberry Pi 4 cluster then I would love to learn more about this.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":" Photo by Jainath Ponnala on Unsplash […]<\/p>\n\n
Hardware used<\/h2>\n
\n
Updating Home Assistant<\/h2>\n
Backing up Home Assistant<\/h2>\n
\/backup<\/code> on Home Assistant OS.<\/p>\n
Setting up an external SSD<\/h2>\n
config.txt<\/code> file on the SD card. I ran into some permission problem, just ejected and reinserted and it wrote to the file no issues. SD cards and computers are weird.<\/p>\n
program_usb_boot_mode=1\n<\/code><\/pre>\n
ssh<\/code> and
ssh.txt<\/code> to the SD card to enable SSH<\/a> since I will be running this Pi headless. (You only need a file named
ssh<\/code> but I wanted to get this right first time)<\/p>\n
$ nmap -sn 192.168.1.0\/24\n<\/code><\/pre>\n
$ ssh pi@raspberrypi.local\nPassword is just: raspberry\n\npi@raspberrypi:~ $ vcgencmd otp_dump | grep 17:\n17:3020000a\n<\/code><\/pre>\n
Moment of Truth<\/h3>\n
$ ping homeassistant.local\nPING homeassistant.local (192.168.1.69): 56 data bytes\n64 bytes from 192.168.1.69: icmp_seq=0 ttl=64 time=5.899 ms\n<\/code><\/pre>\n
Restore from snapshot<\/h2>\n
\n
Netbooting multiple Raspberry Pis<\/h2>\n