Re: Need help with converting growroot to a systemd service

2014-08-14 Thread Zbigniew Jędrzejewski-Szmek
On Mon, Aug 11, 2014 at 04:42:44PM +0200, Lennart Poettering wrote:
> On Mon, 11.08.14 16:25, Juerg Haefliger (jue...@gmail.com) wrote:
> 
> > On Mon, Aug 11, 20
> > > > [Unit]
> > > > Description=Grow the root partition
> > > > After=systemd-readahead-collect.service systemd-readahead-replay.service
> > > > Before=systemd-fsck@.service sysroot.mount
> > >
> > > This will not work. "systemd-fsck@.service" is is not a unit name (but
> > > just a template for unit names), and dependencies may only be declared
> > > relative to other units, never to templates. (I admit though that this
> > > might be useful to have, but then again, I am not sure how we could
> > > implement this nicely...).
> > >
> > > My recommendation would be to add a dropin file
> > > systemd-fsck@.service/foobar.conf or so, which adds the reverse
> > > dependency of the one you are looking for. Or in other words: extend the
> > > systemd-fsck@.service definition, instead of your growroot.service
> > definition.
> > 
> > Are you saying I should replace the existing systemd-fsck@.service file
> > with my own version or what exactly do you mean by 'extending'?
> 
> You can extend any unit file in systemd by creating a subdir in
> /etc/systemd/system/ named after the unit, but suffixed with ".d", and
> then dropping a .conf file in there. Files like this will be read after
> the main unit file has been read and its settings can hence override or
> extend the settings from the main unit file. For instance units systemd
> will look for both the .d/ directory of the instance and of the template.
> 
> Hence:
> 
>   mkdir -p /etc/systemd/system/systemd-fsck@.service.d
>   echo "..." > /etc/systemd/system/systemd-fsck@.service.d/foobar.conf
>   systemctl daemon-reload
> 
> Allows you to extend the definitions in systemd-fsck@.service by your
> own settings.
If growroot will be packaged (I assume it will), this file should be
under /usr/lib, i.e. replace /etc/systemd/system with /usr/lib/systemd/system
in those instructions.

Zbyszek
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct

Re: Need help with converting growroot to a systemd service

2014-08-11 Thread Lennart Poettering
On Mon, 11.08.14 16:25, Juerg Haefliger (jue...@gmail.com) wrote:

> On Mon, Aug 11, 20
> > > [Unit]
> > > Description=Grow the root partition
> > > After=systemd-readahead-collect.service systemd-readahead-replay.service
> > > Before=systemd-fsck@.service sysroot.mount
> >
> > This will not work. "systemd-fsck@.service" is is not a unit name (but
> > just a template for unit names), and dependencies may only be declared
> > relative to other units, never to templates. (I admit though that this
> > might be useful to have, but then again, I am not sure how we could
> > implement this nicely...).
> >
> > My recommendation would be to add a dropin file
> > systemd-fsck@.service/foobar.conf or so, which adds the reverse
> > dependency of the one you are looking for. Or in other words: extend the
> > systemd-fsck@.service definition, instead of your growroot.service
> definition.
> 
> Are you saying I should replace the existing systemd-fsck@.service file
> with my own version or what exactly do you mean by 'extending'?

You can extend any unit file in systemd by creating a subdir in
/etc/systemd/system/ named after the unit, but suffixed with ".d", and
then dropping a .conf file in there. Files like this will be read after
the main unit file has been read and its settings can hence override or
extend the settings from the main unit file. For instance units systemd
will look for both the .d/ directory of the instance and of the template.

Hence:

  mkdir -p /etc/systemd/system/systemd-fsck@.service.d
  echo "..." > /etc/systemd/system/systemd-fsck@.service.d/foobar.conf
  systemctl daemon-reload

Allows you to extend the definitions in systemd-fsck@.service by your
own settings.

Lennart

-- 
Lennart Poettering, Red Hat
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct

