How to Set Up and Benchmark NVMe over TCP on Ubuntu 24.04

What You’ll Build

In this tutorial, you’ll connect two Ubuntu 24.04 servers over a private Ethernet network so that one server can use an NVMe SSD installed in the other. You’ll then use fio to compare end-to-end read latency and sequential throughput for local and remote access to the same SSD.

For an overview of how TCP, RDMA, and Fibre Channel carry NVMe traffic, see our guide to NVMe over Fabrics.

Server Role What it does
Server A Storage target Holds the spare NVMe SSD and exposes it over TCP as an NVMe namespace — a block device the other server can access.
Server B Initiator Connects to the target and uses the remote namespace as a Linux block device.

You’ll start on Server A by measuring read performance on the SSD while it’s locally attached. After configuring the target, you’ll use nvme-cli on Server B to discover it, connect to the namespace, and verify that the connection uses TCP.

Finally, you’ll repeat the same read tests from Server B against the same SSD. Small random reads will show how response times change across the network. Large sequential reads will show how quickly Server B can retrieve a sustained stream of data. By the end, you’ll have a working NVMe/TCP connection and a local-versus-remote comparison measured on your own hardware.

Lab Hardware and Network Requirements

You’ll need two Ubuntu Server 24.04 LTS machines on a private Ethernet network. Only Server A needs a spare NVMe SSD. Server B runs the benchmark against that SSD over TCP. Both servers can use standard Ethernet adapters for this lab.

Requirement Server A — Storage target Server B — Initiator
Operating system Ubuntu Server 24.04 LTS Ubuntu Server 24.04 LTS
Example private IPv4 address 10.10.10.10 10.10.10.20
Storage OS disk plus a spare NVMe SSD reserved for testing OS disk
Kernel module nvmet-tcp to expose the SSD nvme-tcp to connect to it
User-space tools fio for the local benchmark nvme-cli for discovery and connection, fio for the remote benchmark
Access A user with sudo privileges A user with sudo privileges

Choose the test SSD

Use a spare SSD on Server A that contains no data you need. The drive should be unmounted and free of active use by swap, LVM, RAID, or a storage pool. A drive with no mount point can still be in use. Record its model, capacity, and serial number so you can positively identify it before preparing the benchmark region.

Check the private network path

The addresses in the table are examples. Substitute your own private IPs throughout the tutorial. From Server B, check which interface and source address Ubuntu will use to reach Server A.

Bash
ip route get 10.10.10.10

In the output, dev identifies the outgoing interface and src identifies the source IP. With the example addresses, src should be 10.10.10.20, and dev should identify Server B’s private network interface. The tutorial uses TCP port 4420 on Server A’s private address. If a firewall filters traffic between the servers, allow Server B’s private IP to reach that port.

Record the hardware behind your results

Before benchmarking, record the CPU model, running kernel version, and private NIC link speed on each server. Use lscpu for the CPU model and uname -r for the kernel version. On a physical Ethernet interface, ethtool <interface> reports the negotiated link speed when the driver exposes it.

For hosted bare metal, also record any provider-imposed private network bandwidth cap. For example, a NIC can negotiate at 25 Gbps while the private network service is limited to 10 Gbps. That distinction matters when you interpret sequential-read throughput.

Step 1 Identify the Test SSD and Measure Local NVMe Performance

Run this section on Server A, before exposing the SSD over TCP. You’ll measure three workloads directly against the drive and save the results. Later, you’ll repeat those workloads from Server B against the same region of the same SSD. This gives you a baseline for comparing local and remote reads.

1. Identify the spare NVMe SSD

List the disks, their partitions, and the device backing the root filesystem.

Bash
lsblk -o NAME,TYPE,SIZE,MODEL,SERIAL,FSTYPE,MOUNTPOINTS
findmnt -no SOURCE /
swapon --show

Follow the lsblk tree to identify the physical disk behind /, including any LVM or RAID layers. Then locate the spare SSD by its model, capacity, and serial number. Check the entire device tree for mounted partitions, swap, and storage-pool membership. If the server uses ZFS, also check zpool status -P for pool members.

List the persistent NVMe device names:

Bash
ls -l /dev/disk/by-id/nvme-*

Set TEST_DEVICE to the whole-drive entry for your spare SSD. Replace the placeholder below with the exact entry from your server. An entry ending in -part1, for example, identifies a partition.

Bash
TEST_DEVICE='/dev/disk/by-id/REPLACE_WITH_YOUR_SPARE_NVME_ID'

