I need to update a raw UBI partition with a new UBIFS image from Linux userspace with superuser rights, however I'm getting
EBUSY (Device or resource busy) error whenever I'm trying to open my corresponding
/dev/ubiX_Y for writing, even if the current filesystem present on it is mounted as read-only. I suspect that an usual block partition with e.g. an ext4 filesystem could be opened for writing when it's mounted as read-only, seeing that utilities like zerofree and ext4magic work that way. That doesn't seem to be the case with UBI partitions.
Theoretically I could either terminate the processes using the partition or attach to them and forcibly close all files on it before unmounting the partition completely, but seems I can do neither to the busybox
init process which keeps constantly holding its
/etc/inittab open. And yes, the partition in question is a root
/ mounted partition.
I also could implement a kernel module which would do the dirty work, but I'd like to retain as much binary forward compatibility for my update utility and basically keep it as much kernel version agnostic as I can, thus solving it in such a manner is highly undesirable. Is there any other way I can do this?