Maxi Best Of Nutanix CLI: storage containers

In the Maxi Best Of Nutanix CLI series, the previous two articles covered checking the network configuration of a Nutanix cluster and managing subnets.
In this new article, we’ll cover managing storage containers via CLI commands on your Nutanix clusters…
All the commands in this article must be executed from one of the cluster’s CVMs and work on a cluster running AOS 6.10+.
Check the containers
To check the status of your storage containers, the simplest command is:
ncli container list

This command will allow you to display all the information related to all the containers in your cluster.
If you want to display a specific container, you can pass the name (the simplest method) or the ID of your container if you have it as a parameter:
ncli container list name=NAME
ncli container list id=ID

Finally, one last command to display only the usage statistics of your containers:
ncli container list-stats

Renaming a Container
To rename a storage container, it must be completely empty.
Renaming a storage container can be done using the following command:
ncli container edit name=ACTUALNAME new-name=NEWNAME
On the default container, this would give for example the following command:
ncli container edit name=default-container-21425105524428 new-name=ntnx-lab-container
WARNING: There are two containers created by default when deploying your cluster: “SelfServiceContainer” and “NutanixManagementShare”. Do not attempt to rename them!
Creating a Container
It’s also possible to create storage containers using the CLI:
ncli container create name=NAME sp-name=STORAGE-POOL-NAME
The “name” and “sp-name” parameters are the only required parameters when running the command. This will allow you to create a base container on the selected storage pool with the following parameters:
- No data optimization mechanism
- No restrictions/reservations
- The default replication factor

But the container creation command can be very useful if you need to create storage containers in batches, for example, if you’re hosting multiple clients on a cluster, each with an allocated amount of storage space!
For example, to create a storage container with the following parameters:
- Container name “client-alpha”
- Reserved capacity: 64GB
- Maximum capacity: 64GB
- With real-time compression enabled
Here’s the command you would need to run:
ncli container create name=client-alpha res-capacity=64 adv-capacity=64 enable-compression=true compression-delay=0 sp-name=default-storage-pool-21425105524428
A container with the associated characteristics will then be created:

Modifying Container Settings
An existing container can also be modified. You can modify almost everything in terms of settings, from data optimization mechanisms to reserved/allocated sizes, replication factors, and more.
For all the settings, please refer to the official documentation (link at the bottom of the page).
Deleting a Container
Deleting a container is quite simple, but requires that all files stored within it be deleted or moved first. Deleting a container is done using the following command:
ncli container remove name=NAME
It may happen that despite deleting or moving your VM’s vdisks, the deletion is still refused. This is often due to small residual files.
You must then add the “ignore-small-files” parameter to force the deletion:
ncli container remove name=NAME ignore-small-files=true
For example:
ncli container remove name=ntnx-lab-container ignore-small-files=true
WARNING: There are two containers created by default when deploying your cluster: “SelfServiceContainer” and “NutanixManagementShare”. Do not attempt to delete them!
Official Documentation
To learn more about some of the command options presented, please consult the official documentation: https://portal.nutanix.com/page/documents/details?targetId=Command-Ref-AOS-v6_10:acl-ncli-container-auto-r.html
0 comments