Manage Virtual Disks

Virtual machine disks are listed by vss-cli compute vm get <name-or-vm-id> disk <unit> and updated, removed and created by vss-cli compute vm set <name-or-vm-id> disk <unit>. This tutorial walks you through the process of managing virtual machine disks.

List

To list a summary of current virtual machine disks, use vss-cli compute vm get <name-or-vm-id> disk or vss-cli compute vm get <name-or-vm-id> disk <unit> to get specific information of a disk unit. For instance, the following virtual machine has two virtual disks configured:

vss-cli compute vm get VMName disk label unit controller.virtual_device_node ----------- ------ -------------------------------- Hard disk 1 1 SCSI controller 0:0 Hard disk 2 2 SCSI controller 1:1 Hard disk 3 3 SCSI controller 1:0

Getting specific information of a given disk unit, run vss-cli compute vm get <name-or-vm-id> disk <unit> as follows:

vss-cli compute vm get vm-1233 disk 1 label : Hard disk 1 unit : 1 virtual_device_node : SCSI controller 0:0 capacity_gb : 8 shares.level : normal

Getting backing information of a particular disk is available by including the sub-command backing in the disk command:

vss-cli compute vm get vm-1233 disk 1 backing descriptor_file_name: None device_name : None disk_mode : persistent file_name : [CL-NSTOR47-NFS-vol33] 1806P-modest_davinci_66/1806P-modest_davinci_66.vmdk lun_uuid : None thin_provisioned : True

Getting details of the SCSI controller of a particular disk is available by including the sub-command scsi in the disk command:

Update

There are three allowed actions to modify a given disk unit: remove, update and create as shown by vss-cli compute vm set <name-or-vm-id> disk mk|up|rm --help command:

Expand

In order to expand an existing disk, use vss-cli compute vm set <name-or-vm-id> disk up <unit> -c <capacityGB> as shown below:

Controller

SCSI controllers are also available to update via the CLI. Use vss-cli compute vm set <name-or-vm-id> disk up <unit> -s <bus_number> as follows:

Backing Mode

Disk backing modes can be updated via vss-cli compute vm set <name-or-vm-id> disk up <unit> -m <disk-mode>:

Refer to the following table to pick the right backing mode:

Name

Description

Name

Description

append

Changes are appended to the redo log; you revoke changes by removing the undo log.

independent_nonpersistent

Same as nonpersistent, but not affected by snapshots.

independent_persistent

Same as persistent, but not affected by snapshots.

nonpersistent

Changes to virtual disk are made to a redo log and discarded at power off.

persistent

Changes are immediately and permanently written to the virtual disk.

undoable

Changes are made to a redo log, but you are given the option to commit or undo.

Backing Sharing Mode

Disk backing sharing modes can be updated via vss-cli compute vm set <name-or-vm-id> disk up <unit> -r <sharing>:

Refer to the following table to pick the right backing sharing:

Name

Description

Name

Description

sharingmultiwriter

The virtual disk is shared between multiple virtual machines.

sharingnone

The virtual disk is not shared.

Create

Creating a new virtual machine disk is as simple as updating, but switching the sub-command to mk, for example:

Also, it supports providing both backing_mode and backing_sharing in the following format <capacity_gb>=<backing_mode>=<backing_sharing>=<backing_vmdk>. If no backing_mode and backing_sharing and backing_vmdk are provided, defaults are:

  • backing_mode: persistent

  • backing_sharing: sharingnone

  • backing_vmdk: automatically generated by vSphere. (advanced)

For instance:

Or in particular use cases, there could be a need for a sharingmultiwriter sharing mode:

The --disk payload can also be provided in JSON format:

vss-cli compute vm set vm-1233 disk mk –disk 100 –disk ‘{“capacity_gb”: 100, “backing_mode”: “independent_persistent”}’

Specify SCSI controller

By default, the ITS Private Cloud API creates disks using the first SCSI controller and available slots in it. If a SCSI controller is full, a new controller will be created using our pre-defined settings based on operating systems.

There are cases when a virtual machine has more than one SCSI controller to ensure compatibility during the installation of the operating system and an additional using the VMware Paravirtual SCSI Controller to take advantage of the greater throughput and lower CPU utilization.

Assuming there is a virtual machine with the following SCSI controller layout:

And there is a requirement to create a 100GB disk on SCSI controller 1 (Paravirtual), just include the scsi attribute with the bus_number as value in the --disk JSON payload as follows:

The previous command creates a disk in the next available slot of SCSI Controller 1.

Import VMDK

Importing existing VMDK disks into the ITS Private Cloud hosted VM is also possible. In order to create a new disk from an existent VMDK compatible file, please follow these steps:

  1. Upload the VMDK file to VSKEY-STOR.

  2. Execute vss-cli compute vmdk personal sync to synchronize the uploaded VMDK files.

  3. List to verify the files have successfully synchronized with vss-cli compute vmdk personal ls:

4. Submit a VM disk creation request including the backing_vmdk attribute with the vmdk id in the value as JSON payload as follows:

The task will first transfer the original VMDK, validate, inflate and convert the file to the right vSphere format.

Copy

Similar to importing a VMDK, copying virtual disks across virtual machines allows the flexibility to duplicate a disk from one VM to another with a simple command.

  • Source: 2311P-VM-A

  • Target: 2311P-VM-B

  1. Get source VM disk to copy from the file_name attribute as follows:

  1. Submit an import request with the vss-cli compute vm set vm-2551 disk cp command:

3. A confirmation prompt will show with the target VM information, if you would like to skip this step, add the --confirm option to the cp command.

VMDK Copy tasks might take a while based on the source VM size and how much resources are available.

Remove

Disk removal will ask for confirmation if flag -r/--rm is not provided. This is just as fail safe for mistakes that can happen and since disk removal is a one way action, it may end in data loss if not used carefully.

The following example demonstrates how to remove a disk with a confirmation prompt:

If your answer is N, the command will exit as shown above.

To override disk removal confirmation prompt, just add -r/--rm flag as follows:

University of Toronto - Since 1827