Ok do I had a little bit of time to try the unionfs module that wigout has kindly compiled. My goal is to create a writable squashfs filesystem. I also tried this last nite and writing my results here this morning so hopefully my memory is as good as I think it is. Still at the experimental stage but here's are my findings/result.
1) First I installed unionfs.ko module using insmod. Since I copy the module to the HDD I used the following command:
2) Now since my firmware uses yaffs I had to pick a directory that I know is read only to use to prove the concept. I decided to use the /usr/local/bin which I know is read only on the yaffs filesystems. So with that in mind I created two directory (/tmp/writable and /tmp/union); I believe /tmp is writable on squashfs firmware but even if it is not I could always use the /usr/local/etc which I am 100% is writable on any firmware. Anyhow after that I joined all those directories. So here's the commands I issued:
# insmod /tmp/hdd/volumes/HDD1/unionfs.ko
Ok so now I have /usr/local/bin/ and /tmp/writable/ joined to /tmp/union/
# mkdir /tmp/writable
# mkdir /tmp/union
# mount -t unionfs -o dirs=/tmp/writable=rw:/usr/local/bin=ro unionfs /tmp/union
3) Ok so now /tmp/union contains all the files/directories that are in /usr/local/bin/ and /tmp/writable. From this point on everything I do (create new file, edit files etc .....) is done in the /tmp/union but shows up in /tmp/writable ...... almost there but we still need the our friend the overmount the complete the task appropriately. So now we issue that command:
I can't believe this actually worked overmounting an union mount over itself!!! Man you got to love the flexibility of linux.
# mount --bind /tmp/union /usr/local/bin
So now we are done anything we can add/edit files on the /usr/local/bin/. Any changes we make is being reflected on the /tmp/writable which is unionized with /usr/local/bin/ on /tmp/union which is also overmounted on /usr/local/bin.
Now wrap all these command into a nice a script and you have something that call be called up from the /usr/local/etc/rcS file.
So you are probably wandering why not just create a directory in /tmp/union and overmount to /usr/local/bin and be done with it. Well for this to work properly you will first have to copy the whole content of /usr/local/bin to the /tmp/union chewing up some precious memory. Not so bad if there isn't much contents in the /usr/local/bin but what about a whole filesystem ????? .......... Next stop trying this on the whole root directory and making the whole squashfs firmware writable.
To return to the original condition just enter the umount command twice:
Again this is still experimental but it did worked fine for me. This experimentation would not have been possible without the compilation of the unionfs by wigout .... so thanks again.
# umount /tmp/union
# umount /tmp/union