You are not logged in.

#1 2018-11-03 23:50:31

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

[solved] advice regarding netctl-auto, and optional interfaces

Hi there,

I run an arch machine on my laptop, on a separate partition.
I also have this set up to boot as a virtual machine, directly from the partition.

Whilst I have most things working, I can't quite figure out how to handle netctl-auto.

Currently I have a systemd service for netctl-auto on wlp4s0 (my wireless adaptor), and another for netctl-ifplugd on enp5s0f1 (ethernet).
Unfortunately when I boot the partition as a VM, neither of these interfaces are present, so I get a 1.5 minute timeout.

Ideally I would just not load netctl in these situations, but I'm not exactly sure how to do that...

Any advice would be greatly appreciated!

Thanks in advance,
Zach

Last edited by zacharyrs (2018-11-04 22:31:54)

Offline

#2 2018-11-04 00:19:39

loqs
Member
Registered: 2014-03-06
Posts: 19,111

Re: [solved] advice regarding netctl-auto, and optional interfaces

Welcome to the arch linux forums zacharyrs.
Possibly Systemd#Editing_provided_units add ConditionVirtualization=false see man 5 systemd.unit

Offline

#3 2018-11-04 00:53:50

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

Re: [solved] advice regarding netctl-auto, and optional interfaces

Thanks for the suggestion!

I gave it a look, and duplicated the netctl services, adding that under the unit section.
Unfortunately, as they appear to rely on sys-subsystem-net-devices-<xyz> I still get a timeout.

Taking a look regarding removable usb wifi dongles, I did find some info regarding udev, but was unable to get it to work...

Supposedly I needed to create a udev rule like...

ACTION=="add", SUBSYSTEM=="net", KERNEL=="<xyz>", SYMLINK=="wlan0", TAG+="systemd", ENV{SYSTEMD_WANTS}="netctl-auto@wlan0.service"

In my case, I substituted <xyz> with wlp4s0, and renamed my netctl profiles to wlan0-...
Any suggestions where I might be going wrong?

Offline

#4 2018-11-04 01:05:29

loqs
Member
Registered: 2014-03-06
Posts: 19,111

Re: [solved] advice regarding netctl-auto, and optional interfaces

That should not be an issue if the unit is not started because its start conditions are not met.
Does `systemd-detect-virt` detect the virtualization in use when the system is being used as a VM?

Offline

#5 2018-11-04 01:08:34

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

Re: [solved] advice regarding netctl-auto, and optional interfaces

Yes, that returns 'vmware'.

Offline

#6 2018-11-04 01:14:29

loqs
Member
Registered: 2014-03-06
Posts: 19,111

Re: [solved] advice regarding netctl-auto, and optional interfaces

What is the output of `systemctl cat $servicename` and `systemctl status $servicename` where $servicename is the name of one of the services causing the issue.
Edit:
What the output from `systemctl cat X@Y.service` should be like to stop the service running under virtualization.  Tested locally on a netctl service this does work for me.

# /etc/systemd/system/X@Y.service.d/override.conf
[Unit]
ConditionVirtualization=false

Last edited by loqs (2018-11-04 01:24:51)

Offline

#7 2018-11-04 01:22:43

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

Re: [solved] advice regarding netctl-auto, and optional interfaces

A vanilla copy of netctl-auto causes the issue, as does one modified with ConditionVirtualization as below.

# /etc/systemd/system/netctl-auto@.service
[Unit]
Description=Automatic wireless network connection using netctl profiles
Documentation=man:netctl.special(7)
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device network-pre.target
Before=network.target
Wants=network.target
ConditionVirtualization=false

[Service]
Type=forking
RemainAfterExit=yes
ExecStart=/usr/bin/netctl-auto start %I
ExecStop=/usr/bin/netctl-auto stop %I
ExecStopPost=/usr/bin/netctl-auto clean %I

[Install]
WantedBy=multi-user.target

After waiting for the timeout and running the second command, I get...

● netctl-auto@wlp4s0.service - Automatic wireless network connection using netctl profiles
   Loaded: loaded (/etc/systemd/system/netctl-auto@.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:netctl.special(7)

Nov 05 03:20:01 ltv systemd[1]: Dependency failed for Automatic wireless network connection using netctl profiles.
Nov 05 03:20:01 ltv systemd[1]: netctl-auto@wlp4s0.service: Job netctl-auto@wlp4s0.service/start failed with result 'dependency'.

Offline

#8 2018-11-04 01:27:34

loqs
Member
Registered: 2014-03-06
Posts: 19,111

Re: [solved] advice regarding netctl-auto, and optional interfaces

'netctl-auto@wlp4s0.service' is the service you want to edit with `systemctl edit netctl-auto@wlp4s0.service` add just the following two lines to the override

[Unit]
ConditionVirtualization=false

Offline

#9 2018-11-04 01:42:28

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

Re: [solved] advice regarding netctl-auto, and optional interfaces

Correct me if I'm wrong, but the @ symbol just designates the variable %I within the service.

That is, editing netctl-auto@.service, and linking as netctl-auto@wlp4s0.service as I have, means the changes made to netctl-auto@.service are in effect.

Offline

#10 2018-11-04 08:42:08

loqs
Member
Registered: 2014-03-06
Posts: 19,111

Re: [solved] advice regarding netctl-auto, and optional interfaces

What is the output of 'systemctl cat netctl-auto@wlp4s0.service'

Offline

#11 2018-11-04 08:44:11

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

Re: [solved] advice regarding netctl-auto, and optional interfaces

~ zach@ltv
❯ systemctl cat netctl-auto@wlp4s0.service
# /etc/systemd/system/netctl-auto@.service
[Unit]
Description=Automatic wireless network connection using netctl profiles
Documentation=man:netctl.special(7)
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device network-pre.target
Before=network.target
Wants=network.target
ConditionVirtualization=false

[Service]
Type=forking
RemainAfterExit=yes
ExecStart=/usr/bin/netctl-auto start %I
ExecStop=/usr/bin/netctl-auto stop %I
ExecStopPost=/usr/bin/netctl-auto clean %I

[Install]
WantedBy=multi-user.target

Offline

#12 2018-11-04 08:55:57

loqs
Member
Registered: 2014-03-06
Posts: 19,111

Re: [solved] advice regarding netctl-auto, and optional interfaces

If you swap ConditionVirtualization=false for AssertVirtualization=false does that make any difference?
Edit:
If that fails edit systemd-user-sessions.service and remove network.target from the After line to remove the delay.

Last edited by loqs (2018-11-04 09:06:54)

Offline

#13 2018-11-04 09:18:11

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

Re: [solved] advice regarding netctl-auto, and optional interfaces

I'll try it in a sec, currently compiling something.

Would editing that not just be covering up the delay?
I might try reading into udev and see if I can get it to avoid even loading the file, but that'll have to wait till after my exams are over.

Offline

#14 2018-11-04 09:28:01

loqs
Member
Registered: 2014-03-06
Posts: 19,111

Re: [solved] advice regarding netctl-auto, and optional interfaces

It removes the dependency so user sessions do not wait for the networking.target.  It does not stop the services from failing due to the missing device dependency.

Offline

#15 2018-11-04 09:31:37

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

Re: [solved] advice regarding netctl-auto, and optional interfaces

Yes that's what I meant.

Hence it just covers up the symptoms without solving the issue.

Offline

#16 2018-11-04 20:21:15

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

Re: [solved] advice regarding netctl-auto, and optional interfaces

Unfortunately I had no luck with AssertVirtualization.

Currently removed network.target as suggested. I'll look into udev in a few days.

Thanks for the help anyway!

Offline

#17 2018-11-04 22:31:18

zacharyrs
Member
Registered: 2018-11-03
Posts: 14

Re: [solved] advice regarding netctl-auto, and optional interfaces

Well, I ended up reverting that change, as although the VM didn't wait to load anymore, I still couldn't SSH in for 90 seconds.

Ended up reading into udev, and discovering it do what I want (as far as I could tell).
Instead I discovered the virtual network systemd units can be extended to want netctl, so for anyone reading, I did the following...

  1. Made a directory under

    /etc/systemd/system

    called

    sys-subsystem-net-devices-wlp4s0.device.wants
  2. Symlinked

    netctl-auto@.service

    under that directory as

    netctl-auto@wlp4s0.service
  3. Repeated for enp5s0f1 with netctl-ifplugd@.service.


Booting directly into arch now loads netctl as necessary. Booting in a VM (where those devices aren't present) now loads without the timer.

Last edited by zacharyrs (2018-11-04 22:32:15)

Offline

#18 2018-11-17 12:00:38

jouke
Member
Registered: 2009-10-14
Posts: 72

Re: [solved] advice regarding netctl-auto, and optional interfaces

I suspect this works without manual tinkering in netctl 1.19 (currently in [testing]).

Offline

Board footer

Powered by FluxBB