Writing to userdata partition from a script in recovery

I’m preparing the Sailfish OS for Fairphone 2 and I have had serious problems in preparation of a zip package installable from recovery because of the AOSP recovery being different from the cwm/twrp normally used on ported Sailfish devices. Usually Sailfish is installed from a script called from recovery updated-script that uses tar to extract the Sailfish root to the userdata partition and preserve the android user data. Since AOSP recovery doesn’t have tar built-in I had to add busybox in to the zip and use it to extract the rootfs. However the problem that remains is the lack of permissions to write to userdata partition, I have tried to remount userdata as read-write and many other things but still haven’t managed to write to userdata partition. Does anyone with more experience with recovery systems have ideas how to fix this?

If I don’t soon find a solution to this problem I will have to find a way to prepare a complete userdata image with Sailfish OS but this would remove all android user data.

I know this was not your question, but just deliver Sailfish with an updated recovery. It will be better for the users in the long run. Nobody likes the stock recovery anyway. There is a way to get twrp running on the FP2 here in the forum.