Gentoo Archives: gentoo-embedded

From: Francisco Ares <frares@×××××.com>
To: gentoo-embedded@l.g.o
Subject: Re: [gentoo-embedded] planning a flash DOM x86 embedded system
Date: Tue, 22 Oct 2013 16:51:06
Message-Id: CAHH9eM4T17-3zky-8fOR=exhoCtDhs2_7HP4irN0E0zSVuGwhA@mail.gmail.com
In Reply to: Re: [gentoo-embedded] planning a flash DOM x86 embedded system by Francisco Ares
1 Found it and gonna try:
2
3 https://grangerx.wordpress.com/2010/12/31/using-fuse-unionfs-with-centos-5-5-i686/
4
5
6 2013/10/22 Francisco Ares <frares@×××××.com>
7
8 > Thanks for the tip, Gareth;
9 >
10 > As a matter of fact, the unionfs in "/var" is not being mounted - as long
11 > as "/etc" also.
12 >
13 > Finally I got a verbose boot, and it is possible to read, as an error
14 > message:
15 >
16 > !! unable to mount none for /var
17 >
18 > in my "/etc/fstab", these are the related entries:
19 >
20 >
21 >
22 > /dev/sda2 / squashfs
23 > noatime,ro 0 1
24 > /dev/sda3 /.var.rw ext4
25 > noatime,defaults 0 2
26 > none /var unionfs
27 > nonempty,cow,umask=022,dirs=/.var.rw/=rw:/.var.ro/=ro 0 0
28 >
29 > Now I'm trying to find out on the manuals how to better tell the mount
30 > program there is no device to be mounted for "/var" .
31 >
32 > Thanks
33 > Francisco
34 >
35 >
36 >
37 > 2013/10/20 Gareth McClean <disneysw@×××××××.com>
38 >
39 >> ** **
40 >>
41 >> Check your /etc/mtab on the failing system to see how the kernel believes
42 >> the root partition has been mounted.****
43 >>
44 >> ** **
45 >>
46 >> I ended up including a fix-up in at the end of my init script to ensure
47 >> /etc/mtab correctly reflected my aufs root file system****
48 >>
49 >> ** **
50 >>
51 >> # Insert our new root into the mtab****
52 >>
53 >> sed -i '1i none / aufs dirs=/rw=rw:/ro=ro' ${NEW_ROOT}/etc/mtab****
54 >>
55 >> ** **
56 >>
57 >> this is performed just before performing the “switch_root” process.****
58 >>
59 >> ** **
60 >>
61 >> ** **
62 >>
63 >> ** **
64 >>
65 >> Also are you sure "/etc/initramfs.mounts" is actually being processed? **
66 >> **
67 >>
68 >> ** **
69 >>
70 >> If you are passing the “aufs” option into the init script using grub then
71 >> the code to process "/etc/initramfs.mounts" is never called.****
72 >>
73 >> ** **
74 >>
75 >> It’s been a few years since I set this up but like you I use genkernel to
76 >> create the initramfs (yes I’m lazy). However I replace the default
77 >> genkernel init script with a slightly modified version using the
78 >> ‘--linuxrc’ option. This replacement script includes my additional aufs
79 >> mounts and manages a few additional functions such as performing software
80 >> updates which for obvious reasons can’t take place on a fully running
81 >> system. ****
82 >>
83 >> ** **
84 >>
85 >> I use the ‘loop’, ‘looptype’, ‘ramdisk’ and ‘aufs’ init options which
86 >> are passed in via the grub boot manager. These options are normally used
87 >> for live CD builds to overlay a small ram disc on top of the CD using aufs. In
88 >> essence my change simply maps another physical partition over the top to
89 >> allow for permanent data storage.****
90 >>
91 >> ** **
92 >>
93 >> Gareth.****
94 >>
95 >> ** **
96 >>
97 >> ** **
98 >>
99 >> ** **
100 >>
101 >> *From:* Francisco Ares [mailto:frares@×××××.com]
102 >> *Sent:* 18 October 2013 18:16
103 >> *To:* gentoo-embedded@l.g.o
104 >> *Subject:* Re: [gentoo-embedded] planning a flash DOM x86 embedded system
105 >> ****
106 >>
107 >> ** **
108 >>
109 >> Thanks, Gareth.****
110 >>
111 >> But it is very interesting that with no special customizations, I am
112 >> almost able to have a fully functional system.****
113 >>
114 >> That new thing about having to use a initramfs when the root filesystem
115 >> and the /usr directory are not present in the same physical partition, it
116 >> turns out that it helps on having the "genkernel" generated initramfs do
117 >> the job of mounting different arrangements for partitions, directories and
118 >> unionfs mounts. That is because of the file "/etc/initramfs.mounts" where
119 >> the specified mount entries, are extracted from the "/etc/fstab" and
120 >> mounted before the initram gives way to the real root environment.****
121 >>
122 >> For instance, in this system, for now, there is the directory structure
123 >> bellow:****
124 >>
125 >> /.var.rw - here a r/w ext4 partition is to be mounted;****
126 >>
127 >> /.var.ro - here there are all files and directories expected to be on a
128 >> usual /var;****
129 >>
130 >> /var - here a unionfs mount is to join the ones above****
131 >>
132 >> The part from fstab for this is ("/.var.ro" is present on the squashfs
133 >> root file system):****
134 >>
135 >> /dev/sda2 / squashfs
136 >> noatime,ro 0 1
137 >> /dev/sda3 /.var.rw ext4
138 >> noatime,defaults 0 2
139 >> none /var unionfs
140 >> nonempty,cow,umask=022,dirs=/.var.rw/=rw:/.var.ro/=ro 0 0****
141 >>
142 >> I said it is not yet fully functional because it seems there is something
143 >> wrong with permissions, because it ends up with a unknown user prompt from
144 >> which I could list the root directories (something similar is being made to
145 >> "/etc"):
146 >>
147 >> total 9,0K
148 >> drwxr-xr-x 23 root root 385 Out 18 14:18 ./
149 >> drwxr-xr-x 4 root root 4,0K Set 24 09:46 ../
150 >> drwxr-xr-x 47 root root 2,6K Out 17 16:03 .etc.ro/
151 >> drwxr-xr-x 2 root root 40 Out 18 15:09 .etc.rw/
152 >> drwxr-xr-x 11 root root 262 Out 17 16:03 .var.ro/
153 >> drwxr-xr-x 6 root root 4,0K Out 18 14:33 .var.rw/
154 >> drwxr-xr-x 2 root root 1,4K Out 7 14:46 bin/
155 >> drwxr-xr-x 4 root root 1,0K Out 18 14:15 boot/
156 >> d????????? 3 root root 2,3K Ago 1 00:17 dev/
157 >> drwxr-xr-x 1 root root 2,6K Out 17 16:03 etc/
158 >> drwxr-xr-x 3 root root 54 Ago 22 07:55 home/
159 >> lrwxrwxrwx 1 root root 5 Out 7 14:05 lib -> lib64/
160 >> drwxr-xr-x 12 root root 3,2K Out 17 08:51 lib64/
161 >> drwxr-xr-x 2 root root 28 Ago 1 00:16 media/
162 >> drwxr-xr-x 2 root root 28 Ago 1 00:16 opt/
163 >> drwxr-xr-x 2 root root 3 Jul 31 22:22 proc/
164 >> drwxr-xr-x 2 root root 136 Out 18 14:18 root/
165 >> drwxr-xr-x 5 root root 120 Ago 30 08:59 run/
166 >> drwxr-xr-x 2 root root 2,9K Out 17 08:51 sbin/
167 >> drwxr-xr-x 2 root root 28 Ago 1 00:16 sys/
168 >> drwxrwxrwt 2 root root 3 Out 18 14:18 tmp/
169 >> drwxr-xr-x 13 root root 267 Out 17 11:18 usr/
170 >> d????????? 1 root root 262 Out 17 16:03 var/****
171 >>
172 >> Any hints or suggestions? I will post this to the "gentoo-user" list,
173 >> also, I guess it is an interesting thing that might be called a cool side
174 >> effect of the recent issues.****
175 >>
176 >> Thanks
177 >> Francisco****
178 >>
179 >> ** **
180 >>
181 >> ** **
182 >>
183 >> 2013/10/17 Gareth McClean <disneysw@×××××××.com>****
184 >>
185 >> ****
186 >>
187 >> I do this using a slightly modified init script, aufs3 and a squashfs.***
188 >> *
189 >>
190 >> ****
191 >>
192 >> Basically the system setups a tmpfs as a RW overlay on top of the
193 >> squashfs. Then for permanent storage there is a physical Ext4 partition
194 >> overlaid again on top of the /home directory. ****
195 >>
196 >> ****
197 >>
198 >> Symbolic links are then used for any configuration files (such as network
199 >> configuration) that require persistent storage. These links obviously
200 >> reference locations within the /home directory that is stored on an Ext4
201 >> physical partition. ****
202 >>
203 >> ****
204 >>
205 >> My init script is slightly more complicated than this since it caters for
206 >> both live (squash plus aufs) and development (normal disc access) modes but
207 >> basically it boils down to:****
208 >>
209 >> ****
210 >>
211 >> ****
212 >>
213 >> mount -t aufs aufs "${NEW_ROOT}" -o dirs=/rw=rw:/ro=rr****
214 >>
215 >> ****
216 >>
217 >> # Mount RW_PERM****
218 >>
219 >> echo "Mounting RW"****
220 >>
221 >> mkdir -p /rw-perm****
222 >>
223 >> mount "UUID=${RW_PERM_UUID}" /rw-perm****
224 >>
225 >> mount -o bind /ro/home "${NEW_ROOT}/home"****
226 >>
227 >> mount -t aufs aufs "${NEW_ROOT}/home" -o
228 >> dirs=/rw-perm=rw:/ro/home=rr****
229 >>
230 >> ****
231 >>
232 >> where ****
233 >>
234 >> ro = squashfs****
235 >>
236 >> rw = tmpfs****
237 >>
238 >> rw-perm = physical Ext4 partition****
239 >>
240 >> ****
241 >>
242 >> Note you need the “mount -o bind" command to allow an overlay on top of
243 >> an overlay with aufs3 otherwise you will get an error message.****
244 >>
245 >> ****
246 >>
247 >> BTW, Unless you have a good reason for doing this I would not recommend
248 >> doing this since you have a physical hard drive. The reason I still do this
249 >> is mainly for backward compatibility. Of course it is nice to have the
250 >> ability to run our system from a liveUSB stick and it minimises software
251 >> download size when doing updates but debugging the init script is a very
252 >> time consuming process……****
253 >>
254 >> ****
255 >>
256 >> ****
257 >>
258 >> ****
259 >>
260 >> ****
261 >>
262 >> *From:* Francisco Ares [mailto:frares@×××××.com]
263 >> *Sent:* 16 October 2013 13:49
264 >> *To:* gentoo-embedded@l.g.o
265 >> *Subject:* [gentoo-embedded] planning a flash DOM x86 embedded system****
266 >>
267 >> ****
268 >>
269 >> Hi.****
270 >>
271 >> I am planning to build a system to be deployed in a SATA flash disk, and
272 >> most of the file system will be read-only. There will be a tempfs on /temp
273 >> and a read-write partition for /var (perhaps a unionfs with the static part
274 >> of /var and that read-write partition)****
275 >>
276 >> Is there any resources on how to do this using Gentoo?****
277 >>
278 >> There is already a development system with everything working as expected
279 >> on the final system. But when I put it to a squashfs, the system boots with
280 >> several errors, like when trying to write to /etc and /var.****
281 >>
282 >> Looking on the new issue regarding /usr and / being on a different
283 >> partitions, I have found the file in /etc/initramfs.mounts. I have added
284 >> the needed fstab entries to be mounted before the system switches to the
285 >> real-root, (as the comments on top of this file claims) but there are
286 >> still errors during boot.****
287 >>
288 >> ****
289 >>
290 >> Thanks
291 >> Francisco****
292 >>
293 >> ** **
294 >>
295 >
296 >