[ale] systemd - howto wait for _all_ fsck's to finish before starting system

Steve Tynor stevejunk at iintiip.com
Fri Dec 1 11:38:57 EST 2023


Thanks Phil!  That did it.   The key to the puzzle was knowing to look 
for "home.mount" via list-units.   I added Requires and After to 
docker.service, cron.service and my hand crafted *.service files and it 
all works as intended.

Thanks again,
Steve

On 2023-12-01 10:02 AM, Phil Turmel via Ale wrote:
> Hmm. Probably need:
>
> > [Unit]
> > Requires=home.mount
> > After=home.mount
>
> based on systemd.unit(5)
>
> On 12/1/23 09:59, Phil Turmel via Ale wrote:
>> Hi Steve,
>>
>> The tool you need is a dependency on the mount in the affected services.
>>
>> If you do
>>
>> # systemctl list-units
>>
>> you should find the precise name of your home directory's dynamic 
>> mount unit (automatically generated), typically "home.mount".
>>
>> Create a supplement for cron with:
>>
>> # systemctl edit cron.service
>>
>> and put this in the supplement (aka override):
>>
>>  > [Unit]
>>  > Requires=home.mount
>>
>> Then your cron service won't start until /home is mounted.
>>
>> Do similar to any other services affected.
>>
>> On 12/1/23 08:00, Steve Tynor via Ale wrote:
>>> Ubuntu Server 22.04 LTS.  I have a fairly large file system (/home) 
>>> that I wish to fsck at boot. /etc/fstab has:
>>>
>>>      /dev/disk/by-uuid/b4d368cd-e22e-4c85-b261-c0d785de344e /boot 
>>> ext4 defaults 0 1
>>>      /dev/md/ricotta:1     /home     ext4 defaults,nofail,discard 0 2
>>>
>>> On boot, the /boot filesystem get's fsck'd and then systemd seems to 
>>> immediately start the rest of the system in parallel with fsck'ing 
>>> /home.    This is a problem since I have some cron jobs, docker 
>>> containers and other services that rely on directories in /home. 
>>> Those services don't startup nicely if the fsck hasn't finished.
>>>
>>> I'm guessing I could add [Wants] annotation to various .service 
>>> files (if I could figure out what base service to target), but 1) it 
>>> seems like this should work "out of the box", 2) editing half a 
>>> dozen system provided .service files seems fiddly and error prone.
>>>
>>> I've not found any ready-made advice via google.   Which surprises 
>>> me - surely wanting to check _all_ file systems before starting the 
>>> rest of the system is not _that_ uncommon?
>>>
>>> (please don't let this devolve into a systemd bashing thread - I 
>>> don't like systemd, but I've chosen to use Ubuntu and want to live 
>>> within its expectations...)
>>>
>>> Thanks for any advice!
>>>
>>> Steve
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> https://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo


More information about the Ale mailing list