Re: [systemd-devel] Question about systemd-firstboot

2017-03-09 Thread Francis Moreau
On Thu, Mar 9, 2017 at 5:49 PM, Zbigniew Jędrzejewski-Szmek
 wrote:
>> So if 'ro' is used, systemd-firstboot is not working. If it's expected
>> I think it would worth a note in the documentation.
> It's supposed to work, I think. Please open an issue, it'll be better
> tracked there.
>

https://github.com/systemd/systemd/issues/5562

Thank you.
-- 
Francis
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question about systemd-firstboot

2017-03-09 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Mar 09, 2017 at 05:31:46PM +0100, Francis Moreau wrote:
> On Thu, Mar 9, 2017 at 5:19 PM, Zbigniew Jędrzejewski-Szmek
>  wrote:
> > It depends on the command-line parameters: 'ro' and 'rw' both work.
> > 'rw' is actually recommended if you're using an initramfs.
> who is recommending 'rw' ?
That's how I remember the result of the discussions on systemd-devel
when we were trying to get systemd-fsck to work properly on all
combinations of ro/rw and fs type. I don't think there's any official
recommendation, just the general agreement that fsck is done better
in the initramfs (if at all needed, since most filesystems don't
really need it), and then there's no point in having the root temporarilly
read-only in the real system.

> > Otherwise, an empty /etc/machine-id may be present, if /etc is read-only
> > at boot, in which case systemd will do a temporary mount.
> >
> > So 'ro' is supported, but you either need an /etc/machine-id file or
> > a place to mount one temporarily.
> 
> So if 'ro' is used, systemd-firstboot is not working. If it's expected
> I think it would worth a note in the documentation.
It's supposed to work, I think. Please open an issue, it'll be better
tracked there.

Zbyszek

> On my setup, neither 'rw' nor 'ro' is passed so I assume 'ro' is the default.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] mount-on-demand for backups; hooks for indicating success/failure

2017-03-09 Thread Jonathan Dowland
Hey,

I have some backup services which depend on mounts. I want those
filesystems unmounted when the backup jobs are not running. This is
easily achieved with StopWhenUnneeded.

I also want to trigger the backup jobs to start when I attach my
external HDD. This is reasonably simple by adding WantedBy=
to the backup service (*not* the mount unit, or it will never be
auto-unmounted).

So far so good!

However, this is a headless box and I want to blink an LED when certain
jobs are running, finish or fail. So I need to execute commands in
certain situations. Job failure is easy, I can use OnFailure= and set up
a oneshot service. Job started isn't too bad, I add a ExecStart=-
to my backup service before the real one.

Signalling "device is safe to remove" I have not figured out.
Using a chain of blah.device -> blah.mount -> backup-blah.service units,
"safe to remove" LED should only happen after the mount has completed
unmounting, successfully. Is there an existing "hook" or place that I
could put that in this situation?

My temporary solution is to remove the mount unit entirely, define the
mount point in /etc/fstab and use ExecStart and ExecStop in the backup
service to mount and umount before and after the job runs:

[Unit]
OnFailure=blinkstick-fail.service
[Service]
ExecStart=/bin/mount /media/ipod
# vvv this is a "backup in progress" colour vvv
ExecStart=/usr/local/bin/blinkstick --index 1 --limit 10 --set-color 33c280
ExecStart=/usr/bin/rsync ... # the backup job
ExecStop=/bin/umount /media/ipod
ExecStop=/usr/local/bin/blinkstick --index 1 --limit 10 --set-color green

This works for this simple use-case, but is not very elegant, and I
don't think I can scale this up to my next task: do the same but for an
*encrypted* filesystem. So here I have to have  ->
systemd-crpytsetup@.service -> .mount (or not?) ->
backup-black.service.


Any advice appreciated. Thanks!


-- 
Jonathan Dowland
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question about systemd-firstboot

2017-03-09 Thread Francis Moreau
On Thu, Mar 9, 2017 at 5:19 PM, Zbigniew Jędrzejewski-Szmek
 wrote:
> It depends on the command-line parameters: 'ro' and 'rw' both work.
> 'rw' is actually recommended if you're using an initramfs.
>

who is recommending 'rw' ?

do you have any pointers ?

> Otherwise, an empty /etc/machine-id may be present, if /etc is read-only
> at boot, in which case systemd will do a temporary mount.
>
> So 'ro' is supported, but you either need an /etc/machine-id file or
> a place to mount one temporarily.

So if 'ro' is used, systemd-firstboot is not working. If it's expected
I think it would worth a note in the documentation.

