[systemd-devel] [Install] question

lux-integ lux-integ at btconnect.com
Thu Aug 1 01:58:57 PDT 2013


On Thursday 01 August 2013 08:00:49 Tomasz Torcz wrote:
>   They cannot be in mount.  There are few way to accomplish what you want,
> but without details I can provide only vague directions.  You need to
> create unit for your work.  You can stuff mkdir into ExecStartPre and cp
> into ExecStart; you have to make your unit Require the mount unit (or go
> with the automounter); activation of your work unit should trigger mount.
>   There are few details to work out, like for example usage of PartOf.


Thanks for your reply

I take the opportunity  to  layout in more detail what my problem is and 
hopefully you and others will provide guidance:-


I want to translate the following    from a typical init scipt to systemd.

##############
/bin/mount \
-m $someMode \
-t someType \
-o opt1,opt2,opt3 \
someDIR  /somewhereInFS

/bin/mkdir  \
--mode $someMode  $someDIR/otherDIR

/bin/cp -a someStuff  $someDIR/otherDIR

#############

My first approach is to   use a so-called service file like so


[Unit]
Description=Mounting and copying stuff

[Service]
ExecStart=/bin/mount \
-m $someMode \
-t someType \
-o opt1,opt2,opt3 \
someDIR  /somewhereInFS

ExecStart=/bin/mkdir  \
--mode $someMode  $someDIR/otherDIR

ExecStart=/bin/cp -a someStuff  $someDIR/otherDIR

##############
However I would like to use so called mount units and   with this approach 
this is the furtherst I get:-

[Unit]
Description=Mounting somewhereInFS
#After=dont know what to put here?
#Before=dont know what to put here?



[Mount]
What=someDIR 
Where=/somewhereInFS
Type=someType
Options=opt1,opt2,opt3
DirectoryMode=$someMode

I am then stuck I dont know where to put the last two commands namely:-

#--------------------
ExecStart=/bin/mkdir  \
--mode $someMode  $someDIR/otherDIR
and
ExecStart=/bin/cp -a someStuff  $someDIR/otherDIR
#--------------------------


do I have to create a service file for these and if so  how do I ensure    the 
mount unit is exicuted before  this service is called?
( Remark::- this is a learnig exercise  And  using  fstab is not in such an 
instance an option )

Thanks in advance

sincerely
luxInteg


More information about the systemd-devel mailing list