# DHCPCD while in background

## GSnake

Hello guys! I've finally managed to get everything work but my boot time is compromised by dhcpcd trying to link my ethernet card to the net. What can I do to make it execute in background so my PC can boot faster? Thanks!

----------

## oquol

Try removing dhcpcd from rc-update and installing ifplugd. If you haven't done it yet it might help.

----------

## khayyam

GSnake ...

Something is in the runlevel that requires 'net' (what I can't say) this in turn causes dhcpcd to run and provide 'net' (unless of course you've added to to the 'default' runlevel).

You can have dhcpcd not provide net by adding: rc_dhcpcd_provide="!net" to /etc/rc.conf, this will stop dhcpcd from running at boot but you will still have that service (whatever it might be) requiring 'net'. So, you should see what you have added to the runlevel that is the cause of this, as these services require 'net' in order to function correctly.

The following will provide a list of all services set to start at the 'default' runlevel ...

```
rc-config list default
```

You can then remove the service from the runlevel with the following:

```
rc-update del <service> default
```

Thats it basically, there are additional things I could suggest (like creating additional runlevels for 'online' and what-have-you) but as I'm not entirely sure of whats happening, and what your trying to achieve, I'll leave that for you to query.

best ... khay

----------

## Ant P.

If you already have xdm in the default runlevel, just use a script in /etc/local.d to start dhcpcd; that way it'll only start while your login screen is visible.

----------

## GSnake

 *khayyam wrote:*   

> GSnake ...
> 
> Something is in the runlevel that requires 'net' (what I can't say) this in turn causes dhcpcd to run and provide 'net' (unless of course you've added to to the 'default' runlevel).
> 
> You can have dhcpcd not provide net by adding: rc_dhcpcd_provide="!net" to /etc/rc.conf, this will stop dhcpcd from running at boot but you will still have that service (whatever it might be) requiring 'net'. So, you should see what you have added to the runlevel that is the cause of this, as these services require 'net' in order to function correctly.
> ...

 

I'm sorry but I'm here to learn so can I ask you what is a run-level? I started a lot of service under the "default" runlevel but I can't truly understand what it is.. 

How can I make something "start" at boot? (like apps and so on)

Currently I'm following the suggestion of Ant. P since it seems to be the best-fitting for me. [I made a file named 00dhcpcd.start with "exec dhcpcd" in it. Have I done it right?]

Thank you guys!

----------

## Ant P.

A better way would be "rc-service dhcpcd start", but I guess yours works too.

----------

## khayyam

 *GSnake wrote:*   

> I'm sorry but I'm here to learn so can I ask you what is a run-level? I started a lot of service under the "default" runlevel but I can't truly understand what it is. How can I make something "start" at boot? (like apps and so on). Currently I'm following the suggestion of Ant. P since it seems to be the best-fitting for me.

 

GSnake ... runlevels are covered in part 2, chapter 4 of the handbook. All, you need understand it that its not simply a matter of starting something at boot, but the dependencies of the services you start. So, for instance, if you start ntpd it will need 'net' in order to function correctly.

The initscripts will state something like the following:

```
depend() {

    provide net

    before dns

}
```

This service if started at the 'default' run-level will 'provide net' ... other services will 'use net', eg:

```
depend() {

    use net dns

}
```

This lays out a dependency stucture for how services are started, and what must be 'provided' before they start.

In your case, as I explaned, something is in the 'default' runlevel that uses 'net', but nothing is providing it and so dhcpcd is started to meet that dependency. Normally 'net' would be provided by 'net.eth0' or 'net.wlan0', or not provided at all if, for example, something like wicd is used to manage the network interfaces.

So, not knowing what services your starting, or what your trying to achieve, I can't really suggest how this should be configured. In my case I have, besides the standard run-levels of 'boot', 'sysinit' and 'default', a runlevel called 'online', this run-level is started only when explicitly called, otherwise no services that require 'net' are started.

 *GSnake wrote:*   

> [I made a file named00dhcpcd.start with "exec dhcpcd" in it. Have I done it right?]

 

I would say no, it will work (perhaps even when you don't want it to), but by putting it in local you are not really taking advantage of run-levels. I would suggest you not have dhcpcd provide 'net' (see above) and have the actual service net.${IFACE} provide this, or have seperate run-levels for 'default' and 'online', but all this is speculative as I can only guess as how the setup is currently configured, and what your trying to do.

best ... khay

----------

## NeddySeagoon

dhcpcd should not be in any runlevel. It will be started by the first interface that needs it.

Its possible to set a timeout for dhcpcd.  Too low and your network will never get set up but the 60 second default is too high.

7 seconds or so should be adequate for wired interfaces.

If you don't mince race conditions and possible lock ups during boot you can set an option in /etc/rc.conf to start things in parallel. See 

```
# WARNING: whilst we have improved parallel, it can still potentially lock

# the boot process. Don't file bugs about this unless you can supply

# patches that fix it without breaking other things!
```

----------

