Monday, 27 July 2015

Decoding hdisk PVID's on AIX

When you add disks into volume groups, AIX generates a unique PVID number for each hdisk.   You can view these PVID's by running "lspv" and looking at the second column:
# lspv
hdisk0          00cc202e7db580dd                    rootvg          active
hdisk1          00cc202e93b711f7                    datavg          active
hdisk2          00cc202e93bad24b                    datavg          active
hdisk3          00cc202e93bad31c                    datavg          active
hdisk4          00cc202e93bb219c                    testvg          active
hdisk5          00cc202e93bb226d                    testvg          active
hdisk6          00cc202e93bb5f1a                    appvg           active
hdisk7          00cc202e93bb5fe6                    appvg           active
hdisk8          00cc202e93bb60bd                    appvg           active
hdisk9          00cc202e93bb619c                    appvg           active
hdisk10         00cc202e8f4ac23d                    None                    
Let's take hdisk10 for example.  Its PVID is "00cc202e8f4ac23d".   As you can see this is a hexadecimal number.   If you split it right down the middle and take the first 8 characters, these are the same as the first 8 characters of the servers machine ID.   

You can see this by running "uname -m":
# uname -m
00CC202E4C00
# lspv | grep hdisk10
hdisk10         00cc202e8f4ac23d                    None
As you can see, the first 8 characters of the machine ID is the same as the first 8 characters of the PVID.  If you have some PVID's on your server that don't match the first 8 characters of the machine ID this means the PVID's were generated on a different machine.  This can happen if you export volume groups and move them between servers. 

Decoding the second half of the PVID is more tricky.  The second half represents a timestamp, but I have never been able to find out any more information than that.

I set out to dediv this second half of the PVID in hopes that it would be possible to use it to determine the date/time that a volume group was created. 

To figure this out, I wrote a script that would increment the date on the server one day at a time, then clear the PVID and create a new one.    By doing this, I am hoping to see how much the PVID number changes in a day's time by subtracting the old PVID from the new one.  

