Building nvme‐cli - linux-nvme/nvme-cli GitHub Wiki

Building nvme-cli

nvme-cli uses meson as its build system. This page covers the common path and per-distro dependency packages. The full reference — install paths, debug and sanitizer builds, plugin selection, the Windows build, distro packaging — lives in Documentation/BUILDING.md in the source tree.

Quick start

$ meson setup .build
$ meson compile -C .build
# meson install -C .build

Since nvme-cli 3.x, libnvme is part of the nvme-cli source tree. You do not need to build or install it separately first, unlike in nvme-cli 2.x.

By default this installs under /usr/local. To install into the paths a Linux distribution normally uses instead:

$ meson setup .build --prefix /usr --sysconfdir /etc

Dependencies

A minimal build needs a C compiler (gcc or clang), ninja, and meson. A few optional libraries unlock extra features. Each is auto-detected by default; pass -D<option>=enabled or -D<option>=disabled to force it:

Library Feature it unlocks
json-c config.json parsing, all vendor plugins, JSON output. Without it, plugins are disabled.
openssl TLS over NVMe-TCP, host authentication
keyutils Key management for NVMe-oF authentication
libdbus NVMe-MI endpoint discovery (disabled by default)
liburing Get-log-page via io_uring (disabled by default)
python Python bindings for libnvme

For the full option list, including meson's own built-in options, run:

$ meson configure .build

Building specific plugins

By default every vendor plugin is built. To build only some of them:

$ meson setup .build -Dplugins=intel,wdc,ocp

Minimal static build with muon

Older distributions may ship a meson version too old for nvme-cli. muon is an implementation of the meson build system in C99, with far fewer dependencies than meson itself. scripts/build.sh drives it for you:

$ scripts/build.sh -m muon

This needs only:

  • make
  • gcc
  • git

and produces a static binary. It downloads and builds muon and samurai (its ninja replacement) as part of the build.

For some older distributions, additional packages need to be installed first; see the sections below.

Per-distribution setup

Fedora

# dnf install json-c-devel openssl-devel keyutils-libs-devel dbus-devel python3-devel

CentOS Stream 9

$ dnf config-manager --set-enabled powertools
$ dnf search glibc
$ dnf provides */libc.a
$ dnf install glibc-static

Ubuntu 24.04

Dependencies if using meson directly:

$ sudo apt install gcc make git
$ sudo pip3 install meson
$ sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build
$ sudo apt install cmake swig libjson-c-dev libssl-dev libkeyutils-dev pkg-config

SUSE Linux Enterprise 15 Service Pack 7

# zypper install git meson gcc libjson-c-devel keyutils-devel openssl-devel

EOL distributions

These are unsupported for the muon minimal build, but are included here for reference:

CentOS 8

$ dnf config-manager --set-enabled powertools
$ dnf search glibc
$ dnf provides */libc.a
$ dnf install glibc-static

CentOS 7

$ yum install glibc-static
⚠️ **GitHub.com Fallback** ⚠️