Blame Documentation/nvmetcli.txt

Packit 01965a
nvmetcli(8)
Packit 01965a
===========
Packit 01965a
Packit 01965a
NAME
Packit 01965a
----
Packit 01965a
nvmetcli - Configure NVMe-over-Fabrics Target.
Packit 01965a
Packit 01965a
USAGE
Packit 01965a
------
Packit 01965a
[verse]
Packit 01965a
nvmetcli
Packit 01965a
nvmetcli clear
Packit 01965a
nvmetcli restore [filename.json]
Packit 01965a
Packit 01965a
DESCRIPTION
Packit 01965a
-----------
Packit 01965a
*nvmetcli* is a program used for viewing, editing, saving,
Packit 01965a
and starting a Linux kernel NVMe Target, used for an NVMe-over-Fabrics
Packit 01965a
network configuration.  It allows an administrator to export
Packit 01965a
a storage resource (such as NVMe devices, files, and volumes)
Packit 01965a
to a local block device and expose them to remote systems
Packit 01965a
based on the NVMe-over-Fabrics specification from http://www.nvmexpress.org.
Packit 01965a
Packit 01965a
*nvmetcli* is run as root and has two modes:
Packit 01965a
Packit 01965a
1. An interactive configuration shell
Packit 01965a
2. Command-line mode which uses an argument
Packit 01965a
Packit 01965a
BACKGROUND
Packit 01965a
----------
Packit 01965a
The term *NQN* used throughout this man page is the *NVMe Qualified
Packit 01965a
Name* format which an NVMe endpoint (device, subsystem, etc) must
Packit 01965a
follow to guarantee a unique name under the NVMe standard.  Any
Packit 01965a
name in a network system setup can be used, but if it does not
Packit 01965a
follow the NQN format, it may not be unique on an NVMe-over-Fabrics network.
Packit 01965a
Packit 01965a
Note that some of the fields set for an NVMe Target port under
Packit 01965a
interactive mode are defined in the "Discovery Log Page" section of
Packit 01965a
NVMe-over-Fabrics specification. Each NVMe Target has a
Packit 01965a
discovery controller mechanism that an NVMe Host can use to determine
Packit 01965a
the NVM subsystems it can access.  *nvmetcli* can be used to add
Packit 01965a
a new record to the discovery controller upon each new subsystem
Packit 01965a
entry and port entry that the newly created subsystem entry binds
Packit 01965a
to (see *OPTIONS* and *EXAMPLES* sections).  Each NVMe
Packit 01965a
Host only gets to see the discovery entries defined in
Packit 01965a
*/subsystems/[NQN NAME]/allowed_hosts* and the IP port it is connected
Packit 01965a
to the NVMe Target.  An NVMe Host can retrieve these discovery logs via
Packit 01965a
the nvme-cli tool (https://github.com/linux-nvme/nvme-cli).
Packit 01965a
Packit 01965a
OPTIONS
Packit 01965a
-------
Packit 01965a
*Interactive Configuration Shell*
Packit 01965a
Packit 01965a
To start the interactive configuration shell, type *nvmetcli* on
Packit 01965a
the command-line.  nvmetcli interacts with the Linux kernel
Packit 01965a
NVMe Target configfs subsystem starting at base
Packit 01965a
nvmetcli directories **/port**, **/subsystem**, and **/host**.
Packit 01965a
Configuration changes entered by the administrator are made
Packit 01965a
immediately to the kernel target configuration.  The
Packit 01965a
following commands can be used while in the interactive configuration
Packit 01965a
shell mode:
Packit 01965a
[]
Packit 01965a
|==================
Packit 01965a
| cd                    | Allows to move around the tree. 
Packit 01965a
| ls                    | Lists contents of current tree node.
Packit 01965a
| create [NQN name]/[#] | Create a new object using the specified name
Packit 01965a
                          or number. If a [NQN name]/[#] is not specified,
Packit 01965a
                          a random entry will be used.
Packit 01965a
| delete [NQN name]/[#] | Delete an object with the specified name or number.
Packit 01965a
| set attr allow_any_host=[0/1] | Used under */subsystems/[NQN name]* to
Packit 01965a
                                  specify if any NVMe Host can connect to
Packit 01965a
                                  the subsystem.
Packit 01965a
| set device path=[device path] | Used under
Packit 01965a
                                  */subsystems/[NQN name]/namespaces*
Packit 01965a
                                  to set the (storage) device to be used.
Packit 01965a
| set device nguid=[string]     | Used under
Packit 01965a
                                  */subsystems/[NQN name]/namespaces*
Packit 01965a
                                  to set the unique id of the device to
Packit 01965a
                                  the defined namespace.
Packit 01965a
| enable/disable                | Used under
Packit 01965a
                                  */subsystems/[NQN name]/namespaces*
Packit 01965a
                                  to enable and disable the namespace.
Packit 01965a
| set addr [discovery log page field]=[string] | Used under */ports/[#]*
Packit 01965a
                                                 to create a port which
Packit 01965a
                                                 access is allowed. See
Packit 01965a
                                                 *EXAMPLES* for more
Packit 01965a
                                                 information.
Packit 01965a
| saveconfig [filename.json]    | Save the NVMe Target configuration in .json
Packit 01965a
                                  format.  Without specifying the
Packit 01965a
                                  filename this will save as
Packit 01965a
                                  */etc/nvmet/config.json*.  This file
Packit 01965a
                                  is in JSON format and can be edited directly
Packit 01965a
                                  using a prefered file editor.
Packit 01965a
| exit                          | Quits interactive configuration shell mode.
Packit 01965a
|==================
Packit 01965a
Packit 01965a
*Command Line Mode*
Packit 01965a
Packit 01965a
Typing *nvmetcli [cmd]* on the command-line will execute a command
Packit 01965a
and not enter the interactive configuration shell.
Packit 01965a
Packit 01965a
[]
Packit 01965a
|==================
Packit 01965a
| restore [filename.json] | Loads a saved NVMe Target configuration.
Packit 01965a
                            Without specifying the filename this will use
Packit 01965a
                            */etc/nvmet/config.json*.
Packit 01965a
| clear                   | Clears a current NVMe Target configuration.
Packit 01965a
| ls                      | Dumps the current NVMe Target configuration.
Packit 01965a
|==================
Packit 01965a
Packit 01965a
EXAMPLES
Packit 01965a
--------
Packit 01965a
Packit 01965a
Make sure to run nvmetcli as root, the nvmet module is loaded,
Packit 01965a
your devices and all dependent modules are loaded,
Packit 01965a
and configfs is mounted on /sys/kernel/config
Packit 01965a
using:
Packit 01965a
Packit 01965a
	mount -t configs none /sys/kernel/config
Packit 01965a
Packit 01965a
The following section walks through a configuration example.
Packit 01965a
Packit 01965a
* To get started with the interactive mode and the nvmetcli command prompt,
Packit 01965a
type (in root):
Packit 01965a
--------------
Packit 01965a
# ./nvmetcli
Packit 01965a
...>
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* Create a subsystem.  If you do not specify a name a NQN will be generated,
Packit 01965a
which is probably the best choice. We don't do it here as the name
Packit 01965a
would be random:
Packit 01965a
--------------
Packit 01965a
> cd /subsystems
Packit 01965a
...> create testnqn
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* Add access for a specific NVMe Host by it's NQN:
Packit 01965a
--------------
Packit 01965a
...> cd /hosts
Packit 01965a
...> create hostnqn
Packit 01965a
...> cd /subsystems/testnqn
Packit 01965a
...> set attr allow_any_host=0
Packit 01965a
...> cd /subsystems/testnqn/allowed_hosts/
Packit 01965a
...> create hostnqn
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* Remove access of a subsystem by deleting the Host NQN:
Packit 01965a
--------------
Packit 01965a
...> cd /subsystems/testnqn/allowed_hosts/
Packit 01965a
...> delete hostnqn
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* Alternatively this allows any Host to connect to the subsystsem.  Only
Packit 01965a
use this in tightly controlled environments:
Packit 01965a
--------------
Packit 01965a
...> cd /subsystems/testnqn/
Packit 01965a
...> set attr allow_any_host=1
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* Create a new namespace.  If you do not specify a namespace ID the fist
Packit 01965a
unused one will be used:
Packit 01965a
--------------
Packit 01965a
...> cd /subsystems/testnqn/namespaces
Packit 01965a
...> create 1
Packit 01965a
...> cd 1
Packit 01965a
...> set device path=/dev/nvme0n1
Packit 01965a
...> enable
Packit 01965a
--------------
Packit 01965a
Packit 01965a
Note that in the above setup the 'device_nguid' attribute
Packit 01965a
does not have to be set for correct NVMe Target functionality (but
Packit 01965a
to correctly match a namespace to the exact device upon
Packit 01965a
clear and restore operations, it is advised to set the
Packit 01965a
'device_nguid' parameter).
Packit 01965a
Packit 01965a
* Create a loopback port that can be used with nvme-loop module
Packit 01965a
on the same physical machine...
Packit 01965a
--------------
Packit 01965a
...> cd /ports/
Packit 01965a
...> create 1
Packit 01965a
...> cd 1/
Packit 01965a
...> set addr trtype=loop
Packit 01965a
...> cd subsystems/
Packit 01965a
...> create testnqn
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* or create an RDMA (IB, RoCE, iWarp) port using IPv4 addressing. 4420 is the
Packit 01965a
IANA assigned default port for NVMe over Fabrics using RDMA:
Packit 01965a
--------------
Packit 01965a
...> cd /ports/
Packit 01965a
...> create 2
Packit 01965a
...> cd 2/
Packit 01965a
...> set addr trtype=rdma
Packit 01965a
...> set addr adrfam=ipv4
Packit 01965a
...> set addr traddr=192.168.6.68
Packit 01965a
...> set addr trsvcid=4420
Packit 01965a
...> cd subsystems/
Packit 01965a
...> create testnqn
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* or create an FC port. traddr is the WWNN/WWPN of the FC port.
Packit 01965a
--------------
Packit 01965a
...> cd /ports/
Packit 01965a
...> create 3
Packit 01965a
...> cd 3/
Packit 01965a
...> set addr trtype=fc
Packit 01965a
...> set addr adrfam=fc
Packit 01965a
...> set addr traddr=nn-0x1000000044001123:pn-0x2000000055001123
Packit 01965a
...> set addr trsvcid=none
Packit 01965a
...> cd subsystems/
Packit 01965a
...> create testnqn
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* Saving the NVMe Target configuration:
Packit 01965a
--------------
Packit 01965a
./nvmetcli
Packit 01965a
...> saveconfig test.json
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* Loading an NVMe Target configuration:
Packit 01965a
--------------
Packit 01965a
  ./nvmetcli restore test.json
Packit 01965a
--------------
Packit 01965a
Packit 01965a
* Clearing a current NVMe Target configuration:
Packit 01965a
--------------
Packit 01965a
  ./nvmetcli clear
Packit 01965a
--------------
Packit 01965a
Packit 01965a
ADDITIONAL INFORMATION
Packit 01965a
----------------------
Packit 01965a
nvmetcli has the ability to start and stop the NVMe Target configuration
Packit 01965a
on boot and shutdown through the *systemctl* Linux utility via a .service file.
Packit 01965a
nvmetcli package comes with *nvmet.service* which when installed, it can 
Packit 01965a
automatically restore the default, saved NVMe Target configuration from
Packit 01965a
*/etc/nvmet/config.json*.  *nvmet.service* can be installed in directories
Packit 01965a
such as */lib/systemd/system*.
Packit 01965a
Packit 01965a
To explicitly enable the service, type:
Packit 01965a
--------------
Packit 01965a
  systemctl enable nvmet
Packit 01965a
--------------
Packit 01965a
Packit 01965a
To explicitly disable the service, type:
Packit 01965a
--------------
Packit 01965a
  systemctl disable nvmet
Packit 01965a
--------------
Packit 01965a
Packit 01965a
See also systemctl(1).
Packit 01965a
Packit 01965a
AUTHORS
Packit 01965a
-------
Packit 01965a
This man page was written by
Packit 01965a
mailto:james.p.freyensee@intel.com[Jay Freyensee]. nvmetcli was
Packit 01965a
originally written by mailto:hch@infradead.org[Christoph Hellwig].
Packit 01965a
Packit 01965a
REPORTING BUGS & DEVELOPMENT
Packit 01965a
-----------------------------
Packit 01965a
Please send patches and bug reports to linux-nvme@lists.infradead.org
Packit 01965a
for review and acceptance.
Packit 01965a
Packit 01965a
LICENSE
Packit 01965a
-------
Packit 01965a
nvmetcli is licensed under the *Apache License, Version 2.0*. Software
Packit 01965a
distributed under this license is distributed on an "AS IS" BASIS, WITHOUT
Packit 01965a
WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.