You are not logged in.

#1 2018-07-29 22:08:33

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 83
Website

systemd: How to to create a drop-in file for the dhcpcd@.service ?

The dhcpcd wiki page strongly suggest to use a named network interface (to prevent creating a race condition at boot with systemd-udevd).

So I made sure dhcpcd is not enabled:

# systemctl status dhcpcd
* dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/usr/lib/systemd/system/dhcpcd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

And enabled the dhcpcd template for the enp3s0 network interface, as you can see:

# systemctl status dhcpcd@enp3s0.service
* dhcpcd@enp3s0.service - dhcpcd on enp3s0
   Loaded: loaded (/usr/lib/systemd/system/dhcpcd@.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2018-07-28 22:25:15 CEST; 1 day 1h ago
 Main PID: 564 (dhcpcd)
    Tasks: 1 (limit: 4915)
   Memory: 1.7M
   CGroup: /system.slice/system-dhcpcd.slice/dhcpcd@enp3s0.service
           `-564 /usr/bin/dhcpcd -q -w enp3s0
...

Next I do wish to apply the Dhcpcd Timeout delay suggestion because I don't want the console login to wait over 1 minute before being able to login.

The dhcpcd wiki page section is not detailed enough for me to understand how to do that. My first 2 attempts were:

# systemctl edit /etc/systemd/system/dhcpcd@.service.d/timeout.conf
No files found for etc-systemd-system-dhcpcd\x40.service.d-timeout.conf.mount.
Run 'systemctl edit --force etc-systemd-system-dhcpcd\x40.service.d-timeout.conf.mount' to create a new unit.
# systemctl edit /etc/systemd/system/dhcpcd@enp3s0.service.d/timeout.conf
No files found for etc-systemd-system-dhcpcd\x40enp3s0.service.d-timeout.conf.mount.
Run 'systemctl edit --force etc-systemd-system-dhcpcd\x40enp3s0.service.d-timeout.conf.mount' to create a new unit.

Note: there is no file/folder that starts with dhcpcd at [tt]/etc/systemd/system/[/tt]
Note #2: [tt]/etc/systemd/system/multi-user.target.wants/dhcpcd@enp3s0.service[/tt] does exist.

How (with which command) to setup the dhcpcd timeout.conf (as well as dhcpcdrestart.conf) for a named interface?
Is

systemctl edit --force /etc/systemd/system/dhcpcd@.service.d/timeout.conf

correct?

Last edited by probackup-nl (2018-08-24 09:56:37)

Offline

#2 2018-07-30 09:33:45

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: systemd: How to to create a drop-in file for the dhcpcd@.service ?

The command 'systemctl edit' waits a unit file name as parameter:

# systemctl edit dhcpcd@.service

It will create the '/etc/systemd/system/dhcpcd@.service.d' directory automatically, and open the text editor to write the drop-in file, then the systemd configuration is reloaded.

Offline

#3 2018-07-30 09:45:24

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 83
Website

Re: systemd: How to to create a drop-in file for the dhcpcd@.service ?

Thank you for your reply.

# systemctl edit dhcpcd@.service
Failed to get load state of dhcpcd@.service: Unit name dhcpcd@.service is neither a valid invocation ID nor unit name.

I still don't know which exact command to use to create the timeout.conf and restart conf.

Offline

#4 2018-07-31 09:26:09

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: systemd: How to to create a drop-in file for the dhcpcd@.service ?

Did you try the command with 'dhcpcd@enp3s0.service' ?

Offline

#5 2018-08-13 22:44:42

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 83
Website

Re: systemd: How to to create a drop-in file for the dhcpcd@.service ?

berbae wrote:

Did you try the command with 'dhcpcd@enp3s0.service' ?

Hi Berbae,

I hadn't tried

systemctl edit dhcpcd@enp3s0.service

When I do, that opens nano with an empty file, named /etc/systemd/system/dhcpcd@enp3s0.service.d/.#override.conf75d7651b5087e05a

I guess that I should have to paste these 3 lines in the editor and write it:

[Service]
ExecStart=
ExecStart=/usr/bin/dhcpcd -w -q -t 0 %I

I have no clue how to get the wiki suggested "/timeout.conf" or "/dhcpcdrestart.conf" or "/no-wait.conf" in this mix, do you?

Offline

#6 2018-08-14 09:00:34

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,657

Re: systemd: How to to create a drop-in file for the dhcpcd@.service ?

You can just add the timeout.conf at that location and the no-wait is only relevant if you want to get rid of the -w flag because you notice your boot blocking.

Offline

#7 2018-08-14 15:28:13

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: systemd: How to to create a drop-in file for the dhcpcd@.service ?

probackup-nl wrote:
systemctl edit dhcpcd@enp3s0.service

When I do, that opens nano with an empty file, named /etc/systemd/system/dhcpcd@enp3s0.service.d/.#override.conf75d7651b5087e05a

I guess that I should have to paste these 3 lines in the editor and write it

You can save the file giving it the name you want in nano (I presume systemctl will use this name instead of the '.#override...'.
Then if you need it, run the command again to create another .conf file with other lines and another name.

Last edited by berbae (2018-08-14 15:28:42)

Offline

#8 2018-08-24 09:53:53

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 83
Website

Re: systemd: How to to create a drop-in file for the dhcpcd@.service ?

I am still struggling with creating systemd drop-in files for the dhcpcd@ template (not the named instance) following the instructions on Arch wiki.

I do want to override the template

dhcpcd@.serivce

I do not want to edit the named instance

dhcpcd@enp3s0.service

1. https://wiki.archlinux.org/index.php/Dh … own_issues suggests:
dhcpcd@.service is the name of the unit
2. To fix this, create a drop-in file for the unit

3. To create the drop-in file, wiki links to:
https://wiki.archlinux.org/index.php/Sy … p-in_files
That wiki page suggest to

systemctl edit unitname

Combine that:

systemctl edit dhcpcd@.service
Failed to get load state of dhcpcd@.service: Unit name dhcpcd@.service is neither a valid invocation ID nor unit name.

Offline

#9 2018-08-24 11:21:38

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: systemd: How to to create a drop-in file for the dhcpcd@.service ?

probackup-nl wrote:

That wiki page suggest to

systemctl edit unitname

It says

To create drop-in files for the unit file /usr/lib/systemd/system/unit, create the directory /etc/systemd/system/unit.d/ and place .conf files there to override or add new options. systemd will parse and apply these files on top of the original unit.

After that it suggests the edit command as "The easiest way to do this". It is there as a convenience for quick/small changes. If it is not convenient for you -- because it apparently doesn't handle templates or because you want full control over the drop-in files and their names -- then don't use it.

If you had started to wonder whether drop-in files for templates are even possible or just need more information, check the systemd.unit(5) man page. The wiki is decent but it is always good to check instructions against the official docs.

Offline

Board footer

Powered by FluxBB