Here is the script (NOTE: this changes the date and clears/recreates PVID's so this is NOT something you want to run on your AIX server :)

#!/bin/ksh
for day in 01 02 03 04 05 06 07 08 09 10; do
        date "12${day}000012" > /dev/null
        lastpvid=`lspv | grep hdisk10 | awk '{print $2}' | tr 'a-z' 'A-Z'`
        chdev -a pv=clear -l hdisk10 >/dev/null;
        chdev -a pv=yes -l hdisk10 >/dev/null;
        newpvid=`lspv | grep hdisk10 | awk '{print $2}' | tr 'a-z' 'A-Z'`
        [ "$day" -eq "01" ] && continue
        printf "`date +%D` "
        printf "New PVID:  $newpvid   Old PVID:  $lastpvid   New-Old="
        echo "ibase=16; $newpvid - $lastpvid" | bc
done

Here is the output of the script:

 # ./pvid4
12/02/12 New PVID:  00CC202E5A339113   Old PVID:  00CC202E550D3516   New-Old=86399997
12/03/12 New PVID:  00CC202E5F59ED0D   Old PVID:  00CC202E5A339113   New-Old=86399994
12/04/12 New PVID:  00CC202E64804912   Old PVID:  00CC202E5F59ED0D   New-Old=86400005
12/05/12 New PVID:  00CC202E69A6A50D   Old PVID:  00CC202E64804912   New-Old=86399995
12/06/12 New PVID:  00CC202E6ECD0113   Old PVID:  00CC202E69A6A50D   New-Old=86400006
12/07/12 New PVID:  00CC202E73F35D0C   Old PVID:  00CC202E6ECD0113   New-Old=86399993
12/08/12 New PVID:  00CC202E7919B90E   Old PVID:  00CC202E73F35D0C   New-Old=86400002
12/09/12 New PVID:  00CC202E7E401512   Old PVID:  00CC202E7919B90E   New-Old=86400004
12/10/12 New PVID:  00CC202E83667118   Old PVID:  00CC202E7E401512   New-Old=86400006
Again, since the PVID's are just hex numbers you can do math with them.   You can see as the date was increased 1 day at a time, and then yesterday's PVID was subtracted from today's PVID, the results were always about  86,400,000.    So based on this, we can determine that this timestamp counter increases by 86,400,000 per day.  If you do the math, you can figure out that this is 1,000 times per second (60 seconds * 60 minutes * 24 hours * 1000 = 86,400,000).

We also know that this second part of the PVID is 8 hex digits long.  The largest 8 digit hex number is FFFFFFFF, which equals 4,294,967,295 in decimal.  If we take this number, and divide it by 86,400,000 we get about 49.7.  This means that about every 49 days the generated PVID numbers overflow and start over.   Based on this, it is unfortunately not possible to determine the date/time a PVID was generated because the numbers wrap around (start over) every 49 days.

Here is the output of another script that generated a new PVID on every date across several months.   As you can see every 49 days the timestamp recorded in the last 8 digits fills up and starts over:

01/02/13 New PVID:  00CC202EF9D88250   Old PVID:  00CC202EF4B22654   New-Old=86399996
01/03/13 New PVID:  00CC202EFEFEDE4A   Old PVID:  00CC202EF9D88250   New-Old=86399994
01/04/13 New PVID:  00CC202E04253A4A   Old PVID:  00CC202EFEFEDE4A   New-Old=-4208567296    First wrap
01/05/13 New PVID:  00CC202E094B964A   Old PVID:  00CC202E04253A4A   New-Old=86400000
01/06/13 New PVID:  00CC202E0E71F24B   Old PVID:  00CC202E094B964A   New-Old=86400001
01/07/13 New PVID:  00CC202E13984E45   Old PVID:  00CC202E0E71F24B   New-Old=86399994
01/08/13 New PVID:  00CC202E18BEAA45   Old PVID:  00CC202E13984E45   New-Old=86400000
01/09/13 New PVID:  00CC202E1DE5064A   Old PVID:  00CC202E18BEAA45   New-Old=86400005
01/10/13 New PVID:  00CC202E230B624A   Old PVID:  00CC202E1DE5064A   New-Old=86400000
01/11/13 New PVID:  00CC202E2831BE4A   Old PVID:  00CC202E230B624A   New-Old=86400000
01/12/13 New PVID:  00CC202E2D581A50   Old PVID:  00CC202E2831BE4A   New-Old=86400006
01/13/13 New PVID:  00CC202E327E764A   Old PVID:  00CC202E2D581A50   New-Old=86399994
01/14/13 New PVID:  00CC202E37A4D251   Old PVID:  00CC202E327E764A   New-Old=86400007
01/15/13 New PVID:  00CC202E3CCB2E49   Old PVID:  00CC202E37A4D251   New-Old=86399992
01/16/13 New PVID:  00CC202E41F18A46   Old PVID:  00CC202E3CCB2E49   New-Old=86399997
01/17/13 New PVID:  00CC202E4717E64A   Old PVID:  00CC202E41F18A46   New-Old=86400004
01/18/13 New PVID:  00CC202E4C3E4245   Old PVID:  00CC202E4717E64A   New-Old=86399995
01/19/13 New PVID:  00CC202E51649E4B   Old PVID:  00CC202E4C3E4245   New-Old=86400006
01/20/13 New PVID:  00CC202E568AFA46   Old PVID:  00CC202E51649E4B   New-Old=86399995
01/21/13 New PVID:  00CC202E5BB15647   Old PVID:  00CC202E568AFA46   New-Old=86400001
01/22/13 New PVID:  00CC202E60D7B246   Old PVID:  00CC202E5BB15647   New-Old=86399999
01/23/13 New PVID:  00CC202E65FE0E4A   Old PVID:  00CC202E60D7B246   New-Old=86400004
01/24/13 New PVID:  00CC202E6B246A48   Old PVID:  00CC202E65FE0E4A   New-Old=86399998
01/25/13 New PVID:  00CC202E704AC647   Old PVID:  00CC202E6B246A48   New-Old=86399999
01/26/13 New PVID:  00CC202E75712245   Old PVID:  00CC202E704AC647   New-Old=86399998
01/27/13 New PVID:  00CC202E7A977E46   Old PVID:  00CC202E75712245   New-Old=86400001
01/28/13 New PVID:  00CC202E7FBDDA4B   Old PVID:  00CC202E7A977E46   New-Old=86400005
01/29/13 New PVID:  00CC202E84E4364A   Old PVID:  00CC202E7FBDDA4B   New-Old=86399999
01/30/13 New PVID:  00CC202E8A0A924A   Old PVID:  00CC202E84E4364A   New-Old=86400000
01/31/13 New PVID:  00CC202E8F30EE46   Old PVID:  00CC202E8A0A924A   New-Old=86399996
02/01/13 New PVID:  00CC202E94574A4A   Old PVID:  00CC202E8F30EE46   New-Old=86400004
02/02/13 New PVID:  00CC202E997DA680   Old PVID:  00CC202E94574A4A   New-Old=86400054
02/03/13 New PVID:  00CC202E9EA40248   Old PVID:  00CC202E997DA680   New-Old=86399944
02/04/13 New PVID:  00CC202EA3CA5E4A   Old PVID:  00CC202E9EA40248   New-Old=86400002
02/05/13 New PVID:  00CC202EA8F0BA4A   Old PVID:  00CC202EA3CA5E4A   New-Old=86400000
02/06/13 New PVID:  00CC202EAE171650   Old PVID:  00CC202EA8F0BA4A   New-Old=86400006
02/07/13 New PVID:  00CC202EB33D724B   Old PVID:  00CC202EAE171650   New-Old=86399995
02/08/13 New PVID:  00CC202EB863CE45   Old PVID:  00CC202EB33D724B   New-Old=86399994
02/09/13 New PVID:  00CC202EBD8A2A4A   Old PVID:  00CC202EB863CE45   New-Old=86400005
02/10/13 New PVID:  00CC202EC2B08644   Old PVID:  00CC202EBD8A2A4A   New-Old=86399994
02/11/13 New PVID:  00CC202EC7D6E24A   Old PVID:  00CC202EC2B08644   New-Old=86400006
02/12/13 New PVID:  00CC202ECCFD3E4A   Old PVID:  00CC202EC7D6E24A   New-Old=86400000
02/13/13 New PVID:  00CC202ED2239A45   Old PVID:  00CC202ECCFD3E4A   New-Old=86399995
02/14/13 New PVID:  00CC202ED749F64A   Old PVID:  00CC202ED2239A45   New-Old=86400005
02/15/13 New PVID:  00CC202EDC70524A   Old PVID:  00CC202ED749F64A   New-Old=86400000
02/16/13 New PVID:  00CC202EE196AE50   Old PVID:  00CC202EDC70524A   New-Old=86400006
02/17/13 New PVID:  00CC202EE6BD0A45   Old PVID:  00CC202EE196AE50   New-Old=86399989
02/18/13 New PVID:  00CC202EEBE3664A   Old PVID:  00CC202EE6BD0A45   New-Old=86400005
02/19/13 New PVID:  00CC202EF109C24A   Old PVID:  00CC202EEBE3664A   New-Old=86400000
02/20/13 New PVID:  00CC202EF6301E4A   Old PVID:  00CC202EF109C24A   New-Old=86400000
02/21/13 New PVID:  00CC202EFB567A46   Old PVID:  00CC202EF6301E4A   New-Old=86399996
02/22/13 New PVID:  00CC202E007CD658   Old PVID:  00CC202EFB567A46   New-Old=-4208567278  Second wrap, 49 days later
02/23/13 New PVID:  00CC202E05A33246   Old PVID:  00CC202E007CD658   New-Old=86399982
02/24/13 New PVID:  00CC202E0AC98E46   Old PVID:  00CC202E05A33246   New-Old=86400000
02/25/13 New PVID:  00CC202E0FEFEA4A   Old PVID:  00CC202E0AC98E46   New-Old=86400004
02/26/13 New PVID:  00CC202E1516464B   Old PVID:  00CC202E0FEFEA4A   New-Old=86400001
02/27/13 New PVID:  00CC202E1A3CA24A   Old PVID:  00CC202E1516464B   New-Old=86399999
02/28/13 New PVID:  00CC202E1F62FE50   Old PVID:  00CC202E1A3CA24A   New-Old=86400006
03/01/13 New PVID:  00CC202E24895A4B   Old PVID:  00CC202E1F62FE50   New-Old=86399995
03/02/13 New PVID:  00CC202E29AFB64B   Old PVID:  00CC202E24895A4B   New-Old=86400000
03/03/13 New PVID:  00CC202E2ED61245   Old PVID:  00CC202E29AFB64B   New-Old=86399994
03/04/13 New PVID:  00CC202E33FC6E50   Old PVID:  00CC202E2ED61245   New-Old=86400011
03/05/13 New PVID:  00CC202E3922CA4B   Old PVID:  00CC202E33FC6E50   New-Old=86399995
03/06/13 New PVID:  00CC202E3E49264A   Old PVID:  00CC202E3922CA4B   New-Old=86399999
03/07/13 New PVID:  00CC202E436F824B   Old PVID:  00CC202E3E49264A   New-Old=86400001
03/08/13 New PVID:  00CC202E4895DE4B   Old PVID:  00CC202E436F824B   New-Old=86400000
03/09/13 New PVID:  00CC202E4DBC3A4A   Old PVID:  00CC202E4895DE4B   New-Old=86399999
03/10/13 New PVID:  00CC202E52E2964A   Old PVID:  00CC202E4DBC3A4A   New-Old=86400000
03/11/13 New PVID:  00CC202E57D203CA   Old PVID:  00CC202E52E2964A   New-Old=82800000
03/12/13 New PVID:  00CC202E5CF85FCB   Old PVID:  00CC202E57D203CA   New-Old=86400001
03/13/13 New PVID:  00CC202E621EBBCA   Old PVID:  00CC202E5CF85FCB   New-Old=86399999
03/14/13 New PVID:  00CC202E674517CB   Old PVID:  00CC202E621EBBCA   New-Old=86400001
03/15/13 New PVID:  00CC202E6C6B73C5   Old PVID:  00CC202E674517CB   New-Old=86399994
03/16/13 New PVID:  00CC202E7191CFC5   Old PVID:  00CC202E6C6B73C5   New-Old=86400000
03/17/13 New PVID:  00CC202E76B82BC6   Old PVID:  00CC202E7191CFC5   New-Old=86400001
03/18/13 New PVID:  00CC202E7BDE87CB   Old PVID:  00CC202E76B82BC6   New-Old=86400005
03/19/13 New PVID:  00CC202E8104E3CA   Old PVID:  00CC202E7BDE87CB   New-Old=86399999
03/20/13 New PVID:  00CC202E862B3FCA   Old PVID:  00CC202E8104E3CA   New-Old=86400000
03/21/13 New PVID:  00CC202E8B519BC5   Old PVID:  00CC202E862B3FCA   New-Old=86399995
03/22/13 New PVID:  00CC202E9077F7CB   Old PVID:  00CC202E8B519BC5   New-Old=86400006
03/23/13 New PVID:  00CC202E959E53C9   Old PVID:  00CC202E9077F7CB   New-Old=86399998
03/24/13 New PVID:  00CC202E9AC4AFC9   Old PVID:  00CC202E959E53C9   New-Old=86400000
03/25/13 New PVID:  00CC202E9FEB0BD0   Old PVID:  00CC202E9AC4AFC9   New-Old=86400007
03/26/13 New PVID:  00CC202EA51167D1   Old PVID:  00CC202E9FEB0BD0   New-Old=86400001
03/27/13 New PVID:  00CC202EAA37C3CA   Old PVID:  00CC202EA51167D1   New-Old=86399993
03/28/13 New PVID:  00CC202EAF5E1FCB   Old PVID:  00CC202EAA37C3CA   New-Old=86400001
03/29/13 New PVID:  00CC202EB4847BCB   Old PVID:  00CC202EAF5E1FCB   New-Old=86400000
03/30/13 New PVID:  00CC202EB9AAD7CA   Old PVID:  00CC202EB4847BCB   New-Old=86399999
03/31/13 New PVID:  00CC202EBED133CA   Old PVID:  00CC202EB9AAD7CA   New-Old=86400000
04/01/13 New PVID:  00CC202EC3F78FCA   Old PVID:  00CC202EBED133CA   New-Old=86400000
04/02/13 New PVID:  00CC202EC91DEBCA   Old PVID:  00CC202EC3F78FCA   New-Old=86400000
04/03/13 New PVID:  00CC202ECE4447CB   Old PVID:  00CC202EC91DEBCA   New-Old=86400001
04/04/13 New PVID:  00CC202ED36AA3C5   Old PVID:  00CC202ECE4447CB   New-Old=86399994
04/05/13 New PVID:  00CC202ED890FFCA   Old PVID:  00CC202ED36AA3C5   New-Old=86400005
04/06/13 New PVID:  00CC202EDDB75BCB   Old PVID:  00CC202ED890FFCA   New-Old=86400001
04/07/13 New PVID:  00CC202EE2DDB7CB   Old PVID:  00CC202EDDB75BCB   New-Old=86400000
04/08/13 New PVID:  00CC202EE80413CA   Old PVID:  00CC202EE2DDB7CB   New-Old=86399999
04/09/13 New PVID:  00CC202EED2A6FD1   Old PVID:  00CC202EE80413CA   New-Old=86400007
04/10/13 New PVID:  00CC202EF250CBCB   Old PVID:  00CC202EED2A6FD1   New-Old=86399994
04/11/13 New PVID:  00CC202EF77727C5   Old PVID:  00CC202EF250CBCB   New-Old=86399994
04/12/13 New PVID:  00CC202EFC9D83D0   Old PVID:  00CC202EF77727C5   New-Old=86400011
04/13/13 New PVID:  00CC202E01C3DFC5   Old PVID:  00CC202EFC9D83D0   New-Old=-4208567307   Third wrap, 49 days later
04/14/13 New PVID:  00CC202E06EA3BC6   Old PVID:  00CC202E01C3DFC5   New-Old=86400001
04/15/13 New PVID:  00CC202E0C1097CC   Old PVID:  00CC202E06EA3BC6   New-Old=86400006
04/16/13 New PVID:  00CC202E1136F3C6   Old PVID:  00CC202E0C1097CC   New-Old=86399994
04/17/13 New PVID:  00CC202E165D4FCA   Old PVID:  00CC202E1136F3C6   New-Old=86400004
04/18/13 New PVID:  00CC202E1B83ABCA   Old PVID:  00CC202E165D4FCA   New-Old=86400000
04/19/13 New PVID:  00CC202E20AA07CB   Old PVID:  00CC202E1B83ABCA   New-Old=86400001
04/20/13 New PVID:  00CC202E25D063CB   Old PVID:  00CC202E20AA07CB   New-Old=86400000
04/21/13 New PVID:  00CC202E2AF6BFCB   Old PVID:  00CC202E25D063CB   New-Old=86400000
04/22/13 New PVID:  00CC202E301D1BCB   Old PVID:  00CC202E2AF6BFCB   New-Old=86400000
04/23/13 New PVID:  00CC202E354377C6   Old PVID:  00CC202E301D1BCB   New-Old=86399995
04/24/13 New PVID:  00CC202E3A69D3C5   Old PVID:  00CC202E354377C6   New-Old=86399999
04/25/13 New PVID:  00CC202E3F902FCA   Old PVID:  00CC202E3A69D3C5   New-Old=86400005
04/26/13 New PVID:  00CC202E44B68BC9   Old PVID:  00CC202E3F902FCA   New-Old=86399999
04/27/13 New PVID:  00CC202E49DCE7CC   Old PVID:  00CC202E44B68BC9   New-Old=86400003
04/28/13 New PVID:  00CC202E4F0343CA   Old PVID:  00CC202E49DCE7CC   New-Old=86399998
04/29/13 New PVID:  00CC202E54299FCB   Old PVID:  00CC202E4F0343CA   New-Old=86400001
04/30/13 New PVID:  00CC202E594FFBCA   Old PVID:  00CC202E54299FCB   New-Old=86399999
Conclusion
The first 8 digits of the PVID match the first 8 digits of the machine id (which can be displayed with uname -m).   The last 8 digits of the PVID is a timestamp, but this timestamp overflows every 49.7 days and starts over, so it is not possible to determine the date/time a PVID was generated based on the PVID number.   

No comments:

Post a Comment