# NVME Support CONFIG_NVME_CORE=m CONFIG_BLK_DEV_NVME=m # CONFIG_NVME_MULTIPATH is notset # CONFIG_NVME_HWMON is notset CONFIG_NVME_FABRICS=m CONFIG_NVME_FC=m CONFIG_NVME_TCP=m CONFIG_NVME_TARGET=m CONFIG_NVME_TARGET_LOOP=m CONFIG_NVME_TARGET_FC=m # CONFIG_NVME_TARGET_FCLOOP is notset CONFIG_NVME_TARGET_TCP=m # end of NVME Support
2. host端和target端安装nvme-cli
在host端和target端都安装上nvme-cli
1
sudo apt-get install nvme-cli
3. target端配置
首先在target端安装nvmet以及nvmet-tcp模块
1 2
sudo modprobe nvmet sudo modprobe nvmet-tcp
然后使用如下命令去创建一个NVMe Target subsystem和namespace
1 2 3 4 5 6
cd /sys/kernel/config/nvmet/subsystems sudo mkdir nvme-test-target cd nvme-test-target/ echo 1 | sudo tee -a attr_allow_any_host > /dev/null sudo mkdir namespaces/1 cd namespaces/1
找到target端的nvme设备名称,这里是/dev/nvme0n1
1 2 3 4
femu@fvm:~$ sudo nvme list Node SN Model Namespace Usage Format FW Rev ---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- -------- /dev/nvme0n1 vSSD0 FEMU BlackBox-SSD Controller 14.29 GB / 4.29 GB 512 B + 0 B 1.0
将nvme设备/dev/nvme0n1与刚刚创建的子系统进行关联
1 2
echo -n /dev/nvme0n1 |sudo tee -a device_path > /dev/null echo 1|sudo tee -a enable > /dev/null
创建端口号,配置IP和其他参数
1 2 3 4 5 6 7 8
sudo mkdir /sys/kernel/config/nvmet/ports/1 cd /sys/kernel/config/nvmet/ports/1
echo 192.168.123.4 |sudo tee -a addr_traddr > /dev/null
echo tcp|sudo tee -a addr_trtype > /dev/null echo 4420|sudo tee -a addr_trsvcid > /dev/null echo ipv4|sudo tee -a addr_adrfam > /dev/null