# [SOLVED] Issues with networkmanager launching on OpenRC

## owenwastaken

Networkmanager fails to launch on system init and I get this error if I try to start it manually. Im still semi new to Gentoo so I am not sure how to fix this. 

```
$ rc-service NetworkManager start -v

* Executing /lib/rc/sh/openrc-run.sh /lib/rc/sh/openrc-run.sh /etc/init.d/NetworkManager start

* Starting NetworkManager ...

* start-stop-dameon: fopen '/run/NetworkManager/NetworkManager.pid': No such file or directory

* Detaching to start '/usr/sbin/NetworkManager' ...

* start-stop-dameon: failed to start '/usr/sbin/NetworkManager'

* ERROR: NetworkManager failed to start
```

Last edited by owenwastaken on Sat Jun 19, 2021 1:47 pm; edited 2 times in total

----------

## alamahant

Hi

```

USE="elogind" emerge -1av networkmanager

```

If ok make it permanent via package.use

OR better add universal USE="...... elogind"

in make.conf

and

```

emerge -uDNav @world

```

Welcome to Gentoo!

----------

## Hu

alamahant: I think USE=elogind is already default-enabled on many of the common profiles.  From the OP's error message, I do not see why having USE=elogind would be the answer, even if it was currently set in the wrong direction.  Could you explain why you want OP to change this?

----------

## alamahant

Yes HU

I possibly mistakenly felt that 

```
start-stop-dameon: fopen '/run/NetworkManager/NetworkManager.pid': No such file or directory
```

was somehow connected to the absence of elogind.

Plz forgive my mistake.

I confused /run/user with /runNetworkManager.

 :Smile: 

----------

## Fitzcarraldo

owenwastaken,

How precisely did you install and configure NetworkManager? Below is the method I use.

I installed the package with the following USE flags enabled:

bluetooth dhclient elogind introspection modemmanager ncurses nss policykit ppp wext wifi

and the following USE flags disabled:

audit connection-sharing dhcpcd gnutls iwd json ofono ovs resolvconf selinux systemd teamd test vala

The precise status can be seen in the output of the eix command on my main laptop that uses Gentoo Stable:

```
# eix -I net-misc/networkmanager

[I] net-misc/networkmanager

     Available versions:  [M]~1.22.10-r12^t 1.26.4^t ~1.26.6^t ~1.28.0-r1^t {audit bluetooth +concheck connection-sharing debug (+)dhclient dhcpcd elogind examples (+)gnutls gtk-doc (+)introspection iwd json libpsl lto (+)modemmanager ncurses (+)nss ofono ovs (+)policykit (+)ppp resolvconf selinux syslog systemd teamd test +tools vala (+)wext +wifi ABI_MIPS="n32 n64 o32" ABI_S390="32 64" ABI_X86="32 64 x32" KERNEL="linux"}

     Installed versions:  1.26.4^t(00:33:18 02/01/21)(bluetooth dhclient elogind introspection modemmanager ncurses nss policykit ppp wext wifi -audit -connection-sharing -dhcpcd -gnutls -iwd -json -ofono -ovs -resolvconf -selinux -systemd -teamd -test -vala ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="64 -32 -x32" KERNEL="linux")

     Homepage:            https://wiki.gnome.org/Projects/NetworkManager

     Description:         A set of co-operative tools that make networking simple and straightforward
```

I use network file systems, so I also configured the netmount service to run, and specified that NetworkManager is the network manager:

```
# grep -v "^#\|^$" /etc/conf.d/netmount

rc_need="NetworkManager"
```

The network-related services that I configured to be started at boot are as follows:

```
# rc-update show -v | grep -i net

       NetworkManager |      default

                local |      default nonetwork

           net-online |

         net.enp4s0f1 |

               net.lo |

             netmount |      default
```

(It is correct that net-online, net.enp4s0f1 and net.lo are not in any runlevel.)

Neither dhcpd nor dhcpcd services must be started at boot, as they would interfere with NetworkManager:

```
# rc-update show -v | grep -i dhcp

               dhcpcd |   

                dhcpd |

```

By the way, if the output of the command 'rc-update show -v' incudes non-existent physical interfaces not shown in the output of the 'ifconfig' or 'ip a' commands, you can delete the corresponding symlinks. For example, the only physical interfaces listed by the ifconfig command on my older laptop running Gentoo Linux Testing (~amd64) are eth0 and wlan0, but the 'rc-update show -v' command originally showed many other interfaces, so I deleted them as follows (change the commands to suit the unneeded files in your case):

```
# cd /etc/init.d/

# rm net.aol

# rm net.ra*

# rm net.ath*

# rm net.eth[1,2,3,4,5,6,7,8]

# rm net.ppp*

# rm net.wlan[1,2,3]
```

The installation on that laptop is left with the correct symlinks:

```
# ls -la /etc/init.d/net.*

lrwxrwxrwx 1 root root     6 Mar 30  2010 /etc/init.d/net.eth0 -> net.lo

-rwxr-xr-x 1 root root 19861 Feb 15 01:05 /etc/init.d/net.lo

lrwxrwxrwx 1 root root     6 Mar 30  2010 /etc/init.d/net.wlan0 -> net.lo
```

Anyway, coming back to my main laptop, all the services running in Gentoo Linux on it are shown below, for information:

```
# rc-status

Runlevel: default

 dbus                                                       [  started  ]

 NetworkManager                                             [  started  ]

 netmount                                                   [  started  ]

 syslog-ng                                                  [  started  ]

 cupsd                                                      [  started  ]

 samba                                                      [  started  ]

 cronie                                                     [  started  ]

 clamd                                                      [  started  ]

 bluetooth                                                  [  started  ]

 xdm                                                        [  started  ]

 wsdd                                                       [  started  ]

 cups-browsed                                               [  started  ]

 sshd                                                       [  started  ]

 local                                                      [  started  ]

Dynamic Runlevel: hotplugged

Dynamic Runlevel: needed/wanted

 xdm-setup                                                  [  started  ]

 avahi-daemon                                               [  started  ]

Dynamic Runlevel: manual

```

I specified the laptop's hostname in /etc/hosts, /etc/conf.d/hostname, /etc/hostname and /etc/dhcp/dhclient.conf:

```
# grep -v "^#\|^$" /etc/hosts

127.0.0.1       clevow230ss     localhost

::1             clevow230ss     localhost
```

```
# cat /etc/conf.d/hostname

# Set to the hostname of this machine

hostname="clevow230ss"
```

```
# cat /etc/hostname

clevow230ss
```

```
# grep -v "^#\|^$" /etc/dhcp/dhclient.conf

send host-name "clevow230ss";

supersede host-name "clevow230ss";
```

The purpose of the 'supersede' statement in dhclient.conf is explained in man dhclient.conf(5):

 *Quote:*   

>     supersede [ option declaration ] ;
> 
>     If for some option the client should always use a locally-configured value or values rather than whatever is supplied by the server, these values can be defined in the supersede statement.
> 
> 

 

In other words, I do not want the hostname to be specified by a dhcp server (as this has caused problems for me in the past when connected to some networks).

I edited the configuration file /etc/NetworkManager/NetworkManager.conf to contain the following:

```
[main]

plugins=keyfile

rc-manager=none

dhcp=dhclient

no-auto-default=*

 

[keyfile]

hostname=clevow230ss
```

In earlier days it was necessary to specify the hostname in /etc/NetworkManager/NetworkManager.conf but that is no longer required. According to NetworkManager.conf(5) man page: 'This key is deprecated and has no effect since the hostname is now stored in /etc/hostname or other system configuration files according to build options.' I just left it in the file because it does no harm.

NetworkManager's configuration files for your wired and wireless connections are normally created and edited by using the GUI network configuration tool (a.k.a. 'front end') in the Desktop Environment, such as plasma-nm and nm-applet, but can also be created/edited manually. For example, the NetworkManager file for my home Wi-Fi connection contains the following:

```
# cat /etc/NetworkManager/system-connections/BT-5DF82T.nmconnection

[connection]

id=BT-5DF82T

uuid=3190e9d6-961f-38ab-fb90-1d323e6f35d2

type=wifi

autoconnect=false

permissions=

[wifi]

mac-address-blacklist=

mode=infrastructure

ssid=BT-5DF82T

[wifi-security]

key-mgmt=wpa-psk

psk-flags=1

[ipv4]

dns-search=

method=auto

[ipv6]

addr-gen-mode=stable-privacy

dns-search=

method=auto
```

NetworkManager generates the UUID automatically, but it could be generated manually (I have never bothered to do that):

 *Quote:*   

>     The UUID values in the config files must be unique. You can use uuidgen command line tool to generate such values. Alternatively, you can leave out UUID entirely. In that case NetworkManager will generate a UUID based on the file name.

 

----------

## owenwastaken

After a complete re-installation of Gentoo, Networkmanager works properly using the following use flags

```
dhclient elogind introspection modemmanager ncurses policykit wext wifi -audit -bluetooth -connection-sharing -dhcpcd -gnutils -iwd -json -ofono -ovs --ppp resolvconf -selinux -systemd -temd -test -vala
```

I am pretty sure the issue was that netifrc or some other network program was conflicting with networkmanager.

----------

