How to install a device driver for Mellanox ConnectX-4 Ethernet card on Linux

Question: I installed a Mellanox ConnectX-4 Lx EN Ethernet card on my Linux server, but the NIC card is not recognized by the system. How can I install a driver for Mellanox ConnectX-4 NIC on [insert Linux distro]?

Mellanox provides a wide range of high-speed interconnection solutions including Gigabit Ethernet cards and InfiniBand adapter cards. ConnectX-4 EN is one of Mellanox' flagship Ethernet adapters offering 10/25/40/50/100GbE speed. To meet the stringent demand of today's data center interconnection environments, Mellanox ConnectX-4 provides a multitude of powerful features such as SR-IOV I/O virtualization, NVGRE/VxLAN hardware offload, RDMA over Converged Ethernet, Erasure Coding offload, etc.

As of today device drivers for Mellanox ConnectX product series are not part of Linux distributions. Therefore if you want to use a ConnectX card (e.g., ConnectX-4 Lx EN), you need to build and install the driver.

Fortunately, Mellanox does a pretty good job making sure that their NIC card is accessible on all major operating system platforms via up-to-date drivers.

Here is how to compile and install Mellanox ConnectX-4 EN driver (mlx4_en) on Linux. Other Mellanox card drivers can be installed in a similar fashion.


Before building the Mellanox driver, first set up a necessary build environment by installing dependencies as follows.

Install dependencies on Debian, Ubuntu or Linux Mint

$ sudo apt-get install debhelper autotools-dev dkms zlib1g-dev gcc make patch gcc-c++

Install dependencies on CentOS, Fedora or Red Hat

$ sudo yum install gcc make patch gcc-c++ redhat-rpm-config rpm-build

Install dependencies on OpenSUSE

$ sudo zypper install gcc make patch gcc-c++ kernel-syms

Compile and Install Mellanox ConnectX-4 Driver

Download the latest device driver for Mellanox ConnectX-4 card from the official website. The driver's tarball contains the device driver's source code as well as the latest NIC firmware.

Extract the tarball, and run the installation script ( as root.

$ tar -xf mlnx-en-3.3-
$ cd mlnx-en-3.3-
$ sudo ./

The script builds the Mellanox NIC driver from the source, and installs it.

Once installation is completed, the script then queries the Mellanox NIC's firmware, and updates outdated firmware automatically.

Finally, any previously installed mlnx module is unloaded and the new Mellanox NIC driver is loaded.

The installed NIC driver for Mellanox ConnectX-4 EN is named mlx4_en. Verify that is is successfully loaded as follows.

$ lsmod | grep mlx4
$ modinfo mlx4_en

Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

Leave a comment

Your email address will not be published. Required fields are marked *