Run MySQL server locally with database on a NAS?

I have a 4 TB NAS that I’ve been using to connect my recorder integration to and save my SD card from unnecessary wear.

However, recently the NAS stopped booting – and I found out it was because it was actually storing the MySQL database in the NAS’s flash memory and not on the physical RAID disks (d’oh). Eventually Home Assistant filled up the NAS’s flash memory without actually using the disks.

I fixed the problem and it was okay for a day or so – until the NAS started killing the MySQL server for using too much memory. No matter how many times I restart the server, eventually it will eat a bunch of memory and I’d need to kill it again. This, of course, would break my recorder and history integrations.

I’m running Home Assistant OS on a separate Raspberry Pi 4, and it’s the only thing that actually uses the MySQL server. So I grabbed the MariaDB addon for Home Assistant OS with the goal of connecting to my NAS via NFS. That way the MySQL server is stored on the thing that’s actually using it, and the storage is in the place that has the storage to handle it.

…Except it doesn’t seem to work that way. Trying to mount the share within the Home Assistant container gives me a “permission denied” error. Doing it in developer mode doesn’t work because the system complains about not having a mount.nfs or mount.cifs file in /sbin.

According to here, I can execute a shell command as part of HASS startup… but won’t that be too late? By the time those commands get executed, the history/recorder integrations would have already failed or the MariaDB database would’ve failed to connect or something. Maybe I’m wrong here, but I feel like there should be a way to do this that I’m missing.

I see that there’s a WTH post about it, but I’m not sure if it’s something that actually got done or not. Any tips or ideas? I really don’t want to get another Raspberry Pi just to run a MySQL server…

1 Like