[prev in list] [next in list] [prev in thread] [next in thread] 

List:       systemd-devel
Subject:    Re: [systemd-devel] elegant way to use a single mount unit file for multiple paths
From:       Jérémy ROSEN <jeremy.rosen () smile ! fr>
Date:       2020-01-27 7:45:03
Message-ID: CAFvCimVGS_ttWkXBYuyv7xZT-dmehfAkn1RNHuLv+i8KdQGhrA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


You can't use templates with .mount units because .mount units need to be
named exactly after their mount point.
That's probably not explicitly documented, but might be a good idea to add.

For your use-case, I would probably use a generator (man systemd.generator)
to solve that...
It might not solve your problem, since we don't know when exactly do the
mount themselves happen but it would work for the simple, mount at boot,
case

HtH
Jeremy

Le jeu. 23 janv. 2020 à 18:30, Marcel Partap <mpartap@gmx.net> a écrit :

> Salut,
> for our live debian USB stick distro for students (
> https://github.com/fsfw-dresden/usb-live-linux ), we want to minimize on
> flash writes by putting several paths into a tmpfs overlay. So there is a
> pre-overlay@.service with
> 
> > [Unit]
> > Description=Prepare writable overlay on %f
> > DefaultDependencies=no
> > RequiresMountsFor=/run
> > 
> > [Service]
> > Type=oneshot
> > ExecStart=/bin/mkdir -p '/run%f'
> > ExecStart=/bin/mount -t tmpfs -o noatime tmpfs '/run%f'
> > ExecStart=/bin/mkdir -p '/run%f/work' '/run%f/rw'
> 
> and f.e. a var-lib-apt-lists.mount with
> > [Unit]
> > Description=tmpfs overlay of %f
> > Conflicts=umount.target
> > Wants=pre-overlay@%p.service
> > After=pre-overlay@%p.service
> > 
> > [Mount]
> > What=overlay
> > Type=overlay
> > Where=%f
> > Options=lowerdir=%f,upperdir=/run%f/rw,workdir=/run%f/work
> > 
> > [Install]
> > WantedBy=local-fs.target
> 
> Currently, the file is just cloned for multiple paths, which is working
> but not very elegant. I tried changing it into an instanced unit file
> tmpfs-overlay@.mount, which did not work ("Unit type mount cannot be
> templated" in journal only, nothing from systemd-analyze verify or the
> systemd.mount man page).. Neither did calling the file
> tmpfs-overlay.mount.unit and symlinking to it as var-lib-apt-lists.mount,
> var-cache-apt.mount etc.
> 
> So what would be a more elegant way to not have multiple copies of the
> very same file?
> 
> Best Regards,
> #marcel
> _______________________________________________
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 


-- 
[image: SMILE]  <http://www.smile.eu/>

20 rue des Jardins
92600 Asnières-sur-Seine
*Jérémy ROSEN*
Architecte technique

[image: email] jeremy.rosen@smile.fr
[image: phone]  +33 6 88 25 87 42
[image: url] http://www.smile.eu

[image: Twitter] <https://twitter.com/GroupeSmile> [image: Facebook]
<https://www.facebook.com/smileopensource> [image: LinkedIn]
<https://www.linkedin.com/company/smile> [image: Github]
<https://github.com/Smile-SA>

[image: Découvrez l'univers Smile, rendez-vous sur smile.eu]
<https://www.smile.eu/fr/publications/livres-blancs/yocto?utm_source=signature&utm_medium=email&utm_campaign=signature>



[Attachment #5 (text/html)]

<div dir="ltr">You can&#39;t use templates with .mount units because .mount units \
need to be named exactly after their mount point.<div>That&#39;s probably not \
explicitly  documented, but might be a good idea to add.</div><div><br></div><div>For \
your use-case, I would probably use a generator (man systemd.generator) to solve \
that... </div><div>It might not solve your problem, since we don&#39;t know when \
exactly do the mount themselves happen but it would work for the simple, mount at \
boot, case</div><div><br></div><div>HtH</div><div>Jeremy</div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">Le  jeu. 23 janv. 2020 Ã   \
18:30, Marcel Partap &lt;<a href="mailto:mpartap@gmx.net">mpartap@gmx.net</a>&gt; a \
écrit  :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Salut,<br> for our \
live debian USB stick distro for students ( <a \
href="https://github.com/fsfw-dresden/usb-live-linux" rel="noreferrer" \
target="_blank">https://github.com/fsfw-dresden/usb-live-linux</a> ), we want to \
minimize on flash writes by putting several paths into a tmpfs overlay. So there is a \
pre-overlay@.service with<br> <br>
&gt; [Unit]<br>
&gt; Description=Prepare writable overlay on %f<br>
&gt; DefaultDependencies=no<br>
&gt; RequiresMountsFor=/run<br>
&gt;<br>
&gt; [Service]<br>
&gt; Type=oneshot<br>
&gt; ExecStart=/bin/mkdir -p &#39;/run%f&#39;<br>
&gt; ExecStart=/bin/mount -t tmpfs -o noatime tmpfs &#39;/run%f&#39;<br>
&gt; ExecStart=/bin/mkdir -p &#39;/run%f/work&#39; &#39;/run%f/rw&#39;<br>
<br>
and f.e. a var-lib-apt-lists.mount with<br>
&gt; [Unit]<br>
&gt; Description=tmpfs overlay of %f<br>
&gt; Conflicts=umount.target<br>
&gt; Wants=pre-overlay@%p.service<br>
&gt; After=pre-overlay@%p.service<br>
&gt;<br>
&gt; [Mount]<br>
&gt; What=overlay<br>
&gt; Type=overlay<br>
&gt; Where=%f<br>
&gt; Options=lowerdir=%f,upperdir=/run%f/rw,workdir=/run%f/work<br>
&gt;<br>
&gt; [Install]<br>
&gt; WantedBy=local-fs.target<br>
<br>
Currently, the file is just cloned for multiple paths, which is working but not very \
elegant. I tried changing it into an instanced unit file tmpfs-overlay@.mount, which \
did not work (&quot;Unit type mount cannot be templated&quot; in journal only, \
nothing from systemd-analyze verify or the systemd.mount man page).. Neither did \
calling the file tmpfs-overlay.mount.unit and symlinking to it as \
var-lib-apt-lists.mount, var-cache-apt.mount etc.<br> <br>
So what would be a more elegant way to not have multiple copies of the very same \
file?<br> <br>
Best Regards,<br>
#marcel<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" \
target="_blank">systemd-devel@lists.freedesktop.org</a><br> <a \
href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" \
target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br> \
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" \
class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><table border="0" \
style="border-collapse:collapse;border-spacing:0px;color:rgb(51,51,51);font-family:Raleway,regular;font-size:14px;padding:20px"><tbody><tr><td \
style="padding:0px 30px 0px \
0px;font-size:13px;color:rgb(255,128,84);text-align:center"><a \
href="http://www.smile.eu/" style="background-color:transparent;color:rgb(221,72,20)" \
target="_blank"><img \
src="http://ftp.smile.fr/client/Communication/signature/img/Logo-new.png" alt="SMILE" \
style="border: 0px; vertical-align: middle; max-width: 100%; height: auto;">  \
</a><br><br><p style="margin:0px 0px 10px">20 rue des Jardins<br>92600 \
Asnières-sur-Seine</p></td><td style="padding:0px 0px 0px 20px;border-left:1px solid \
rgb(59,127,254);font-size:13px;color:rgb(255,128,84)"><div \
style="font-size:14px"><b>Jérémy ROSEN</b></div><div \
style="color:rgb(59,127,254)">Architecte technique<br></div><br><div \
style="color:rgb(59,127,254)"><span style="white-space:nowrap"><img \
src="http://ftp.smile.fr/client/Communication/signature/img/mail.png" alt="email" \
width="12" height="10" style="border: 0px; vertical-align: middle; margin-right: \
5px;">  <a href="mailto:jeremy.rosen@smile.fr" \
style="background-color:transparent;color:rgb(59,127,254)" \
target="_blank">jeremy.rosen@smile.fr</a>  </span><br><span \
style="white-space:nowrap"><img \
src="http://ftp.smile.fr/client/Communication/signature/img/phone.png" alt="phone" \
width="10" height="10" style="border: 0px; vertical-align: middle; margin-right: \
5px;"></span>   +33 6 88 25 87 42  <br><span style="white-space:nowrap"><img \
src="http://ftp.smile.fr/client/Communication/signature/img/web.png" alt="url" \
width="12" height="12" style="border: 0px; vertical-align: middle; margin-right: \
5px;">  <a href="http://www.smile.eu/" \
style="background-color:transparent;color:rgb(59,127,254)" \
target="_blank">http://www.smile.eu</a></span></div><br><div><span><a \
href="https://twitter.com/GroupeSmile" \
style="background-color:transparent;color:rgb(221,72,20);margin-right:5px" \
target="_blank"><img \
src="http://ftp.smile.fr/client/Communication/signature/img/rs-twitter.png" \
alt="Twitter" style="border: 0px; vertical-align: middle; max-width: 100%; height: \
auto;"></a></span>  <span><a href="https://www.facebook.com/smileopensource" \
style="background-color:transparent;color:rgb(221,72,20);margin-right:5px" \
target="_blank"><img \
src="http://ftp.smile.fr/client/Communication/signature/img/rs-facebook.png" \
alt="Facebook" style="border: 0px; vertical-align: middle; max-width: 100%; height: \
auto;"></a></span>  <span><a href="https://www.linkedin.com/company/smile" \
style="background-color:transparent;color:rgb(221,72,20);margin-right:5px" \
target="_blank"><img \
src="http://ftp.smile.fr/client/Communication/signature/img/rs-linkedin.png" \
alt="LinkedIn" style="border: 0px; vertical-align: middle; max-width: 100%; height: \
auto;"></a></span>  <span><a href="https://github.com/Smile-SA" \
style="background-color:transparent;color:rgb(221,72,20);margin-right:5px" \
target="_blank"><img \
src="http://ftp.smile.fr/client/Communication/signature/img/rs-github.png" \
alt="Github" style="border: 0px; vertical-align: middle; max-width: 100%; height: \
auto;"></a></span></div></td></tr></tbody></table><br \
style="color:rgb(51,51,51);font-family:Raleway,regular;font-size:14px"><div \
style="color:rgb(51,51,51);font-family:Raleway,regular;font-size:14px"><a \
href="https://www.smile.eu/fr/publications/livres-blancs/yocto?utm_source=signature&amp;utm_medium=email&amp;utm_campaign=signature" \
style="background-color:transparent;color:rgb(221,72,20)" target="_blank"><img \
src="https://signature.smile.eu/assets/img/bandeaux_signature_mail_yocto.gif.gif" \
alt="Découvrez l'univers Smile, rendez-vous sur smile.eu" border="0" style="border: \
0px; vertical-align: middle;"></a></div></div></div></div></div>



_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic