You are not logged in.

#1 2012-08-31 17:44:12

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

[SOLVED] Netcfg.service always failing.

Hello,

Since systemd got pushed down with an update I decided to jump the ship (even though roughly a week ago I tried it and decided to wait a while, the irony roll) With the help of my previous topic and the knowledge that e4rat does work with systemd, I got everything working and it's working faster than ever too. Win/win if you ask me.

There's only one issue: the netcfg.service that I have enabled with systemctl enable netcfg.service always fail on boot and I have to manually connect later. I don't know why it fails, so I hope you can help me tracking the issue.

This is the output of systemctl status netcfg.service right after booting:

┌─[jente @ lappy ~] 19:39:30 
└─■ systemctl status netcfg.service
netcfg.service - Netcfg multi-profile daemon
	  Loaded: loaded (/usr/lib/systemd/system/netcfg.service; enabled)
	  Active: failed (Result: exit-code) since Fri, 31 Aug 2012 19:35:04 +0200; 4min 27s ago
	 Process: 253 ExecStart=/usr/bin/netcfg-daemon start (code=exited, status=1/FAILURE)
	  CGroup: name=systemd:/system/netcfg.service

And here's systemctl --failed list-units:

┌─[jente @ lappy ~] 19:39:32 
└─■ systemctl --failed list-units
UNIT           LOAD   ACTIVE SUB    JOB DESCRIPTION
netcfg.service loaded failed failed     Netcfg multi-profile daemon

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
JOB    = Pending job for the unit.

1 units listed. Pass --all to see inactive units, too.

And here's the journal output:

----- Reboot -----
Aug 31 19:35:04 lappy netcfg-daemon[253]: :: [ESSID] up interface wlan0 does not exist
Aug 31 19:35:04 lappy netcfg-daemon[253]: [fail]

I don't think it's any netcfg configuration file, because it did work with SysV and the net-profiles daemon.

Last edited by Unia (2012-10-31 14:20:21)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#2 2012-08-31 20:06:54

Stebalien
Member
Registered: 2010-04-27
Posts: 1,237
Website

Re: [SOLVED] Netcfg.service always failing.

Units can depend on devices so you could have your netcfg unit require sys-subsystem-net-devices-wlan0.device. However, this is not a general solution as it assumes that your device is wlan0.

As a side note, if you don't need initscripts compatibility, I would use netcfg@.service instead of using the netcfg.service and a the networks array. You can create as many '/etc/systemd/system/multi-user.target.wants/netcfg@<your-profile>.service' symlinks to '/usr/lib/systemd/system/netcfg@.service' as you want.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#3 2012-08-31 20:11:10

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Netcfg.service always failing.

Won't using netcfg@.service limit me to using one network at startup? When I'm roaming (which, admittedly, I'm not often) I like to make use of the NETWORKS=(last) option in /etc/conf.d/netcfg.

But, considering I'm not roaming that often, using the static netcfg@.service seems like a nice solution.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#4 2012-08-31 20:19:52

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED] Netcfg.service always failing.

Unia wrote:
----- Reboot -----
Aug 31 19:35:04 lappy netcfg-daemon[253]: :: [ESSID] up interface wlan0 does not exist
Aug 31 19:35:04 lappy netcfg-daemon[253]: [fail]

Shouldn't you be investigating why your interface does not exist?

Offline

#5 2012-08-31 20:24:15

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Netcfg.service always failing.

tomk wrote:
Unia wrote:
----- Reboot -----
Aug 31 19:35:04 lappy netcfg-daemon[253]: :: [ESSID] up interface wlan0 does not exist
Aug 31 19:35:04 lappy netcfg-daemon[253]: [fail]

Shouldn't you be investigating why your interface does not exist?

Well, as I said, I have no idea what to troubleshoot in systemd. It worked before in SysV and when I get to X (using systemd) it works too when I manually run netcfg [ESSID].

So, the error should be somewhere in systemd. It's just that I don't know where and that's why I'm asking here.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#6 2012-08-31 20:33:43

Stebalien
Member
Registered: 2010-04-27
Posts: 1,237
Website

Re: [SOLVED] Netcfg.service always failing.

Unia wrote:

Won't using netcfg@.service limit me to using one network at startup? When I'm roaming (which, admittedly, I'm not often) I like to make use of the NETWORKS=(last) option in /etc/conf.d/netcfg.

But, considering I'm not roaming that often, using the static netcfg@.service seems like a nice solution.

While you can't use menu/lsat, as far as I know, you can enable multiple netcfg@.service units. However, this will have concurrency problems if you have multiple profiles trying to bring up the same interface.

-- edit:
@tomk: Netcfg is probably starting too early. The note about netcfg@.service was semi-off topic (As a side note...). But that is a good point.
@Unia: Try my first suggestion and see if it fixes your problem before messing with anything else.

Last edited by Stebalien (2012-08-31 20:38:02)


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#7 2012-08-31 20:38:51

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: [SOLVED] Netcfg.service always failing.

For my broadcom wireless I have added the following two lines in the "Unit" section of by network.service

After=sys-devices-pci0000:00-0000:00:1c.1-0000:02:00.0-bcma0:0-net-wlan0.device
BindTo=sys-devices-pci0000:00-0000:00:1c.1-0000:02:00.0-bcma0:0-net-wlan0.device

Now the connection starts reliably every boot.

Offline

#8 2012-08-31 21:05:24

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Netcfg.service always failing.

@Stebalien: I tried your suggestion. I copied /usr/lib/systemd/system/netcfg.service to /etc/systemd/system/netcfg.service and I added Requires=sys-subsystem-net-devices-wlan0.device to the UNIT section. However, I still get the same error.

@vacant: I guess your solution is kinda the same, but I don't think I can copy your bits (think it's setup-dependant). Where did you find those lines? I checked the journal but didn't find them.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#9 2012-08-31 21:11:57

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Netcfg.service always failing.

Maybe you could do something like this to wait for a wlan device or a connected cable before running netcfg (in a separate service file ordered with Before=netcfg.service)

#!/bin/sh
for i in {1..5} # wait up to 5 seconds for wlan or wire
do
	[ -d /sys/class/net/wlan0 ] && exit
	for f in /sys/class/net/eth*
	do
		carrier=$(cat "$f/carrier")
		[ "$carrier" = "1" ] && exit 0
	done
	sleep 1
done

| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#10 2012-08-31 21:15:26

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Netcfg.service always failing.

^ I could, but I don't consider that a "clean" fix. For now, I will see if something else works. If not, I might end up doing that.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#11 2012-08-31 21:17:43

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Netcfg.service always failing.

Unia wrote:

^ I could, but I don't consider that a "clean" fix. For now, I will see if something else works. If not, I might end up doing that.

Maybe this functionality is missing in netcfg? Waiting until a device exists. Or maybe this is part of net-auto-wireless.service / net-auto-wired.service ?


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#12 2012-08-31 21:20:25

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: [SOLVED] Netcfg.service always failing.

Unia wrote:

@vacant: I guess your solution is kinda the same, but I don't think I can copy your bits (think it's setup-dependant). Where did you find those lines? I checked the journal but didn't find them.

systemctl --full

First column gives the id of the unit you want, you should see your wireless device in the "description" column (I see "BCM43225 802.11b/g/n").

Offline

#13 2012-08-31 21:24:49

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Netcfg.service always failing.

^ Thanks, got it. One question: are you sure it's network.service? I don't have it. I only have network.target. Is is that one, or is it netcfg.service?


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#14 2012-08-31 21:30:31

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: [SOLVED] Netcfg.service always failing.

I use a custom "network.service" as I have a static ip on my wireless lan (oh, and I chucked in the hdparm stuff because after suspend I found the disk had lost those settings, so don't copy that line). Based on this wiki section.

$ cat /etc/systemd/system/network.service 
[Unit]
Description=Network Connectivity
Wants=network.target
Before=network.target
After=sys-devices-pci0000:00-0000:00:1c.1-0000:02:00.0-bcma0:0-net-wlan0.device
BindTo=sys-devices-pci0000:00-0000:00:1c.1-0000:02:00.0-bcma0:0-net-wlan0.device

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network

ExecStart=/sbin/hdparm --yes-i-know-what-i-am-doing -m 16 -S0 -B255 /dev/sda
ExecStart=/usr/sbin/wpa_supplicant -B -i ${interface} -c /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down
ExecStop=/usr/bin/killall wpa_supplicant

[Install]
WantedBy=multi-user.target

Offline

#15 2012-08-31 21:34:44

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Netcfg.service always failing.

I see. So would I want to add this to network.target, or netcfg.service? Or should I create a (more minimal) network.service too?

Sorry, I'm a complete noob concerning systemd...


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#16 2012-08-31 21:40:57

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: [SOLVED] Netcfg.service always failing.

1) the /etc/systemd/system/network.service is a new file I created
2) then "systemctl enable network.service" so it starts at boot.

That replaces any netcfg.service and, in my case, wpa_supplicant????.service, so I have those disabled.

Offline

#17 2012-08-31 21:46:00

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Netcfg.service always failing.

Yes, but I only need the Before= and BindTo= lines, so that doesn't require a whole new file (I think). Could I also add this to network.target or netcfg.service?


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#18 2012-08-31 21:57:33

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: [SOLVED] Netcfg.service always failing.

Copy /usr/lib/systemd/system/netcfg.service to /etc/systemd/system/netcfg.service and modify that. The /etc version takes precedence and you still have the original kept safe.

Last edited by vacant (2012-08-31 21:58:08)

Offline

#19 2012-08-31 22:02:05

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Netcfg.service always failing.

Yep, that seems to work!

Thanks everyone for the quick fix! Marking solved!


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#20 2012-09-01 21:37:29

shagrat
Member
From: Norway
Registered: 2004-05-25
Posts: 18
Website

Re: [SOLVED] Netcfg.service always failing.

Adding the After and BindTo requirements can cleanly be done by creating
a /etc/systemd/system/netcfg.service with a include directive:

.include /usr/lib/systemd/system/netcfg.service

[Unit]
After=sys-devices-pci0000:00-0000:00:1c.1-0000:03:00.0-bcma0:0-net-wlan0.device
BindTo=sys-devices-pci0000:00-0000:00:1c.1-0000:03:00.0-bcma0:0-net-wlan0.device

Last edited by shagrat (2012-09-01 21:37:53)

Offline

#21 2012-09-01 21:43:35

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Netcfg.service always failing.

^ That's even sweeter! Thanks!


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#22 2012-10-04 03:48:03

thorion
Member
Registered: 2012-02-06
Posts: 19

Re: [SOLVED] Netcfg.service always failing.

Sorry for the slight bump, but this solution worked for us (two-person robotics team), and I wanted to add this info so that people who are desperately searching for information can find this thread more easily.

I'm guessing that this problem of systemd not loading the usb wifi device on time is caused by having a slow system. We had this problem with Arch Linux ARM on a Raspberry Pi <http://en.wikipedia.org/wiki/Raspberry_Pi>, which is understandable considering how slow it is compared to modern desktops. We were using a Belkin F5D8053 usb wifi adapter, and had no idea why we saw such seemingly inconsistent behavior with it, until we read this thread and I used shagrat's method.

By the way, if you replace every instance of "netcfg.service" with "netcfg@.service" you can use the "netcfg@<profile>.service" notation to start individual netcfg profiles at boot.

Last edited by thorion (2012-10-04 03:51:07)

Offline

#23 2012-10-19 06:30:22

drrossum
Member
From: Chicago
Registered: 2009-02-24
Posts: 82

Re: [SOLVED] Netcfg.service always failing.

I'd like to point to a potential problem with using the BindTo= directive.  I used this directive in my net-auto-wireless.service and it looks like it prevented the connection to reestablish after getting lost.

Offline

Board footer

Powered by FluxBB