Re: [systemd-devel] Help! Reached target Local File Systems order is incorrect

2023-10-11 Thread Tony Rodriguez
Believe I found a solution after some extra debugging. However, I 
appreciate materials/links you provided.  It is definitely good stuff to 
know.


Regards,
Tony




Re: [systemd-devel] Help! Reached target Local File Systems order is incorrect

2023-10-10 Thread Lennart Poettering
On Mo, 09.10.23 12:07, Tony Rodriguez (unixpro1...@gmail.com) wrote:

> Created a service that invokes a "systemctl daemon-reload". Goal is for a
> reload to occur early in the boot process, before other user made services
> are invoked.  During additional testing, sometimes it is correct and other
> times it is out of order (incorrect -  See steps C).  It may work for 5 or 6
> times after each reboot/shutdown, then randomly become incorrect. How can I
> make this more consistent? Already tried various keyword combinations
> (wants,before,after, etc) within the unit file, all without luck.
> Thought about something like "After=var.mount, etc" as well, but that is
> inflexible because I will not know filesystems users may create.
>
> A) Unit file
>
> [Unit]
> Description=Systemctl-Reload
> Wants=local-fs.target
> DefaultDependencies=yes
>
> [Service]
> Type=oneshot
> RemainAfterExit=yes
> ExecStart=/bin/systemctl daemon-reload
>
> [Install]
> WantedBy=local-fs.target
>
> B)  Correct order: ** Reached target Local File Systems is after all
> mounting is done. Sometimes it works.

You have not defined any order in the unit file. i.e. not After= nor
Before=. Hence it's going to be executed as quickly as possible during
boot.

See docs:

https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before=

Generally though it's recommended not to reload PID 1 configuration
during the initial transaction if avoidable. Better approaches are to
put together generators or so, which can augment the set of units and
their dependencies already when the first transaction is put together.

https://www.freedesktop.org/software/systemd/man/systemd.generator.html

Lennart

--
Lennart Poettering, Berlin


[systemd-devel] Help! Reached target Local File Systems order is incorrect

2023-10-09 Thread Tony Rodriguez
Created a service that invokes a "systemctl daemon-reload". Goal is for 
a reload to occur early in the boot process, before other user made 
services are invoked.  During additional testing, sometimes it is 
correct and other times it is out of order (incorrect -  See steps C).  
It may work for 5 or 6 times after each reboot/shutdown, then randomly 
become incorrect. How can I make this more consistent? Already tried 
various keyword combinations (wants,before,after, etc) within the unit 
file, all without luck.
Thought about something like "After=var.mount, etc" as well, but that is 
inflexible because I will not know filesystems users may create.


A) Unit file

[Unit]
Description=Systemctl-Reload
Wants=local-fs.target
DefaultDependencies=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/systemctl daemon-reload

[Install]
WantedBy=local-fs.target


B)  Correct order: ** Reached target Local File Systems is after all 
mounting is done. Sometimes it works.


eg:
journalctl --boot=0 | grep -E 'Mounting |Mounted |Local File'
Oct 09 11:21:39 rocky8-linux-build systemd[1]: Mounting Kernel 
Configuration File System...
Oct 09 11:21:39 rocky8-linux-build systemd[1]: Mounted Kernel 
Configuration File System.
Oct 09 11:21:40 rocky8-linux-build systemd[1]: Reached target Local File 
Systems (Pre).
Oct 09 11:21:40 rocky8-linux-build systemd[1]: Reached target Local File 
Systems.

Oct 09 11:21:40 rocky8-linux-build systemd[1]: Mounting /sysroot...
Oct 09 11:21:40 rocky8-linux-build kernel: XFS (dm-0): Mounting V5 
Filesystem

Oct 09 11:21:40 rocky8-linux-build systemd[1]: Mounted /sysroot.
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Mounting /sysroot/usr...
Oct 09 11:21:41 rocky8-linux-build kernel: XFS (dm-2): Mounting V5 
Filesystem

