[systemd-devel] Portable service and bind paths

Claes H claesatwork at gmail.com
Sun Jan 5 18:25:29 UTC 2020


Turns out the problem was not with the mount - that was working well.
Instead it was a user problem and I did not realize the process ran as
root and used a different home directory.
When I added the user homeassistant in the host and added it to the
User= configuration in the service file it worked
But this required the "admin" of the host to do something additional,
it did not work "out of the box".

I was thinking  - how is it supposed to work with a portable service,
which user is it recommended to run as?
Maybe portablectl attach should create the user the service has
declared, if it does not exist already?
Or should is there be a general user that portable services to run as?
Interested to hear if there is any recommendation for how a portable
service "packager" should define the user aspect of the service

Best regards
Claes

On Sun, Jan 5, 2020 at 1:46 AM Claes H <claesatwork at gmail.com> wrote:
>
> Hi,
> I am experimenting with a portable service for Home Assistant. I think
> embedding it as a portable service would be a good way to isolate its
> quite extensive dependencies.
>
> But I would like to bind mount a directory on the host into the
> service and I can't figure it out.
> The portable service file looks like below but the bind path does not
> seem to take effect.
>
> Is this maybe the wrong way to go? I am able to bind mount it if I
> start using a regular service, that calls systemd-nspawn (like
> ExecStart=/usr/bin/systemd-nspawn -M homeassistant /srv/homeassistant/bin/hass
> ) and has a corresponding .nspawn file with Bind attribute.
>
> I also read in the documentation that .nspawn files are not among the
> unit fies copied out from the image. What is the recommended way to go
> about with this for a portable service?
>
> best regards,
> Claes
>
>
> [Unit]
> Description=Home Assistant (portable service)
> After=network-online.target
>
> [Service]
> Type=simple
> ExecStart=/srv/homeassistant/bin/hass
> Restart=on-failure
> RestartSec=5s
> BindPaths=/home/claes/projects/homeassistant/configuration-.homeassistant:/home/homeassistant/.homeassistant
>
> [Install]
> WantedBy=multi-user.target
>
> --
> C l a e s    H o l m e r s o n



-- 
C l a e s    H o l m e r s o n


More information about the systemd-devel mailing list