Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

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

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
rlue
Posts: 13
Joined: 2017-10-30 02:04

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

#1 Post by rlue »

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?

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

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

#2 Post by Dai_trying »

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.

shep
Posts: 423
Joined: 2011-03-15 15:22

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

#3 Post by shep »

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

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

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

#4 Post by debiman »

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

Code: Select all

systemd-analyze blame

rlue
Posts: 13
Joined: 2017-10-30 02:04

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

#5 Post by rlue »

@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

#6 Post by rlue »

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 ... ackground/) 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/question ... 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?

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

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

#7 Post by Head_on_a_Stick »

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.
deadbang

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

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

#8 Post by debiman »

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.

rlue
Posts: 13
Joined: 2017-10-30 02:04

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

#9 Post by rlue »

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/question ... ssies-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

#10 Post by rlue »

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.

Post Reply