Hi.

I am trying to build an embedded system to be deployed in a SATA flash disk, and most of the file system will be read-only.

There will be a tempfs on /temp and a read-write partition for /var (in fact, a unionfs with the static part of /var and that read-write partition) and the rest of the root tree will (has to) be read-only.

There is already a development system with everything working as expected on the final system.

Adjusting a few files, when I try to simply put it to a squashfs, the system boots with several errors, when trying to write to "/etc" and "/var" (this last one looks obvious, but there are some init process trying to create temporary files on "/etc").

But even so, I got a prompt, this because one of these adjusted files is "/etc/inittab", where I set up "agetty" to auto-login a user. The system claims that it does not know who is this user (permissions problem, probably).

Now, looking on that new issue regarding "/usr" and "/" being on a different partitions, I have found the file in "/etc/initramfs.mounts" , that claims to automagicaly mount specified fstab entries before initramfs gives way to real-root environment.

So in this system, for now, there is the directory structure bellow:

/.var.rw  - here a r/w ext4 partition is to be mounted;
/.var.ro  - here there are all files and directories expected to be on a usual /var;
/var - here a unionfs mount is to join the ones above

The part from fstab for this is ("/.var.ro" is present on the squashfs root file system):

/dev/sda2               /                       squashfs        noatime,ro                              0 1
/dev/sda3               /.var.rw                ext4            noatime,defaults                        0 2
none                    /var                    unionfs         nonempty,cow,umask=022,dirs=/.var.rw/=rw:/.var.ro/=ro   0 0

I said it is not yet fully functional because it seems there is something wrong with permissions, because it ends up with a unknown user prompt from which I could list the root directories (something similar is being made to "/etc", so the same results):

total 9,0K
drwxr-xr-x 23 root root  385 Out 18 14:18 ./
drwxr-xr-x  4 root root 4,0K Set 24 09:46 ../
drwxr-xr-x 47 root root 2,6K Out 17 16:03 .etc.ro/
drwxr-xr-x  2 root root   40 Out 18 15:09 .etc.rw/
drwxr-xr-x 11 root root  262 Out 17 16:03 .var.ro/
drwxr-xr-x  6 root root 4,0K Out 18 14:33 .var.rw/
drwxr-xr-x  2 root root 1,4K Out  7 14:46 bin/
drwxr-xr-x  4 root root 1,0K Out 18 14:15 boot/
d?????????  3 root root 2,3K Ago  1 00:17 dev/
drwxr-xr-x  1 root root 2,6K Out 17 16:03 etc/
drwxr-xr-x  3 root root   54 Ago 22 07:55 home/
lrwxrwxrwx  1 root root    5 Out  7 14:05 lib -> lib64/
drwxr-xr-x 12 root root 3,2K Out 17 08:51 lib64/
drwxr-xr-x  2 root root   28 Ago  1 00:16 media/
drwxr-xr-x  2 root root   28 Ago  1 00:16 opt/
drwxr-xr-x  2 root root    3 Jul 31 22:22 proc/
drwxr-xr-x  2 root root  136 Out 18 14:18 root/
drwxr-xr-x  5 root root  120 Ago 30 08:59 run/
drwxr-xr-x  2 root root 2,9K Out 17 08:51 sbin/
drwxr-xr-x  2 root root   28 Ago  1 00:16 sys/
drwxrwxrwt  2 root root    3 Out 18 14:18 tmp/
drwxr-xr-x 13 root root  267 Out 17 11:18 usr/
d?????????  1 root root  262 Out 17 16:03 var/

Any hints?

Thanks
Francisco