Re: Need help with converting growroot to a systemd service

2014-08-11 Thread Juerg Haefliger
On Mon, Aug 11, 20
> > [Unit]
> > Description=Grow the root partition
> > After=systemd-readahead-collect.service systemd-readahead-replay.service
> > Before=systemd-fsck@.service sysroot.mount
>
> This will not work. "systemd-fsck@.service" is is not a unit name (but
> just a template for unit names), and dependencies may only be declared
> relative to other units, never to templates. (I admit though that this
> might be useful to have, but then again, I am not sure how we could
> implement this nicely...).
>
> My recommendation would be to add a dropin file
> systemd-fsck@.service/foobar.conf or so, which adds the reverse
> dependency of the one you are looking for. Or in other words: extend the
> systemd-fsck@.service definition, instead of your growroot.service
definition.

Are you saying I should replace the existing systemd-fsck@.service file
with my own version or what exactly do you mean by 'extending'?

Thanks
...Juerg
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct

Re: Need help with converting growroot to a systemd service

2014-08-11 Thread Juerg Haefliger
On Mon, Aug 11, 2014 at 3:40 PM, Richard W.M. Jones 
wrote:
>
> On Mon, Aug 11, 2014 at 03:24:59PM +0200, Lennart Poettering wrote:
> > On Mon, 11.08.14 12:59, Juerg Haefliger (jue...@gmail.com) wrote:
> >
> > > All,
> > >
> > > I want to convert the growroot functionality to a proper systemd
service
> >
> > Not sure what "growroot" is...
>
> Lennart, the one I'm familiar with is a dracut module which expands
> the filesystem at first boot to fill the available disk space.
>
> Used very often in cloud and embedded (ARM) systems where you don't
> install using Anaconda, but by copying a fixed size image onto a VM
> disk or memory stick.
>
> The upstream is:
>
> https://launchpad.net/cloud-initramfs-tools
>
> The dracut packaging is:
>
>
https://bazaar.launchpad.net/~juergh/cloud-initramfs-tools/dracut-growroot-pre-mount/files/head:/growroot/dracut/modules.d/50growroot/

Yes that's the one. Sorry for not being verbose enough.

...Juerg


> Rich.
>
> --
> Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
> Read my programming and virtualization blog: http://rwmj.wordpress.com
> virt-p2v converts physical machines to virtual machines.  Boot with a
> live CD or over the network (PXE) and turn machines into KVM guests.
> http://libguestfs.org/virt-v2v
> --
> devel mailing list
> devel@lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/devel
> Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct

Re: Need help with converting growroot to a systemd service

2014-08-11 Thread Richard W.M. Jones
On Mon, Aug 11, 2014 at 03:24:59PM +0200, Lennart Poettering wrote:
> On Mon, 11.08.14 12:59, Juerg Haefliger (jue...@gmail.com) wrote:
> 
> > All,
> > 
> > I want to convert the growroot functionality to a proper systemd service
> 
> Not sure what "growroot" is...

Lennart, the one I'm familiar with is a dracut module which expands
the filesystem at first boot to fill the available disk space.

Used very often in cloud and embedded (ARM) systems where you don't
install using Anaconda, but by copying a fixed size image onto a VM
disk or memory stick.

The upstream is:

https://launchpad.net/cloud-initramfs-tools

The dracut packaging is:

https://bazaar.launchpad.net/~juergh/cloud-initramfs-tools/dracut-growroot-pre-mount/files/head:/growroot/dracut/modules.d/50growroot/

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct

Re: Need help with converting growroot to a systemd service

2014-08-11 Thread Lennart Poettering
On Mon, 11.08.14 12:59, Juerg Haefliger (jue...@gmail.com) wrote:

> All,
> 
> I want to convert the growroot functionality to a proper systemd service

Not sure what "growroot" is...

> but I'm struggling. I (think I) want it to run and finish before the
> filesystems are checked and before /sysroot is mounted. 

This is supposed to be an initrd service hence?

