I do this using a slightly modified init script, aufs3 and a squashfs.
Basically the system setups a tmpfs as a RW overlay on top of the squashfs.
Then for permanent storage there is a physical Ext4 partition overlaid again on
top of the /home directory.
Symbolic links are then used for any configuration files (such as network
configuration) that require persistent storage. These links obviously reference
locations within the /home directory that is stored on an Ext4 physical
partition.
My init script is slightly more complicated than this since it caters for both
live (squash plus aufs) and development (normal disc access) modes but
basically it boils down to:
mount -t aufs aufs "${NEW_ROOT}" -o dirs=/rw=rw:/ro=rr
# Mount RW_PERM
echo "Mounting RW"
mkdir -p /rw-perm
mount "UUID=${RW_PERM_UUID}" /rw-perm
mount -o bind /ro/home "${NEW_ROOT}/home"
mount -t aufs aufs "${NEW_ROOT}/home" -o dirs=/rw-perm=rw:/ro/home=rr
where
ro = squashfs
rw = tmpfs
rw-perm = physical Ext4 partition
Note you need the “mount -o bind" command to allow an overlay on top of an
overlay with aufs3 otherwise you will get an error message.
BTW, Unless you have a good reason for doing this I would not recommend doing
this since you have a physical hard drive. The reason I still do this is mainly
for backward compatibility. Of course it is nice to have the ability to run our
system from a liveUSB stick and it minimises software download size when doing
updates but debugging the init script is a very time consuming process……
From: Francisco Ares [mailto:[email protected]]
Sent: 16 October 2013 13:49
To: [email protected]
Subject: [gentoo-embedded] planning a flash DOM x86 embedded system
Hi.
I am planning to build a 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 (perhaps a unionfs with the static part of /var
and that read-write partition)
Is there any resources on how to do this using Gentoo?
There is already a development system with everything working as expected on
the final system. But when I put it to a squashfs, the system boots with
several errors, like when trying to write to /etc and /var.
Looking on the new issue regarding /usr and / being on a different partitions,
I have found the file in /etc/initramfs.mounts. I have added the needed fstab
entries to be mounted before the system switches to the real-root, (as the
comments on top of this file claims) but there are still errors during boot.
Thanks
Francisco