1 |
I do this using a slightly modified init script, aufs3 and a squashfs. |
2 |
|
3 |
|
4 |
|
5 |
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. |
6 |
|
7 |
|
8 |
|
9 |
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. |
10 |
|
11 |
|
12 |
|
13 |
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: |
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
mount -t aufs aufs "${NEW_ROOT}" -o dirs=/rw=rw:/ro=rr |
20 |
|
21 |
|
22 |
|
23 |
# Mount RW_PERM |
24 |
|
25 |
echo "Mounting RW" |
26 |
|
27 |
mkdir -p /rw-perm |
28 |
|
29 |
mount "UUID=${RW_PERM_UUID}" /rw-perm |
30 |
|
31 |
mount -o bind /ro/home "${NEW_ROOT}/home" |
32 |
|
33 |
mount -t aufs aufs "${NEW_ROOT}/home" -o dirs=/rw-perm=rw:/ro/home=rr |
34 |
|
35 |
|
36 |
|
37 |
where |
38 |
|
39 |
ro = squashfs |
40 |
|
41 |
rw = tmpfs |
42 |
|
43 |
rw-perm = physical Ext4 partition |
44 |
|
45 |
|
46 |
|
47 |
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. |
48 |
|
49 |
|
50 |
|
51 |
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…… |
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
From: Francisco Ares [mailto:frares@×××××.com] |
62 |
Sent: 16 October 2013 13:49 |
63 |
To: gentoo-embedded@l.g.o |
64 |
Subject: [gentoo-embedded] planning a flash DOM x86 embedded system |
65 |
|
66 |
|
67 |
|
68 |
Hi. |
69 |
|
70 |
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) |
71 |
|
72 |
Is there any resources on how to do this using Gentoo? |
73 |
|
74 |
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. |
75 |
|
76 |
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. |
77 |
|
78 |
|
79 |
|
80 |
Thanks |
81 |
Francisco |