> For testing purposes, I replaced the growroot script with a simple
> script that sleeps for 5 seconds and emits debug messages at the
> beginning and at the end.  What I end up with is that fsck is started
> before growroot and I can't seem
> to figure out why that is. What I have at the moment is:

fsck units are ordered after the devices they are supposed to check, and
before the mount units for it. If you want your service to run before
the fsck, you'd have to order your service between the device and the fsck.

> 
> [Unit]
> Description=Grow the root partition
> After=systemd-readahead-collect.service systemd-readahead-replay.service
> Before=systemd-fsck@.service sysroot.mount

This will not work. "systemd-fsck@.service" is is not a unit name (but
just a template for unit names), and dependencies may only be declared
relative to other units, never to templates. (I admit though that this
might be useful to have, but then again, I am not sure how we could
implement this nicely...).

My recommendation would be to add a dropin file
systemd-fsck@.service/foobar.conf or so, which adds the reverse
dependency of the one you are looking for. Or in other words: extend the
systemd-fsck@.service definition, instead of your growroot.service definition.

> 
> [Service]
> Type=oneshot
> ExecStart=/bin/growroot
> StandardOutput=syslog+console
> StandardError=syslog+console

These two are unnecessary, as all services stdout/stderr will be
connected to the journal anyway by default, and "syslog" and "journal"
in this context are pretty much identical (in fact, we should probably
remove any reference to syslog in the docs, to avoid the confusion...)

> Also, I suspect I need to add this service to a target unit. What would be
> the most appropriate one? Currently it's initrd.target.

This sounds appropriate for an initrd service.

Lennart

-- 
Lennart Poettering, Red Hat
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct

Need help with converting growroot to a systemd service

2014-08-11 Thread Juerg Haefliger
All,

I want to convert the growroot functionality to a proper systemd service
but I'm struggling. I (think I) want it to run and finish before the
filesystems are checked and before /sysroot is mounted. For testing
purposes, I replaced the growroot script with a simple script that sleeps
for 5 seconds and emits debug messages at the beginning and at the end.
What I end up with is that fsck is started before growroot and I can't seem
to figure out why that is. What I have at the moment is:

[Unit]
Description=Grow the root partition
After=systemd-readahead-collect.service systemd-readahead-replay.service
Before=systemd-fsck@.service sysroot.mount

[Service]
Type=oneshot
ExecStart=/bin/growroot
StandardOutput=syslog+console
StandardError=syslog+console
RemainAfterExit=yes

And the log:

[  OK  ] Reached target System Initialization.
[  OK  ] Found device
/dev/disk/by-uuid/d349e793-8c72-4696-ada5-d137ce999ce8.
 Starting File System Check on
/dev/disk/by-uuid/d349...d137ce999ce8...
[  OK  ] Started dracut initqueue hook.
[  OK  ] Reached target Remote File Systems (Pre).
[  OK  ] Reached target Remote File Systems.
[  OK  ] Started Show Plymouth Boot Screen.
[  OK  ] Reached target Paths.
[  OK  ] Reached target Basic System.
 Starting Grow the root partition...
[   11.921184] systemd-fsck[130]: root: clean, 22930/589824 files,
318802/2359296 blocks
[   11.925470] growroot[139]: Start
[  OK  ] Started File System Check on
/dev/disk/by-uuid/d349e...5-d137ce999ce8.
[   15.102699] systemd-udevd (96) used greatest stack depth: 12104 bytes
left
[   16.917436] growroot[139]: Stop
[  OK  ] Started Grow the root partition.
 Mounting /sysroot...
[   17.008583] EXT4-fs (vda1): mounted filesystem with ordered data mode.
Opts: (null)
[  OK  ] Mounted /sysroot.
[  OK  ] Reached target Initrd Root File System.

What am I missing?

Also, I suspect I need to add this service to a target unit. What would be
the most appropriate one? Currently it's initrd.target.

Thanks
...Juerg
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct