Wifi adds 1min+ to boot time — how to connect in background?

Kernels & Hardware, configuring network, installing services

Wifi adds 1min+ to boot time — how to connect in background?

Postby rlue » 2017-10-31 11:16

As stated in a previous thread, I'm running a minimal installation of Debian 9.2. When I first booted off of a fresh installation, it took ~10s to reach the login prompt. Now that I have drivers for my wireless card installed and a connection configured through network-manager, the boot process takes upwards of one minute to complete.

Is there any way to initialize the wireless network in the background, so that the boot process doesn't have to wait on it, and it finishes in the background as I'm logging in?
rlue
 
Posts: 13
Joined: 2017-10-30 02:04

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby Dai_trying » 2017-10-31 15:35

You should start by finding out what is taking the time during boot-up, it might not be the wifi that is causing it, you could post the error that is displayed when booting.
Dai_trying
 
Posts: 332
Joined: 2016-01-07 12:25

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby shep » 2017-10-31 16:29

One common delay is negotiating a dhcp lease. Debian has several dhcp clients - the default is dhclient(8).

If your delay is in obtaining the dhcp lease, there are several options
-nw
Become a daemon immediately (nowait) rather than waiting until an IP address has been acquired.


You can also keep your /etc/resolv.conf file rather than re writing it on each boot.

The other startup delay can be ntp
shep
 
Posts: 130
Joined: 2011-03-15 15:22

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby debiman » 2017-10-31 19:42

Dai_trying wrote:You should start by finding out what is taking the time during boot-up

Code: Select all
systemd-analyze blame
User avatar
debiman
 
Posts: 1528
Joined: 2013-03-12 07:18

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby rlue » 2017-11-01 02:21

@debiman, thanks for the pointer. @Dai_trying, it's definitely the wifi:

Code: Select all
$ systemd-analyze blame
    1min 14.858s networking.service
          2.666s apt-daily.service
...


@shep, that lead looks very promising. Any idea where I can learn more about where all the system init processes are stored/how they're configured?
rlue
 
Posts: 13
Joined: 2017-10-30 02:04

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby rlue » 2017-11-01 05:36

So I've been doing a little reading and now understand that the script I'm looking for is located at /etc/init.d/networking. I found one blog post (https://www.dotkam.com/2008/08/06/speed-up-ubuntu-boot-time-by-starting-networking-on-the-background/) which suggests directly modifying that file to launch a portion of it in the background (by moving the content of the 'start' branch of the case statement below into a dedicated function):

Code: Select all
# adding this method so it can be run as a background process on the start up
start_on_boot () {
  log_action_begin_msg "Configuring network interfaces"
  type usplash_write >/dev/null 2>/dev/null && usplash_write "TIMEOUT 120" || true
  if [ "$VERBOSE" != no ]; then
    if ifup -a; then
      log_action_end_msg $?
    else
      log_action_end_msg $?
    fi
  else
    if ifup -a >/dev/null 2>&1; then
      log_action_end_msg $?
    else log_action_end_msg $?
    fi
  fi

  type usplash_write >/dev/null 2>/dev/null && usplash_write "TIMEOUT 15" || true
}   

case "$1" in
start) 
  # start networking on the background, so it does not slow down the boot time
  start_on_boot &   

  ;;


Someone on this LinuxQuestions thread (https://www.linuxquestions.org/questions/linux-networking-3/dhcp-on-bootup-how-do-i-background-it-245156/) suggested a similar approach, but then had this to say about making changes to system init scripts:

Normally I don't like editing these files, since your changes will not be preserved when the package is updated, but it should solve your problem.


Is it true that software updates may overwrite changes I make to these files? If so, is there a way to configure DHCP to run in the background without modifying the init script directly?
rlue
 
Posts: 13
Joined: 2017-10-30 02:04

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby Head_on_a_Stick » 2017-11-01 06:28

rlue wrote:Is it true that software updates may overwrite changes I make to these files?

No, APT should leave any modifications in /etc well alone, they are reserved for the sysadmin.

I really don't think backgrounding anything will speed up your connection, systemd already aggressively parallelises all processes anyway.

If DHCP is the problem then assign static addresses instead and disable DHCP.

For the record, I find that both ifupdown (/etc/network/interfaces) and systemd-networkd bring the connection up *much* faster than NetworkManager in Debian stretch.
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6669
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby debiman » 2017-11-02 05:11

i'm a little surprised that on stretch, networking is still initiated by the old sysvinit and not systemd.
chances are, the script you edited is just a leftover from a bygone era, and will change exactly nothing.

rlue wrote:Any idea where I can learn more about where all the system init processes are stored/how they're configured?

talking about systemd, it has good man pages for all commands and config files.
additionally, i really like to use wiki.archlinux.org to get better knowledge, but i guess wiki.debian.org is also good.
services and such are in /etc/systemd and /usr/lib/systemd.
according to what was said earlier, you should leave /usr/lib alone.
if you want to edit one of the files there, copy it to /etc/systemd/system first.
User avatar
debiman
 
Posts: 1528
Joined: 2013-03-12 07:18

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby wizard10000 » 2017-11-02 08:45

I think the thing to do would be to troubleshoot the slow startup as I'm not sure NM is the issue

The network-manager applet runs in the context of the currently logged-in user and therefore can't start before the user logs on. Reading your posts it sounds like the delay is happening before the user logs on, which may eliminate NM as the culprit.

I run Sid with Plasma5 and NM connects about two seconds after the desktop is drawn. If your delay is before login chances are it's a coincidence, not NM :)
we see things not as they are, but as we are.
-- anais nin
User avatar
wizard10000
 
Posts: 1204
Joined: 2011-05-09 20:02
Location: everywhere i go, there i am!

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby rlue » 2017-11-02 13:13

Y'all were definitely right — it wasn't the wifi and it wasn't network-manager. I uninstalled network-manager and was still having the same problem.

Per this thread on the Unix StackExchange (https://unix.stackexchange.com/questions/204753/systemd-waiting-too-long-for-network-at-debian-8-0-jessies-boot), all I had to do was change my ethernet interface in /etc/network/interfaces from "auto" to "allow-hotplug" (the wireless interface was undefined and left up to network-manager to take care of):

Code: Select all
auto lo
iface lo inet loopback

allow-hotplug enp0s10  # this line used to begin with "auto", and was causing the 1min+ delay
iface enp0s10 inet dhcp


I must have made this change around the same time I installed network-manager without paying much mind to it at all.

Thanks for all the insight!
Last edited by rlue on 2017-11-03 00:52, edited 1 time in total.
rlue
 
Posts: 13
Joined: 2017-10-30 02:04

Re: Wifi adds 1min+ to boot time — how to connect in backgro

Postby rlue » 2017-11-02 23:54

Also, re: @Head_on_a_Stick,

For the record, I find that both ifupdown (/etc/network/interfaces) and systemd-networkd bring the connection up *much* faster than NetworkManager in Debian stretch.


I haven't tried setting up systemd-networkd, but at least on my machine, raising a connection via network-manager is fast enough that I can't imagine it being appreciably faster.
rlue
 
Posts: 13
Joined: 2017-10-30 02:04


Return to System configuration

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable