Wednesday 14 May 2014

How to check when VMFS volume was created?

VMFS UUID include at the begining epoch time when VMFS was created e.g.

Mark in red epoch time of VMFS creation. 

Run this command on ESXi console to check VMFS UUID

# ls -l /vmfs/volumes/ | awk -F '->' '/^l/ {print $2}' 

51788628-436b3484-80b4-4403a74a651f
5178864e-f6ae0d72-ea05-4403a74a651f
5170ffe3-7dbcd048-d989-4403a74a6429
5170ffd1-956e7d10-2c5a-4403a74a5699
51372ebf-d37fb174-650f-4403a74a5699
  
Unfortunately in vSphere ESXi version 5.0  is older version of date command:

# date --help
BusyBox v1.9.1-VMware-visor-8630 (2012-01-06 01:09:05 PST) multi-call binary

Usage: date [OPTION]... [MMDDhhmm[[CC]YY][.ss]] [+FORMAT]

Display current time in the given FORMAT, or set system date

Options:
        -R              Outputs RFC-822 compliant date string
        -d STRING       Displays time described by STRING, not 'now'
        -I[TIMESPEC]    Outputs an ISO-8601 compliant date/time string
                        TIMESPEC='date' (or missing) for date only,
                        'hours', 'minutes', or 'seconds' for date and
                        time to the indicated precision
        -D hint         Use 'hint' as date format, via strptime()
        -s STRING       Sets time described by STRING
        -r FILE         Displays the last modification time of FILE
        -u              Prints or sets Coordinated Universal Time



We need linux box to check time of vmfs creation:

# date -u -d @$((0x51372ebf))

Since verision 5.1 we have newest date command:

# date --help
BusyBox v1.19.0 (2012-02-29 14:20:08 PST) multi-call binary.

Usage: date [OPTIONS] [+FMT] [TIME]

Display time (using +FMT), or set time

        [-s,--set] TIME Set time to TIME
        -u,--utc        Work in UTC (don't convert to local time)
        -R,--rfc-2822   Output RFC-2822 compliant date string
        -I[SPEC]        Output ISO-8601 compliant date string
                        SPEC='date' (default) for date only,
                        'hours', 'minutes', or 'seconds' for date and
                        time to the indicated precision
        -r,--reference FILE     Display last modification time of FILE
        -d,--date TIME  Display TIME, not 'now'
        -D FMT          Use FMT for -d TIME conversion

Recognized TIME formats:
        hh:mm[:ss]
        [YYYY.]MM.DD-hh:mm[:ss]
        YYYY-MM-DD hh:mm[:ss]
        [[[[[YY]YY]MM]DD]hh]mm[.ss]



On vSphere 5.1 and above to check time of creation we can run from esxi console follwing command:


#date -u -d @$(($(awk 'BEGIN {printf "%0d\n",0x51372ebf;print""}')))
Wed Mar  6 11:55:43 UTC 2013

UPDATE: To check creation time of VMFS volume we can use vmkfstools it seems to be easiest way:

# vmkfstools -Ph -v10 /vmfs/volumes/<datastore name>

# vmkfstools -Ph -v10 /vmfs/volumes/Customer-1 | egrep Creation
Volume Creation Time: Thu Apr 25 01:26:00 2013


Now we know that VMFS was created in March. This information could be very useful in case if we suspect some VMFS corruption it is worth to check when VMFS volume was created sometimes someone could overwrite it

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Command:
    for i in `esxcli storage vmfs extent list |awk '{print $1}'|egrep -v "Volume|-----------"`; do vmkfstools -Ph -v10 /vmfs/volumes/$i |egrep "label|Creation|naa"; done
    output:
    File system label (if any): test-volume
    Volume Creation Time: Wed Dec 12 02:34:05 2018
    naa.600000f05060c70000005c1042930019:1

    or

    command:
    for i in `ls -l /vmfs/volumes/ | awk -F '->' '/^l/ {print $2}' |cut -c 1-9`; do date -u -d @$(($(awk 'BEGIN {printf "%0d \n",0x'$i';print""}')));done
    output:
    Wed Dec 12 02:34:05 UTC 2018

    ReplyDelete