Channing He
Channing He
Articles14
Tags8
Categories0
NFS over RDMA  TrueNAS

NFS over RDMA TrueNAS

关键

  • rpcrdma模块加载
  • /proc/fs/nfsd/portlist写入rdma端口

你可以直接输入下面命令下载脚本并执行。

1
curl -o ./load-nfs-rdma.sh https://file.homelabproject.cc/d/local/Server/Src/rdma-tools/load-nfs-rdma.sh

或者自行粘贴

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash

LOGFILE="/var/log/rdma_setup.log"
RDMA_PORT=${RDMA_PORT:-20049}

# Redirect output to log file
exec > >(tee -a "$LOGFILE") 2>&1

echo "Starting RDMA setup script at $(date)"

# Ensure script is run as root
if [ "$(id -u)" -ne 0 ]; then
    echo "This script must be run as root. Please re-run with sudo or as root user." >&2
    exit 1
fi

# Check if the rpcrdma module is available
if ! modinfo rpcrdma &>/dev/null; then
    echo "The rpcrdma module is not available on this system. Please ensure it is installed." >&2
    exit 1
fi

# Check if the rpcrdma module is loaded
if ! lsmod | grep -q "^rpcrdma"; then
    echo "The rpcrdma module is not loaded, loading it now..."
    modprobe rpcrdma
    if [ $? -eq 0 ]; then
        echo "The rpcrdma module was successfully loaded."
    else
        echo "Failed to load the rpcrdma module. Please check permissions or module availability." >&2
        exit 1
    fi
else
    echo "The rpcrdma module is already loaded."
fi

# Check if /proc/fs/nfsd/portlist contains the RDMA port
if ! grep -q "rdma $RDMA_PORT" /proc/fs/nfsd/portlist; then
    echo "'rdma $RDMA_PORT' is not present in /proc/fs/nfsd/portlist, adding it now..."
    echo "rdma $RDMA_PORT" > /proc/fs/nfsd/portlist
    if [ $? -eq 0 ]; then
        echo "'rdma $RDMA_PORT' was successfully added to /proc/fs/nfsd/portlist."
    else
        echo "Failed to write to /proc/fs/nfsd/portlist. Please check permissions." >&2
        exit 1
    fi
else
    echo "'rdma $RDMA_PORT' is already present in /proc/fs/nfsd/portlist."
fi

#echo "RDMA setup script completed successfully at $(date)"

另外可以放入定时任务,自动检测模块加载和端口,确保服务正常

Author:Channing He
Link:https://homelabproject.cc/TrueNAS/NFS%20over%20RDMA%20%20TrueNAS/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可