VMware Cloud Community
Dorilevy
Enthusiast
Enthusiast

partition / label new disk using cli

Hi All,

Im writing an automated script for handling disk replacment on ESXi, in case if disk failure. We are using vSphere 5.1 with all hosts in lockdown mode, and therefor SSH & direct access to the host are blocked.

I found out that when replacing a disk with a blank disk or one with unsupported partiton format, it is needed to use partedUtil to assigne new label (msdos).

I was wondering if there is way of doing so with official CLI (esxcli or other command) that i can run from a remote machine.

Regards,

Dori

0 Kudos
1 Reply
Dorilevy
Enthusiast
Enthusiast

Hi all,

We created a new VIB that adds a plugin to the esxcli command (attached).

(NOTE - the vib was created for "community"acceptance level)

the plugin will install 2 files on the system - esxcli XML file plugin (see link below on how to create one) & a warrper script that runs partedUtil and return the output, pasrsed into excpeted XML structer (esxcli command require it).

Then i packed it as a VIB and instlled it on the esxi. After i restared the ESXi i can run partedUtil command using esxcli:

# esxcli
Usage: esxcli [options] {namespace}+ {cmd} [cmd options]
Options:
  --formatter=FORMATTER
                        Override the formatter to use for a given command. Available formatter: xml, csv, keyvalue
  --debug               Enable debug or internal use options
  --version             Display version information for the script
  -?, --help            Display usage information for the script
Available Namespaces:
  esxcli                Commands that operate on the esxcli system itself allowing users to get additional information.
  fcoe                  VMware FCOE commands.
  hardware              VMKernel hardware properties and commands for configuring hardware.
  hp                    hpnmi esxcli plugin
  hpacucli              HP Array Configuration Utility CLI
  hpbootcfg             HP Boot Configuration Utility
  iscsi                 VMware iSCSI commands.
  network               Operations that pertain to the maintenance of networking on an ESX host. This includes a wide variety of
                        commands to manipulate virtual networking components (vswitch, portgroup, etc) as well as local host IP,
                        DNS and general host networking settings.
  parted                swp command for partedutil
  sched                 VMKernel system properties and commands for configuring scheduling related functionality.
  software              Manage the ESXi software image and packages
  storage               VMware storage commands.
  system                VMKernel system properties and commands for configuring properties of the kernel core system.
  vm                    A small number of operations that allow a user to Control Virtual Machine operations.

And this is what happen when i run it:

# esxcli parted cmd -q 'getptbl /vmfs/devices/disks/mpx.vmhba32:C0:T0:L0:8'

unknown

36 255 63 585696

I used this post on how to create the esxcli plugin:

http://www.v-front.de/2013/01/how-to-write-your-own-esxcli-plugin.html#uds-search-results

I used this documantion on how to pack it into a VIB:

http://www.virtuallyghetto.com/2012/09/creating-custom-vibs-for-esxi-50-51.html

0 Kudos