Oct 09 11:21:41 rocky8-linux-build systemd[1]: Mounted /sysroot/usr.
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Stopped target Local File 
Systems.
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Stopped target Local File 
Systems (Pre).
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Mounted POSIX Message 
Queue File System.
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Mounted Kernel Debug File 
System.
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Mounted Huge Pages File 
System.
Oct 09 11:21:42 rocky8-linux-build systemd[1]: Mounting FUSE Control 
File System...
Oct 09 11:21:42 rocky8-linux-build systemd[1]: Mounted FUSE Control File 
System.
Oct 09 11:21:42 rocky8-linux-build systemd[1]: Reached target Local File 
Systems (Pre).

Oct 09 11:21:42 rocky8-linux-build systemd[1]: Mounting /boot...
Oct 09 11:21:42 rocky8-linux-build systemd[1]: Mounting /tmp...
Oct 09 11:21:42 rocky8-linux-build systemd[1]: Mounting /var...
Oct 09 11:21:42 rocky8-linux-build kernel: XFS (vda2): Mounting V5 
Filesystem
Oct 09 11:21:42 rocky8-linux-build kernel: XFS (dm-3): Mounting V5 
Filesystem

Oct 09 11:21:42 rocky8-linux-build systemd[1]: Mounting /home...
Oct 09 11:21:42 rocky8-linux-build kernel: XFS (dm-4): Mounting V5 
Filesystem
Oct 09 11:21:42 rocky8-linux-build kernel: XFS (dm-5): Mounting V5 
Filesystem

Oct 09 11:21:42 rocky8-linux-build systemd[1]: Mounted /tmp.
Oct 09 11:21:43 rocky8-linux-build systemd[1]: Mounted /boot.
Oct 09 11:21:43 rocky8-linux-build systemd[1]: Mounting /boot/efi...
Oct 09 11:21:43 rocky8-linux-build systemd[1]: Mounted /boot/efi.
Oct 09 11:21:43 rocky8-linux-build systemd[1]: Mounted /home.
Oct 09 11:21:43 rocky8-linux-build systemd[1]: Mounted /var.
*** Oct 09 11:21:43 rocky8-linux-build systemd[1]: Reached target Local 
File Systems.  <<--- This is correct
Oct 09 11:21:43 rocky8-linux-build systemd[1]: Mounting RPC Pipe File 
System...

Oct 09 11:21:43 rocky8-linux-build systemd[1]: Mounted RPC Pipe File System.

C)  Other times a mount is randomly out of order:
eg:
journalctl --boot=0 | grep -E 'Mounting |Mounted |Local File'
Oct 09 11:21:39 rocky8-linux-build systemd[1]: Mounting Kernel 
Configuration File System...
Oct 09 11:21:39 rocky8-linux-build systemd[1]: Mounted Kernel 
Configuration File System.
Oct 09 11:21:40 rocky8-linux-build systemd[1]: Reached target Local File 
Systems (Pre).
Oct 09 11:21:40 rocky8-linux-build systemd[1]: Reached target Local File 
Systems.

Oct 09 11:21:40 rocky8-linux-build systemd[1]: Mounting /sysroot...
Oct 09 11:21:40 rocky8-linux-build kernel: XFS (dm-0): Mounting V5 
Filesystem

Oct 09 11:21:40 rocky8-linux-build systemd[1]: Mounted /sysroot.
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Mounting /sysroot/usr...
Oct 09 11:21:41 rocky8-linux-build kernel: XFS (dm-2): Mounting V5 
Filesystem

Oct 09 11:21:41 rocky8-linux-build systemd[1]: Mounted /sysroot/usr.
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Stopped target Local File 
Systems.
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Stopped target Local File 
Systems (Pre).
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Mounted POSIX Message 
Queue File System.
Oct 09 11:21:41 rocky8-linux-build systemd[1]: Mounted Kernel Debug File