Gentoo Archives: gentoo-embedded

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

Replies

Subject Author
Re: [gentoo-embedded] SOLVED planning a flash DOM x86 embedded system wireless <wireless@×××××××××××.com>