Possible to move database to USB on HassOS/Hassio?

Everyone makes mistakes, even NASA but as @allan said, that’s dumb. It’s dangerous to devices and lazy engineering. Put a few blobs of conformal coating on it at least.

Though I suppose it’s easy enough to fix with a small amount of play-dough experience and some Sugru or (open source!) Ooogoo.

1 Like

I’m confused, it says only possible with resin os and not HassOs?

This is correct. Where’s the confusion?

If you have a NAS, you can configure the recorder to save to a database on that:

That is what I use

Because all Hassio images today are built on HassOS and not Resin anymore… So I wasn’t sure if you had managed to get it working on a HassOS build… In other words, I can’t move everything as I understand it…

I’ve just seen your post about configuring recorder to use a NAS. I would like to do this for my hassio setup. I’ve read through the recorder component and I’m still none the wiser as to exactly what the config should look like. Are you able to share yours as an example?

Mine looks like this:

recorder:
  db_url: mysql://homeassistant:[email protected]/homeassistant?charset=utf8
  exclude:
    domains:
      - input_select
      - automation
      - cover
      - camera
      - group
      - weather

The xxxxxxx is the password and homeassistant is the user.
At the bottom the documentationpage are examples of the URL under “Custom database engines”

My config is the second MySQL option:
mysql://user:password@SERVER_IP/DB_NAME?charset=utf8

As you can see I also excluded some domains, those are not recorded,

2 Likes

Just wondering - this won’t move the db to a USB stick will it? It’ll be on the SD card still within the homeassistant folder?

If you use the mysql recorder, there will be no database anywhere on disk

The question remains…
Can one move the database in Hassio to a USB drive connected to the Raspberry Pi?

7 Likes

Any news on this? I’m also looking to move my MariaDB databases to a USB drive connected to the Pi running HassOS

1 Like

Now I haven’t tried this or anything but I found this little tutorial that moves the home assistant log and db to a usb. They use symbolic links to link from the HA config directory to the usb drive and move the files to the drive. That makes sense to me, might have to give it a try when I have some free time. Eventually I’d like to move the log and db off the pi entirely and onto my server but that’s another can of worms.
https://www.cribbstechnologies.com/index.php/home-assistant/moving-home-assistant-logs/

2 Likes

So, did it work?

1 Like

I’ve gone the symlink route for my logs and also run my DB from a USB drive as well, but I’m not Hassio.

Thanks for the reply.

I worked out how to symlink DB and log to USB for hassio.

1 Like

Care to share?

I reconstructed the following from memory. Proceed carefully.

I’ve installed hass.io on raspbian buster. If you have a different installation please adapt accordingly.

Backup everything first (not outlined below)

ssh into raspbian (ssh [email protected] for me)
then su or use sudo in each command
follow these directions to setup the USB stick:
https://thepihut.com/blogs/raspberry-pi-tutorials/17699796-formatting-and-mounting-a-usb-drive-from-a-terminal-window
I created my mountpoint as /usr/share/hassio/share/usbstick via mkdir (so that hassio will see it as /share/usbstick). I wanted it outside /config, but available via the hassio samba addon in /share.
then add this line to /etc/fstab:
UUID=69788be1-6a02-4e8d-ad6c-5c7bd9a3c0f1 /usr/share/hassio/share/usbstick ext4 defaults,nofail 0 0
of course, put in your UUID or use a device designation you’re sure won’t change.
That’ll make sure your stick gets mounted on reboot if it is plugged-in.

Symlinks must be made within the docker container, so now ssh into hassio: (ssh [email protected] -p 222 for me per setup of hassio ssh addon).
hassio ha stop
chmod 775 /share/usbstick
cd /config
mv home-assistant_v2.db /share/usbstick
mv home-assistant.log /share/usbstick
ln -s /share/usbstick/home-assistant.log home-assistant.log
ln -s /share/usbstick/home-assistant_v2.db home-assistant_v2.db
hassio ha start

3 Likes

Thanks. So this can only be done through raspbian?

hi,

You can run on SSD on RPI 3B+ - I think for 3 you have to set that one time USB boot bit IF you don’t mind being on a release candidate - issue #440 is USB boot:

I installed release candidate 3.5 on an RPI 3B+ and it’s working for a few weeks now. Don’t upgrade to stable or you will lose ability to SSD boot though I hope it will soon be incorporated in a stable release.

Installation procedure is identical to SD - flash image to SSD and plug in your RPI (and be very patient). I have the feeling booting is slower than on SD card but once it is up you’ll be happy with the performance gain.

Jhh

I’ve moved on from usb 2 and sticks on 3B+ to usb 3 and nvme on 4B. Much faster.
See Rpi 4 installation