readlink -e "$TEST_DEVICE"
lsblk -o NAME,TYPE,SIZE,MODEL,SERIAL,FSTYPE,MOUNTPOINTS "$TEST_DEVICE"

Continue only after the resolved device and serial number match the spare SSD you reserved for this lab. Keep the same shell open so TEST_DEVICE remains set.

2. Select a populated test region

The example uses a 16 GiB region starting 1 GiB into the drive, so the test SSD must be at least 17 GiB. Use a region that already contains written data. An SSD can answer reads from freshly discarded or unwritten blocks unusually quickly, which can make the baseline misleading.

If that region already contains test data, skip the preparation write below. Install fio and record its version for the later comparison.

Bash
sudo apt update
sudo apt install -y fio
fio --version

For a blank, disposable test SSD only: The following command overwrites the entire 16 GiB test region. It can destroy filesystem data even if the disk is unmounted. Recheck the serial number before running it. Prepare the region once on Server A and use those same blocks for both sets of read tests.

Bash
sudo fio --name=prepare-test-region \
  --filename="$TEST_DEVICE" \
  --offset=1G --size=16G \
  --rw=write --bs=1M \
  --ioengine=io_uring --iodepth=16 --direct=1 \
  --refill_buffers=1 --end_fsync=1

3. Run the three read-only benchmarks

Create a fio job file so you can reuse the exact workload settings on Server B. The stonewall option runs each workload after the previous one finishes. Each gets a 10-second warm-up followed by 60 seconds of measurement. direct=1 bypasses the Linux page cache, and lat_percentiles=1 requests total I/O latency percentiles.

Bash
cat > nvme-reads.fio <<'EOF'
[global]
ioengine=io_uring
direct=1
numjobs=1
offset=1G
size=16G
time_based=1
ramp_time=10
runtime=60
lat_percentiles=1
percentile_list=50:99

[random-read-4k-qd1]
rw=randread
bs=4k
iodepth=1

[random-read-4k-qd32]
stonewall
rw=randread
bs=4k
iodepth=32

[sequential-read-1m-qd16]
stonewall
rw=read
bs=1M
iodepth=16
EOF

Run the job three times while the SSD is otherwise idle. --readonly adds a guard against write workloads. Each run saves its own JSON result.

Bash
for run in 1 2 3; do
  sudo fio --readonly --filename="$TEST_DEVICE" \
    --output-format=json --output="local-run-${run}.json" \
    nvme-reads.fio || break
done

4. Read and save the baseline

The following command prints one row per workload from each completed run. It converts bandwidth to MiB/s and total latency to microseconds.

Bash
python3 - <<'PY'
import glob
import json

print("Run file           Workload                    IOPS    MiB/s   p50 µs   p99 µs")
for path in sorted(glob.glob("local-run-*.json")):
    with open(path) as result:
        jobs = json.load(result)["jobs"]
    for job in jobs:
        if job["error"]:
            raise SystemExit(f"{path}: {job['jobname']} failed with error {job['error']}")
        read = job["read"]
        pct = read["lat_ns"]["percentile"]
        print(f"{path:<18} {job['jobname']:<24} {read['iops']:8.0f} "
              f"{read['bw_bytes'] / 2**20:8.1f} "
              f"{pct['50.000000'] / 1000:8.1f} {pct['99.000000'] / 1000:8.1f}")
PY

You should have nine rows — three workloads across three runs. For the 4 KiB QD1 test, record p50 and p99 latency to see how quickly an individual read completes. For 4 KiB QD32, read IOPS alongside p99 latency to see what happens under concurrency. For the 1 MiB sequential test, record throughput in MiB/s.

Keep nvme-reads.fio and all three JSON files. For each metric, use the median of its three run values when you compare Server A with Server B. The difference will show the end-to-end effect of accessing this drive remotely, including the network path and processing on both hosts.

Step 2 Configure the NVMe/TCP Target on Server A

With the local benchmark saved, you can expose the same SSD over the private network. On Server A, you’ll create an NVMe subsystem, attach the spare SSD as namespace 1, and bind the subsystem to 10.10.10.10:4420. You’ll also add Server B’s host identifier to the subsystem’s allowlist. Linux exposes these target settings through configfs.

1. Get the host NQN from Server B

Run on Server B. The host NVMe Qualified Name (NQN) identifies the initiator. Install nvme-cli, then print the host NQN that Server B will use when connecting.

Bash
sudo apt update
sudo apt install -y nvme-cli
sudo cat /etc/nvme/hostnqn

Copy the complete line beginning with nqn.. The host NQN identifies Server B. The subsystem NQN you create below identifies the storage that Server B will connect to.

2. Confirm the SSD and private address on Server A

Run the remaining commands on Server A, in the shell where you set TEST_DEVICE for the local benchmark. Replace the example IP if your private network uses a different address.

Bash
TARGET_IP='10.10.10.10'
SUBSYS_NQN='nqn.2026-12.com.example:nvme-lab.ssd1'
read -r -p "Paste Server B's host NQN: " HOST_NQN

lsblk -o NAME,TYPE,SIZE,MODEL,SERIAL,FSTYPE,MOUNTPOINTS \
  "${TEST_DEVICE:?Set TEST_DEVICE to the verified spare SSD first}"

ip -4 -brief address show

Match the SSD serial number to your baseline record and confirm that TARGET_IP belongs to Server A’s private interface. The namespace will expose the whole drive, even though the benchmark reads only a 16 GiB region. Keep that drive unmounted and out of local use while Server B has access.

The subsystem NQN above is an example for this lab. Keep the value you choose because Server B will use that exact string in the connection step.

3. Create the namespace and bind the private listener

Run on Server A. This block assumes a fresh lab target and uses configfs port ID 1. The port ID is a local configuration number. Clients connect to TCP port 4420. The script checks that the subsystem and configfs port are unused before creating either one, then links the subsystem to the listener as its final step.

Bash
sudo bash -s -- "$TEST_DEVICE" "$TARGET_IP" "$SUBSYS_NQN" "$HOST_NQN" <<'TARGET_SETUP'
set -euo pipefail

device=$1
target_ip=$2
subsys_nqn=$3
host_nqn=$4

root=/sys/kernel/config/nvmet
subsystem="$root/subsystems/$subsys_nqn"
namespace="$subsystem/namespaces/1"
host="$root/hosts/$host_nqn"
port="$root/ports/1"

[[ -b "$device" ]] || { echo "Test SSD is not a block device."; exit 1; }
[[ "$host_nqn" == nqn.* && "$host_nqn" != */* ]] || {
  echo "Check the host NQN copied from Server B."
  exit 1
}

modprobe nvmet-tcp
mountpoint -q /sys/kernel/config || mount -t configfs none /sys/kernel/config

if [[ -e "$subsystem" || -e "$port" ]]; then
  echo "The subsystem or configfs port 1 already exists. Inspect it before continuing."
  exit 1
fi

mkdir "$subsystem"
printf '0' > "$subsystem/attr_allow_any_host"
mkdir -p "$host"
ln -s "$host" "$subsystem/allowed_hosts/$host_nqn"

mkdir "$namespace"
printf '%s' "$device" > "$namespace/device_path"
printf '1' > "$namespace/enable"

mkdir "$port"
printf 'tcp' > "$port/addr_trtype"
printf 'ipv4' > "$port/addr_adrfam"
printf '%s' "$target_ip" > "$port/addr_traddr"
printf '4420' > "$port/addr_trsvcid"
ln -s "$subsystem" "$port/subsystems/$subsys_nqn"
TARGET_SETUP

The allowlist matches the host NQN presented by the initiator. Keep the listener on the private network and restrict inbound TCP 4420 to Server B’s private IP in the applicable firewall. An NQN is an identifier and can be copied.

4. Verify the target before connecting a client

Run on Server A.

Bash
SUBSYSTEM="/sys/kernel/config/nvmet/subsystems/$SUBSYS_NQN"

sudo cat "$SUBSYSTEM/namespaces/1/device_path"
sudo cat "$SUBSYSTEM/namespaces/1/enable"
sudo cat "$SUBSYSTEM/attr_allow_any_host"
sudo ls -1 "$SUBSYSTEM/allowed_hosts"
sudo ls -1 /sys/kernel/config/nvmet/ports/1/subsystems
sudo ss -lnt 'sport = :4420'
Check Expected result
Namespace device path The same spare SSD path used for the local baseline
Namespace enabled 1
Allow any host 0
Allowed hosts Server B’s exact host NQN
Subsystem attached to port 1 The value of SUBSYS_NQN
TCP listener LISTEN on Server A’s private address, such as 10.10.10.10:4420

These checks confirm the server-side configuration. Leave Server A running with the SSD unmounted. The configuration is currently held in configfs; reboot persistence is covered later in the tutorial.

Step 3 Discover and Connect to the NVMe/TCP Target from Server B

Run all commands in this section on Server B, the initiator. You’ll use nvme discover to find the storage subsystem that Server A exposes, then nvme connect to establish a connection to that subsystem.

1. Load the NVMe/TCP initiator driver

Use the nvme-cli package installed in the previous section. Set TARGET_IP to Server A’s private address and TARGET_PORT to the TCP port configured on its listener.

Bash
TARGET_IP='10.10.10.10'
TARGET_PORT='4420'

sudo modprobe nvme-tcp

2. Discover the storage subsystem

Query Server A’s discovery log over the private network.

Bash
sudo nvme discover -t tcp -a "$TARGET_IP" -s "$TARGET_PORT"

Find the entry whose subtype is nvme subsystem. For the example configuration, these are the fields to match:

Discovery field Expected value
trtype tcp
traddr 10.10.10.10
trsvcid 4420
subnqn nqn.2026-12.com.example:nvme-lab.ssd1

The subnqn field is the value you need for the connection. If the expected subsystem is missing, check that Server A linked it to the listener and that its allowed_hosts entry matches Server B’s /etc/nvme/hostnqn.

3. Connect using the discovered subsystem NQN

Set SUBSYS_NQN to the exact subnqn from your discovery output. If you chose a custom name on Server A, use that name here.

Bash
SUBSYS_NQN='nqn.2026-12.com.example:nvme-lab.ssd1'

sudo nvme connect -t tcp -a "$TARGET_IP" -s "$TARGET_PORT" -n "$SUBSYS_NQN"

Check the connection from Server B:

Bash
sudo nvme list-subsys

Locate your subsystem NQN and check the controller line beneath it. It should show the tcp transport, Server A’s private IP, port 4420, and the state live. The controller number is assigned locally and can vary. Leave the namespace unmounted so you can identify the correct block device before benchmarking.

Step 4 Verify the Remote NVMe Device on Server B

A live controller confirms that Server B has connected to Server A. Before running fio, identify the block device for namespace 1. Both local and remote NVMe devices can appear as /dev/nvme… on Linux, so use the subsystem NQN and controller path to identify the correct SSD.

1. Match the subsystem to its namespace

Run on Server B.

Bash
sudo nvme list-subsys
sudo nvme list -v

In nvme list-subsys, find the subsystem NQN you connected to and note the controller on its tcp path. Then use the verbose listing to match that subsystem and controller to the namespace device. For example, your lab might show the following mapping. The controller and device numbers can differ on your server.

What to identify Example value
Subsystem NQN nqn.2026-12.com.example:nvme-lab.ssd1
Controller on the TCP path to Server A nvme2
Namespace ID 1
Namespace block device /dev/nvme2n1

2. Check the namespace ID, capacity, and mount status

Run on Server B. Enter the namespace path you identified above. Keep this shell open so you can reuse REMOTE_DEVICE for the benchmark.

Bash
read -r -p "Enter the verified namespace path on Server B: " REMOTE_DEVICE

sudo nvme get-ns-id "$REMOTE_DEVICE"
lsblk -b -o NAME,TYPE,SIZE,FSTYPE,MOUNTPOINTS "$REMOTE_DEVICE"
sudo blockdev --getsize64 "$REMOTE_DEVICE"

Confirm that the namespace ID is 1, the whole device appears as TYPE disk, and the MOUNTPOINTS column is empty for the disk and any partitions. The blockdev command reports the capacity in bytes, which you can compare directly with the backing SSD.

Run on Server A in the shell where you set TEST_DEVICE:

Bash
sudo blockdev --getsize64 "$TEST_DEVICE"

The two byte counts should match exactly because this lab exports the entire SSD. The 16 GiB selected earlier is only the benchmark region. If the capacities differ, recheck the subsystem-to-namespace mapping before continuing.

Leave the SSD unmounted on both servers. The remote read benchmark will use REMOTE_DEVICE on Server B to read the same populated blocks used for the local baseline.

Step 5 Benchmark Local NVMe vs NVMe/TCP with fio

How much does remote access change read latency and throughput? To measure it, run the same three workloads from Server B against the namespace you just verified. Use the original nvme-reads.fio file from Server A so that the block sizes, queue depths, runtime, and 16 GiB test region stay identical. The region already contains the baseline data, so you can go straight to read testing.

1. Copy the baseline and job file to Server B

Run on Server B in the shell where you set REMOTE_DEVICE. Install fio and display its version. For the closest comparison, use the same version you recorded on Server A.

Bash
sudo apt install -y fio
fio --version

Create a fresh results directory. Replace labuser and the example directory with the SSH account and absolute path containing the baseline files on Server A.

Bash
RESULTS_DIR=$(mktemp -d "$HOME/nvme-tcp-results.XXXXXX")
cd "$RESULTS_DIR"

BASELINE_SOURCE='[email protected]:/home/labuser/nvme-baseline'

scp "$BASELINE_SOURCE/nvme-reads.fio" .
for run in 1 2 3; do
  scp "$BASELINE_SOURCE/local-run-${run}.json" . || break
done

ls -lh nvme-reads.fio local-run-{1,2,3}.json

Confirm that the job file and all three local results are present before proceeding.

2. Run the remote read tests

Run on Server B. Confirm that REMOTE_DEVICE still points to the verified namespace. Keep other disk and network activity low on both servers during the comparison.

Bash
lsblk -b -o NAME,TYPE,SIZE,MOUNTPOINTS \
  "${REMOTE_DEVICE:?Set REMOTE_DEVICE to the verified namespace first}"

Run the same job three times, saving each result separately. --readonly prevents fio from running a write workload. Allow about 11 minutes for all three runs, including warm-up periods.

Bash
for run in 1 2 3; do
  sudo fio --readonly --filename="$REMOTE_DEVICE" \
    --output-format=json --output="remote-run-${run}.json" \
    nvme-reads.fio || break
done

3. Compare the local and remote results

Run the following in the results directory on Server B. It reads all six JSON files and prints the median of the three runs for each metric. The latency values come from fio’s total read latency field and are displayed in microseconds.

Bash
python3 - <<'PY'
import json
from statistics import median

workloads = [
    "random-read-4k-qd1",
    "random-read-4k-qd32",
    "sequential-read-1m-qd16",
]

print(f"{'Workload':<24} {'Path':<7} {'IOPS':>10} {'MiB/s':>9} "
      f"{'p50 µs':>9} {'p99 µs':>9}")

for path in ("local", "remote"):
    samples = {name: [] for name in workloads}
    for run in range(1, 4):
        filename = f"{path}-run-{run}.json"
        with open(filename) as result:
            jobs = {job["jobname"]: job for job in json.load(result)["jobs"]}
        for name in workloads:
            job = jobs[name]
            if job["error"]:
                raise SystemExit(f"{filename}: {name} failed with error {job['error']}")
            read = job["read"]
            pct = read["lat_ns"]["percentile"]
            samples[name].append((
                read["iops"],
                read["bw_bytes"] / 2**20,
                pct["50.000000"] / 1000,
                pct["99.000000"] / 1000,
            ))

    for name, runs in samples.items():
        iops, bandwidth, p50, p99 = map(median, zip(*runs))
        print(f"{name:<24} {path:<7} {iops:10.0f} {bandwidth:9.1f} "
              f"{p50:9.1f} {p99:9.1f}")
PY

4. Interpret the comparison

Workload Compare What the difference tells you
4 KiB random read, QD1 Local and remote p50 and p99 With one read outstanding, subtract local p50 from remote p50 to estimate the change in typical application-visible read latency. The difference includes processing on both hosts and the network path.
4 KiB random read, QD32 IOPS alongside p99 IOPS measures completed reads per second. The p99 latency is the time within which approximately 99% of reads complete. Similar IOPS can coexist with a higher remote p99.
1 MiB sequential read, QD16 MiB/s against the local baseline and private link capacity Shows whether Server B can consume data as quickly as Server A reads it locally. A 10 Gbit/s link has a theoretical ceiling of about 1,192 MiB/s before protocol overhead.

Read the QD1 and sequential results together. If remote sequential throughput approaches the private link ceiling while QD1 latency rises, both observations can be true: the link can carry a large stream efficiently even though each individual read takes longer to complete. If throughput falls well below both the local baseline and the link ceiling, inspect CPU utilization on both hosts and competing traffic before attributing the gap to the SSD.

Keep the six raw results alongside the summary. If one run has a noticeably higher p99 than the other two, report that spread with the median so readers can see how consistently the setup performed.

Step 6 Reconnect NVMe/TCP After a Reboot

Two things must happen after a reboot. Server A must export the same SSD with the same subsystem NQN and host allowlist. Server B must reconnect to that subsystem. For this two-server lab, use one systemd service on each host so you can verify each side independently.

1. Save the target configuration on Server A

Run on Server A, using the shell from the target setup section. Confirm that the saved device is the persistent /dev/disk/by-id/… path you verified against the SSD serial number.

Bash
printf 'SSD:       %s\nTarget IP: %s\nSubsystem: %s\nHost NQN:  %s\n' \
  "${TEST_DEVICE:?Set the verified SSD path}" \
  "${TARGET_IP:?Set the private target IP}" \
  "${SUBSYS_NQN:?Set the subsystem NQN}" \
  "${HOST_NQN:?Set the host NQN for Server B}"

sudo install -d -m 0755 /etc/nvme-tcp-lab
printf 'TEST_DEVICE=%q\nTARGET_IP=%q\nSUBSYS_NQN=%q\nHOST_NQN=%q\n' \
  "$TEST_DEVICE" "$TARGET_IP" "$SUBSYS_NQN" "$HOST_NQN" |
  sudo tee /etc/nvme-tcp-lab/target.env >/dev/null

Create the startup script:

Bash
sudoedit /usr/local/sbin/nvme-lab-target

Start the file with these three lines:

Bash
#!/bin/bash
source /etc/nvme-tcp-lab/target.env
set -- "$TEST_DEVICE" "$TARGET_IP" "$SUBSYS_NQN" "$HOST_NQN"

Immediately below them, paste the body of the target setup script from Configure the NVMe/TCP Target on Server A, starting at set -euo pipefail and ending with ln -s "$subsystem" "$port/subsystems/$subsys_nqn". Omit the surrounding sudo bash … <<'TARGET_SETUP' line and the closing TARGET_SETUP marker. This reuses the same namespace, private listener, and host allowlist you configured earlier.

Save the file, check its shell syntax, and make it executable:

Bash
sudo bash -n /usr/local/sbin/nvme-lab-target
sudo chmod 0755 /usr/local/sbin/nvme-lab-target

2. Enable target restoration at boot

Run on Server A. Generate a systemd device unit name from the persistent SSD path. This makes the service wait for the specific backing device before attempting to export it.

Bash
SSD_UNIT=$(systemd-escape --path --suffix=device "$TEST_DEVICE")

sudo tee /etc/systemd/system/nvme-lab-target.service >/dev/null <<EOF
[Unit]
Description=Export the lab SSD over NVMe/TCP
Wants=network-online.target
Requires=$SSD_UNIT
After=network-online.target $SSD_UNIT

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/nvme-lab-target
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable nvme-lab-target.service

The target is already active from the manual setup, so enable the service for the next boot. Starting it now would encounter the subsystem and port that already exist.

3. Enable the initiator connection on Server B

Run on Server B. Set the private address and subsystem NQN to the exact values from your successful discovery step. Keep the existing /etc/nvme/hostnqn so Server B continues to match Server A’s allowlist.

Bash
TARGET_IP='10.10.10.10'
SUBSYS_NQN='nqn.2026-12.com.example:nvme-lab.ssd1'
NVME_BIN=$(command -v nvme)

Create the connection service:

Bash
sudo tee /etc/systemd/system/nvme-lab-connect.service >/dev/null <<EOF
[Unit]
Description=Connect to the lab NVMe/TCP subsystem
Wants=network-online.target
After=network-online.target
StartLimitIntervalSec=0

[Service]
Type=oneshot
ExecStartPre=/sbin/modprobe nvme-tcp
ExecStart=$NVME_BIN connect -t tcp -a $TARGET_IP -s 4420 -n $SUBSYS_NQN
ExecStop=$NVME_BIN disconnect -n $SUBSYS_NQN
RemainAfterExit=yes
Restart=on-failure
RestartSec=15s

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable nvme-lab-connect.service

If Server B boots first, the service retries a failed initial connection after 15 seconds. Once the connection succeeds, use nvme list-subsys to inspect the live storage path. The service’s active (exited) status alone cannot tell you whether that path is currently healthy.

4. Verify both sides with a controlled reboot

Use a maintenance window for the two lab machines. Finish any fio jobs and confirm the namespace is still unmounted. Then test the target and initiator in order.

  1. On Server B, disconnect the manually established session with sudo nvme disconnect -n "$SUBSYS_NQN".
  2. Reboot Server A. After it returns, run systemctl status nvme-lab-target.service --no-pager and sudo ss -lnt 'sport = :4420'. Confirm that the service succeeded and that the listener is bound to Server A’s private IP.
  3. Reboot Server B. After it returns, run systemctl status nvme-lab-connect.service --no-pager and sudo nvme list-subsys. Find your subsystem NQN and confirm that its TCP path shows Server A’s address, port 4420, and state live.
  4. Re-identify namespace 1 with sudo nvme list -v before using fio again. The /dev/nvme… number can change across boots.

If either check fails, read the corresponding boot log with sudo journalctl -b -u nvme-lab-target.service on Server A or sudo journalctl -b -u nvme-lab-connect.service on Server B. The first failing side tells you whether to investigate SSD export or initiator connection.

Troubleshoot NVMe/TCP Discovery, Connection, and Performance Issues

Start with the first step that fails. If nvme discover returns no matching subsystem, check the listener and access rules. If nvme list-subsys already shows a live TCP path, move directly to namespace verification or benchmark performance.

The commands below use the lab address 10.10.10.10, TCP port 4420, and the example subsystem NQN. If you opened a new shell after reboot, set these variables on the server where you’re running the checks. Substitute your actual values.

Bash
TARGET_IP='10.10.10.10'
SUBSYS_NQN='nqn.2026-12.com.example:nvme-lab.ssd1'

Discovery times out or returns “Connection refused”

On Server B, check which route reaches the target. On Server A, check whether the target is listening.

Host Command What to look for
Server B ip route get "$TARGET_IP" The outgoing private interface and Server B’s expected private source IP
Server A sudo ss -lnt 'sport = :4420' A listener bound to Server A’s private address on port 4420

If Server A has no listener after a reboot, inspect its startup log with sudo journalctl -b -u nvme-lab-target.service. An error opening the backing device points you toward the SSD path. An address-binding error points you toward the private IP configuration.

If the listener and route are correct but discovery still times out, check the host firewall and any provider-side private network rules. The required flow for this lab is Server B’s private IP → Server A’s private IP, TCP 4420. Then retry from Server B:

Bash
sudo nvme discover -t tcp -a "$TARGET_IP" -s 4420

Discovery succeeds, but the subsystem is missing or the host is rejected

On Server B, read the initiator identity:

Bash
sudo cat /etc/nvme/hostnqn

On Server A, inspect the subsystem’s allowed hosts and its link to the listener:

Bash
TARGET_ROOT=/sys/kernel/config/nvmet

sudo ls -1 "$TARGET_ROOT/subsystems/$SUBSYS_NQN/allowed_hosts"
sudo ls -1 "$TARGET_ROOT/ports/1/subsystems"

The first listing should contain Server B’s exact host NQN. The second should contain Server A’s subsystem NQN. These identifiers serve different purposes. A common copy-and-paste mistake is passing the host NQN to nvme connect -n, which expects the subsystem NQN returned by discovery.

If Server B was reinstalled and its host NQN changed, verify its new identity and update the target allowlist. Also update HOST_NQN in Server A’s /etc/nvme-tcp-lab/target.env so the correct mapping returns after reboot.

The controller is live, but the expected SSD is missing

On Server B, run sudo nvme list-subsys and sudo nvme list -v. Match the subsystem NQN to its TCP controller and namespace 1. The device name may have changed since the previous boot.

If the controller is live but namespace 1 is absent, inspect the namespace on Server A:

Bash
NS_DIR="/sys/kernel/config/nvmet/subsystems/$SUBSYS_NQN/namespaces/1"

sudo cat "$NS_DIR/enable"
sudo cat "$NS_DIR/device_path"

The enabled value should be 1, and the backing path should identify the spare SSD used for the baseline. If either differs, stop before running fio and correct the target mapping. Once the namespace appears on Server B, compare its byte capacity with Server A’s SSD again.

The connection works, but fio is slower than expected

Use the workload that exposed the difference to narrow down the cause.

Benchmark symptom What to check first
4 KiB QD1 latency rises, but sequential throughput is strong Compare local and remote p50 and p99. A small read at queue depth one waits for the entire remote operation to finish. A higher remote latency can coexist with strong sustained bandwidth.
Sequential throughput is close to the private link ceiling Check negotiated NIC speed and the provider’s private bandwidth cap. For example, 10 Gbit/s is about 1,192 MiB/s before overhead. Compare the measured rate against that ceiling and the local SSD baseline.
Sequential throughput is well below both ceilings Check CPU usage on both hosts during the run. Compare ip -s link show dev <private-interface> before and after the test for increasing errors or drops, and check for competing traffic.
Only one run has unusually high p99 latency Inspect that individual JSON result against the other two. Repeat the same job while monitoring background I/O and network activity. Keep the outlying result when reporting the spread.

Before changing queue settings, confirm that both hosts used the same nvme-reads.fio, the same populated 16 GiB region, and the same fio version. Otherwise, a change in workload can look like a change in transport performance.

Step 7 Disconnect the Initiator and Remove the Test Target

Clean up in dependency order. First stop I/O and disconnect Server B. Once the client has released the namespace, remove the listener, namespace, and subsystem from Server A. Keep the benchmark job file and JSON results if you want to reproduce or publish the comparison.

1. Disconnect Server B and disable automatic reconnection

Run on Server B. Finish any fio jobs and confirm that the remote namespace and its partitions have no mount points. If you mounted a filesystem during your own testing, unmount it before disconnecting.

Set the subsystem NQN to the exact value used in your lab:

Bash
SUBSYS_NQN='nqn.2026-12.com.example:nvme-lab.ssd1'
sudo nvme list-subsys

If you installed the reconnect service in the reboot section, disable and stop it:

Bash
sudo systemctl disable --now nvme-lab-connect.service

When the service is active, its ExecStop command disconnects the subsystem. Run sudo nvme list-subsys again. Only if the lab subsystem still has a connected path, disconnect the manually established session:

Bash
sudo nvme disconnect -n "$SUBSYS_NQN"
sudo nvme list-subsys

Check that the TCP path to Server A for this subsystem has disappeared. Other NVMe controllers, including Server B’s local OS drive, should remain visible.

2. Disable target restoration on Server A

Run on Server A. If you installed the target startup service, disable it before changing the live configuration:

Bash
sudo systemctl disable --now nvme-lab-target.service

The target service created in this tutorial has no ExecStop action. Stopping it leaves the live kernel configuration in place, so remove the lab objects explicitly in the next step.

3. Remove the listener, namespace, and subsystem

The commands below assume the layout created in this tutorial: configfs port ID 1, namespace ID 1, and a subsystem dedicated to this lab. Set SUBSYS_NQN to your actual value. Read HOST_NQN from the allowlist so the cleanup uses the same host identity that Server A authorized.

Bash
SUBSYS_NQN='nqn.2026-12.com.example:nvme-lab.ssd1'
ROOT=/sys/kernel/config/nvmet
SUBSYSTEM="$ROOT/subsystems/$SUBSYS_NQN"
PORT="$ROOT/ports/1"

sudo ls -1 "$PORT/subsystems"
sudo ls -1 "$SUBSYSTEM/allowed_hosts"
sudo cat "$SUBSYSTEM/namespaces/1/device_path"

Confirm that the port lists only the lab subsystem, the allowlist contains only Server B’s host NQN, and the backing path matches the spare SSD. Then run:

Bash
HOST_NQN=$(sudo ls -1 "$SUBSYSTEM/allowed_hosts")

sudo bash -s -- "$PORT" "$SUBSYSTEM" "$SUBSYS_NQN" "$HOST_NQN" <<'CLEANUP'
set -euo pipefail

port=$1
subsystem=$2
subsys_nqn=$3
host_nqn=$4

# Detach the subsystem from the listener before removing the namespace.
unlink "$port/subsystems/$subsys_nqn"
rmdir "$port"

printf '0' > "$subsystem/namespaces/1/enable"
rmdir "$subsystem/namespaces/1"

unlink "$subsystem/allowed_hosts/$host_nqn"
rmdir "$subsystem"
CLEANUP

The host identity under /sys/kernel/config/nvmet/hosts/ can be shared by multiple subsystems. If you created it solely for this lab, remove it with sudo rmdir "$ROOT/hosts/$HOST_NQN". Leave Server B’s /etc/nvme/hostnqn in place. These steps remove the NVMe/TCP export while preserving the contents of the backing SSD.

4. Remove the lab startup files and verify cleanup

If you installed the optional reboot services, remove their files on the host where each was created.

Server B

Bash
sudo rm -f /etc/systemd/system/nvme-lab-connect.service
sudo systemctl daemon-reload

Server A

Bash
sudo rm -f /etc/systemd/system/nvme-lab-target.service
sudo rm -f /usr/local/sbin/nvme-lab-target /etc/nvme-tcp-lab/target.env
sudo rmdir /etc/nvme-tcp-lab
sudo systemctl daemon-reload

Finish with two checks. On Server B, sudo nvme list-subsys should show no path to the lab subsystem. On Server A, sudo ss -lnt 'sport = :4420' should show no listener on the lab’s private address. If you added a firewall rule specifically for this test, remove that rule as well.

Your local-run-*.json and remote-run-*.json files now provide a record of how the same SSD performed over both paths. Keep them with nvme-reads.fio, the SSD model, kernel versions, and private link speed so the results can be interpreted and reproduced.

Conclusion

This Ubuntu 24.04 lab shows how to expose an NVMe SSD over a private TCP connection, verify the remote namespace, and compare local and remote reads on the same drive. The most useful result depends on your workload. For applications that issue one small read at a time, compare the 4 KiB queue-depth-one latency. For large file reads, compare sequential throughput against both the local SSD baseline and the private network’s bandwidth limit.

Keep the fio job file and raw results with your hardware and network details. Together, they give you a repeatable baseline for evaluating a faster link, a different SSD, or a kernel upgrade.