@ark, thank you for posting the patch. This is pretty much what I did, with a small difference: Instead of making the rootfs writeable, I created an overlay partition to prevent accidentally messing up the middleware.
Create a target for your overlay in a writeable dataset of your choice (e.g. /mnt/tank/overlay/). I use the original path for clarity:
#mkdir -p /mnt/tank/overlay/usr/lib/python3/dist-packages/middlewared/utils/disks_
Copy the middleware file you want to alter to the folder you just created:
#cp /usr/lib/python3/dist-packages/middlewared/utils/disks_/disk_class.py /mnt/tank/overlay/usr/lib/python3/dist-packages/middlewared/utils/disks_
Mount bind it temporarily (until the next restart) to “replace” your write-protected orginal file on your rootfs:
#mount --bind /mnt/tank/overlay/usr/lib/python3/dist-packages/middlewared/utils/disks_/disk_class.py /usr/lib/python3/dist-packages/middlewared/utils/disks_/disk_class.py
Make your edits to the file in your overlay directory (e.g. apply ark’s patch from the post above). Don’t forget this step.
Then restart the middleware to test:
#service middlewared restart
If all is OK, you can mount bind it automatically before the middleware starts by creating an init script under System->Advanced Settings->Init/Shutdown Script. This makes the edits permanent:
Description: disk_class.py overlay
Type: Command
Command: mount --bind /mnt/tank/overlay/usr/lib/python3/dist-packages/middlewared/utils/disks_/disk_class.py /usr/lib/python3/dist-packages/middlewared/utils/disks_/disk_class.py
When: Post Init
Enabled: checked
Timout: 10 (default)
This procedure is a little less dangerous compared to making the whole middleware writeable … and shouldn’t trigger support if you ever need to contact them (but of course, you should disable the overlay on init before making a support request to exclude the possibility of this being a problem).
However, you need to make sure you disable the init script before you update the system or you risk temporarily bricking your middleware. After an update, carefully examine if the file that is to be overlay changed. For example, disk_class.py changed between 25.10-RC1 and 25.10.0.1, so I had to copy the original file to my overlay directory and merge my previous changes to the new file before I could mount bind it again.