Module for kernel

I have application that works with the backup system. To use this application, if you need to make a backup from the btrfs partition, you need a driver, it is connected by the module for the system kernel.
How should this be set in snapcraft.conf? If anyone knows a similar example, give a link please.
This driver should be compiled.

I have *.ko
This is the driver that I need to link to the kernel for the job.
How do I do this in a snap and where do I put this driver?
Are there any examples of how this works?

The only way to get custom kernel modules into a snap system is via a gadget snap which is specific to the computer that you’re targeting (e.g. raspberry pi 2 has a gadget snap with the rpi drivers). Application snaps cannot ship their own drivers outside of this because there is no way to ensure they’re compatible with the kernels of every snap-supporting system.

Could you describe a little what you had in mind? So that I understand what to look for further information that will help me solve this.

I would like to clarify that the snap package that will carry the module for the kernel should have access to the entire system. This application should serve for the backup system.
I understand correctly that I need to take custom kernel for the system together with the module and application in the snap package?

there is no system like dkms in snaps, so how would you make sure your module is even remotely matching the kernel symbols ? what would happen if the host system upgrades the kernel ?

the only way to make this work would be to actually have the host ship the module in its kernel package … either by having the deb have this module enabled (which also makes sure that the module is sane and secure since it would have to go through code and security reviews by kernel and security teams of the distro) or if you want to use your snap on an Ubuntu Core system by creating your own kernel snap with the module included for your specific Core image.

Just shipping a random (and very likely incompatible with most kernels) module in a snap package will not work … while there is a module-control interface that would allow you to do this and to use insmod to load said module, this interface falls under the same restrictions as snapd-control and your snap would not be allowed in the public store.

(regarding snapd-control, see the discussion below)

Tell me, but will it be considered the possibility of adding to the snapd some functionality that will allow to work with the development modules or connect them?

The module is needed for the application to work with the filesystem btrfs.
Without this driver it is impossible to work.
Therefore, the proper operation of the snap package, the module, and the system itself is very important.

Can anyone have an example or description of how to prepare such a module for work?
Examples of settings have not been found anywhere.

What is the module you need? btrfs should be part of the Ubuntu Core reference kernels… Are you talking about a separate upstream module that is missing from the kernel or are you talking about an out-of-tree module that needs to be compiled for your software to work? If the latter, I don’t have much more to say on the subject beyond what @ogra said except to say that snapd intentionally hasn’t implemented dkms-style hooks generally since this could introduce instability or impact the security stance of the system (since the module would grant device ownership to the snap providing it). That isn’t to say that snapd won’t be extended to carefully extend this in the future, but I’m not aware of any roadmap items for this.

All that said, you originally had this to say: “I have application that works with the backup system. To use this application, if you need to make a backup from the btrfs partition, you need a driver, it is connected by the module for the system kernel.” Ubuntu Core systems use ext4 and I’m not aware of a means to change that via the gadget and kernel snaps (perhaps there is; someone can correct me). As such, you don’t need this module. On classic distros, you can simply probe for it and then alert the user to install the module outside of the snap for your software to work.