On my setup, neither 'rw' nor 'ro' is passed so I assume 'ro' is the default.

Thanks for your help
-- 
Francis
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question about systemd-firstboot

2017-03-09 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Mar 09, 2017 at 03:49:51PM +0100, Francis Moreau wrote:
> On Thu, Mar 9, 2017 at 3:10 PM, Zbigniew Jędrzejewski-Szmek
>  wrote:
> > On Thu, Mar 09, 2017 at 10:48:03AM +0100, Francis Moreau wrote:
> >> Hello,
> >>
> >> I'm puzzled about systemd-firstboot service.
> >>
> >> In my understanding this service is ran only during the firstboot. The
> >> firstboot condition is detected with the presence of /etc/machine-id
> >> file.
> >>
> >> If this file is not present then it's assumed to be a first boot and
> >> systemd-firstboot.service is ran and will create the machine-id file.
> >>
> >> Now the thing is that I dont see how systemd-firstboot.service can
> >> have a chance to be started because if /etc/machine-id is missing the
> >> whole boot is failing due to journald requiring /etc/machine-id.
> >>
> >> Could anybody give me some clues ?
> >
> > machine_id_setup() is called from main(). So pid1 should set up
> > /etc/machine-id if possible (/etc is wriable) before it starts the
> > firstboot services.
> >
> 
> For regular boots /etc is always RO when systemd is started, at least
> in my understanding.
It depends on the command-line parameters: 'ro' and 'rw' both work.
'rw' is actually recommended if you're using an initramfs.

Otherwise, an empty /etc/machine-id may be present, if /etc is read-only
at boot, in which case systemd will do a temporary mount.

So 'ro' is supported, but you either need an /etc/machine-id file or
a place to mount one temporarily.

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


Re: [systemd-devel] Question about systemd-firstboot

2017-03-09 Thread Francis Moreau
On Thu, Mar 9, 2017 at 3:10 PM, Zbigniew Jędrzejewski-Szmek
 wrote:
> On Thu, Mar 09, 2017 at 10:48:03AM +0100, Francis Moreau wrote:
>> Hello,
>>
>> I'm puzzled about systemd-firstboot service.
>>
>> In my understanding this service is ran only during the firstboot. The
>> firstboot condition is detected with the presence of /etc/machine-id
>> file.
>>
>> If this file is not present then it's assumed to be a first boot and
>> systemd-firstboot.service is ran and will create the machine-id file.
>>
>> Now the thing is that I dont see how systemd-firstboot.service can
>> have a chance to be started because if /etc/machine-id is missing the
>> whole boot is failing due to journald requiring /etc/machine-id.
>>
>> Could anybody give me some clues ?
>
> machine_id_setup() is called from main(). So pid1 should set up
> /etc/machine-id if possible (/etc is wriable) before it starts the
> firstboot services.
>

For regular boots /etc is always RO when systemd is started, at least
in my understanding.

Just give it a try, remove /etc/machine-id and reboots, you'll see
that journald will fail.

Cheers.
-- 
Francis
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question about systemd-firstboot

2017-03-09 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Mar 09, 2017 at 10:48:03AM +0100, Francis Moreau wrote:
> Hello,
> 
> I'm puzzled about systemd-firstboot service.
> 
> In my understanding this service is ran only during the firstboot. The
> firstboot condition is detected with the presence of /etc/machine-id
> file.
> 
> If this file is not present then it's assumed to be a first boot and
> systemd-firstboot.service is ran and will create the machine-id file.
> 
> Now the thing is that I dont see how systemd-firstboot.service can
> have a chance to be started because if /etc/machine-id is missing the
> whole boot is failing due to journald requiring /etc/machine-id.
> 
> Could anybody give me some clues ?

machine_id_setup() is called from main(). So pid1 should set up
/etc/machine-id if possible (/etc is wriable) before it starts the
firstboot services.

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


[systemd-devel] Question about systemd-firstboot

2017-03-09 Thread Francis Moreau
Hello,

I'm puzzled about systemd-firstboot service.

In my understanding this service is ran only during the firstboot. The
firstboot condition is detected with the presence of /etc/machine-id
file.

If this file is not present then it's assumed to be a first boot and
systemd-firstboot.service is ran and will create the machine-id file.

Now the thing is that I dont see how systemd-firstboot.service can
have a chance to be started because if /etc/machine-id is missing the
whole boot is failing due to journald requiring /etc/machine-id.

Could anybody give me some clues ?

Thanks.
-- 
Francis
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel