linuxnvme

How to remove an existing namespace in a nvme and break it into two smaller namespaces?


I have a NVME SSD. There is an existent namespace on it as below.

# nvme list
Node             SN                   Model                                    Namespace Usage                      Format           FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1     2L232L25HQ2C         ADATA SX6000LNP                          1         256.06  GB / 256.06  GB    512   B +  0 B   VC0S0328

But it takes whole capacity. I would like to break it into two smaller namespaces. I did this,

# nvme detach-ns /dev/nvme0 -n 1
warning: empty controller-id list will result in no actual change in namespace attachment
NVMe status: INVALID_OPCODE: The associated command opcode field is not valid(0x4001)

# nvme delete-ns /dev/nvme0 -n 1
NVMe status: INVALID_OPCODE: The associated command opcode field is not valid(0x4001)

As you see, both of them failed. How to deal with it?


Solution

  • Not every SSD supports multiple namespaces. To find number of namespaces an NVMe device supports,

    # nvme id-ctrl /dev/nvme0 | grep ^nn
    nn        : 1
    

    nn indicates the maximum value of a valid NSID for the NVM subsystem. If the SSD supports just one namespace, you even can't delete the existing namespace. The controller doesn't allow the move.