Configure shm size on an oci container (Frigate)

Hi! I’ve been playing with setting up a Frigate container and everything seems to work fine, but I get the following warning on the logs:

The current SHM size of 64.0MB is too small, recommend increasing it to at least 114MB.

On the install instructions, the following Docker option is used:

  --shm-size=64m

So: is there anyway to configure the shm size on Incus containers?

Thanks!

OK, I’ve been doing some more tests. If I access the container shell with:
$ incus shell frigate-container
And then remount the filesystem with something like this:
$ mount -o remount,size=128M /dev/shm

I get what I need but, how can I persist that change? :thinking:

Am I missing something obvious @stgraber ?

Thanks!

@osch & @Janm84 I’ve read in other threats that you also run the frigate docker image as an incus container, so I was guessing if you see this same warning regarding the SHM size.

Thanks!

I believe this is a common issue you run into as soon as you have a few cameras configured.

The workaround I use is a bit tricky as you need to edit the main “config.json” file located at the instance root volume. To do this you need to mount the root volume in one cmd window and edit the file in a second cmd window. Alternative try the following, assume “frigate” is your instance name and your storage pool is located at default location “/var/lib/incus”:

incus start frigate && vi /var/lib/incus/storage-pools/default/containers/frigate/config.json

It tries to start frigate, mounts the root volume and vim opens the “config.json”. This holds a lock on the mount until you finish editing the file. Search for “/dev/shm” and update the size to your needs:

                {
                        "destination": "/dev/shm",
                        "type": "tmpfs",
                        "source": "shm",
                        "options": [
                                "nosuid",
                                "noexec",
                                "nodev",
                                "mode=1777",
                                "size=524288k"
                        ]
                },

I upped my to 512MB (as you can see, have enough of RAM) which is plenty properly 256MB or 128MB will do to. After changing the shm just save the file which will unmount the root volume. Now you can start frigate and will start with the configured amount of shared ram.

The change is persistent until you update / rebuild the instance. There might be a better way to do this. May be @stgraber can chime in and explain the proper way :wink:

Enjoy…

1 Like

I haven’t made it truly persistent, but I did automate it a bit by bind-mounting a script (resize-shm) containing “mount -o remount,size=256M /dev/shm” from the host into the /usr/local/sbin directory the container. And then I’ve got a separate script to rebuild the image (I needed to script it so that I could remove the built-in symlink for /etc/localtime and bind-mount my local timezone as well) and the last step of that script is just running “incus exec [container-name] resize-shm”