From Wiki-UX.info

Wiki-UX / Logical Volume Manager / How to obtain a LVM 1.0 Physical Volume ID
Jump to: navigation, search

How to obtain a LVM 1.0 Physical Volume ID

Abstract

Is possible to obtain a LVM 1.0 Volume Group ID (VGID) directly from the physical volume Volume Group Reserve Area (VGRA) volume. To accomplish this feat is necessary to dump the second 8 Kb from the Physical Volume and use the od command to obtain the octal representation of that binary information.

In the following example the procedure to extract the VGID from the primary and mirror disk of /dev/vg00 is reviewed. HP-UX 11i v3 agile device are used for the example, but traditional legacy devices will offer the same information.

Contents


Basic Procedure

1. Determine which Physical Volumes belong to Volume Group /dev/vg00.

# strings /etc/lvmtab
/dev/vg00
/dev/disk/disk6
/dev/disk/disk10
...


2. Extract 8 Kb, skipping the first 8 Kb from the Physical Volumes using the dd command.

# dd if=/dev/rdisk/disk6 of=/tmp/disk6.dd bs=8k skip=1 count=1
1+0 records in
1+0 records out
# dd if=/dev/rdisk/disk10 of=/tmp/disk10.dd bs=8k skip=1 count=1
1+0 records in
1+0 records out


3. Display the content of the dump files using the od command.

# od -Ax -tx /tmp/disk6.dd
0000000         4c564d52        45433031        1e69dc32        4ad20b84
0000010         1e69dc32        4ad20b84         21eb38f               0
0000020              270             860             126               a
0000030              860             998               8             990
0000040              ac8         21ea000             b60              17
0000050             2000             82f         21eab60               1
0000060                0              10              80               2
0000070               80              88               6              82
0000080               8a               0               0               0
0000090                0               0               0               0
*
0000400         44454645        43543031               0               0
0000410                0               0               0               0
*
0002000
# od -Ax -tx /tmp/disk10.dd
0000000         4c564d52        45433031        1e69dc32        4b2fc49f
0000010         1e69dc32        4ad20b84         21eb38f               1
0000020              270              80             126               a
0000030               80             1b8               8             1b0
0000040              2e8         21ea000             400              17
0000050             2000             f8f         21ea400               1
0000060                0               0               0               0
*
0000400         44454645        43543031               0               0
0000410                0               0               0               0
*
0002000


The VGID is shown on the first and second columns of line 0000010. In this example, the VGID on both physical volumes primary disk is 1e69dc324ad20b84. Note that that the third column of line 0000000 and the first column of line 0000010 are the same. This is the HostID portion of the VGID.

You can verify this information creating a share mode map file using the -s option of the vgexport command.

# vgexport -p -s -m /tmp/vg00.mapfile /dev/vg00
vgexport: Volume group "/dev/vg00" is still active.
vgexport: Preview of vgexport on volume group "/dev/vg00" succeeded.

# cat /tmp/vg00.mapfile
VGID 1e69dc324ad20b84
1 lvol1
2 lvol2
3 lvol3
4 lvol4
5 lvol5
6 lvol6
7 lvol7
8 lvol8
9 lvol9

The same information can be obtain directly from the physical volume without dumping the data with the dd command using the xd command.

# xd -An -j8200 -N16 -tx /dev/rdisk/disk6
                1e69dc32        4ad20b84        1e69dc32        4ad20b84

# od -j8k -N32 -tx /dev/rdisk/disk6
0000000         4c564d52        45433031        1e69dc32        4ad20b84
0000020         1e69dc32        4ad20b84         21eb38f               0
0000040

Create unformatted VGID reports

A quick and dirty VGID report can be created using Postfix Shell scripts.

Using Legacy Device Special Files

Based on the available device special files:

for pv in $(ls /dev/rdsk/*)
do
echo $pv
xd -An -j8200 -N16 -tx $pv 2> /dev/null
done

Example:

# for pv in $(ls /dev/rdsk/*)
> do
> echo $pv
> xd -An -j8200 -N16 -tx $pv 2> /dev/null
> done
/dev/rdsk/c0t0d0
/dev/rdsk/c2t10d0
                 1010101         1010101         1010101         1010101

/dev/rdsk/c2t12d0
                1e69dc32        4ad7841a        1e69dc32        4ad777e4

/dev/rdsk/c2t1d0
                1e69dc32        4ad20b84        1e69dc32        4ad20b84

/dev/rdsk/c2t8d0
                1e69dc32        4ad25312        1e69dc32        4ad25332

/dev/rdsk/c3t0d0
                1e69dc32        4b2fc49f        1e69dc32        4ad20b84

Based on a list of physical volumes from the ioscan I/O tree:

for pv in $(ioscan -fnC disk | awk '{if(NF==2) printf $1 "\n"}')
do
echo $pv
xd -An -j8200 -N16 -tx $pv 2> /dev/null
done

Example:

# for pv in $(ioscan -fnC disk | awk '{if(NF==2) printf $1 "\n"}')
> do
> echo $pv
> xd -An -j8200 -N16 -tx $pv 2> /dev/null
> done
/dev/dsk/c0t0d0
/dev/dsk/c2t1d0
                1e69dc32        4ad20b84        1e69dc32        4ad20b84

/dev/dsk/c2t8d0
                1e69dc32        4ad25312        1e69dc32        4ad25332

/dev/dsk/c2t10d0
                 1010101         1010101         1010101         1010101

/dev/dsk/c2t12d0
                1e69dc32        4ad7841a        1e69dc32        4ad777e4

/dev/dsk/c3t0d0
                1e69dc32        4b2fc49f        1e69dc32        4ad20b84

Using Agile Device Special Files

Based on the available device special files:

for pv in $(ls /dev/rdisk/*)
do
echo $pv
xd -An -j8200 -N16 -tx $pv 2> /dev/null
done

Example:

# for pv in $(ls /dev/rdisk/*)
> do
> echo $pv
> xd -An -j8200 -N16 -tx $pv 2> /dev/null
> done
/dev/rdisk/disk10
                1e69dc32        4b2fc49f        1e69dc32        4ad20b84

/dev/rdisk/disk11
/dev/rdisk/disk6
                1e69dc32        4ad20b84        1e69dc32        4ad20b84

/dev/rdisk/disk7
                1e69dc32        4ad25312        1e69dc32        4ad25332

/dev/rdisk/disk8
                 1010101         1010101         1010101         1010101

/dev/rdisk/disk9
                1e69dc32        4ad7841a        1e69dc32        4ad777e4

Based on a list of physical volumes from the ioscan I/O tree:

for pv in $(ioscan -NfnC disk | awk '/\/dev\/rdisk/ {print $2}')
do
echo $pv
xd -An -j8200 -N16 -tx $pv 2> /dev/null
done

Example:

# for pv in $(ioscan -NfnC disk | awk '/\/dev\/rdisk/ {print $2}')
> do
> echo $pv
> xd -An -j8200 -N16 -tx $pv 2> /dev/null
> done
/dev/rdisk/disk6
                1e69dc32        4ad20b84        1e69dc32        4ad20b84

/dev/rdisk/disk7
                1e69dc32        4ad25312        1e69dc32        4ad25332

/dev/rdisk/disk8
                 1010101         1010101         1010101         1010101

/dev/rdisk/disk9
                1e69dc32        4ad7841a        1e69dc32        4ad777e4

/dev/rdisk/disk10
                1e69dc32        4b2fc49f               0               0

/dev/rdisk/disk11

Create formatted VGID reports

Using Legacy Device Special Files

printf "%-18s | %-17s | %-17s\n" "PV" "VGID" "PVID"; \
for pv in `ls /dev/rdsk/*`
do
   xd -An -j8200 -N16 $pv > /dev/null 2>&1
   if [[ $? -eq 0 ]]; then
      echo "$pv \c"
      xd -An -j8200 -N16 -tx $pv 2> /dev/null
   fi
done \
| awk '$0 ~ /dev/ {printf "%-18s | %8s %8s | %8s %8s\n", $1, $4, $5, $2, $3}' \
| sort -k 2,5

Example:

PV                 | VGID              | PVID
/dev/rdsk/c3t0d0   |        0        0 | 1e69dc32 4b2fc49f
/dev/rdsk/c2t1d0   | 1e69dc32 4ad20b84 | 1e69dc32 4ad20b84
/dev/rdsk/c2t8d0   | 1e69dc32 4ad25332 | 1e69dc32 4ad25312
/dev/rdsk/c2t10d0  |  1010101  1010101 |  1010101  1010101
/dev/rdsk/c2t12d0  | 1e69dc32 4ad777e4 | 1e69dc32 4ad7841a

Using Agile Device Special Files

printf "%-18s | %-17s | %-17s\n" "PV" "VGID" "PVID"; \
for pv in `ls /dev/rdisk/*`
do
   xd -An -j8200 -N16 $pv > /dev/null 2>&1
   if [[ $? -eq 0 ]]; then
      echo "$pv \c"
      xd -An -j8200 -N16 -tx $pv 2> /dev/null
   fi
done \
| awk '$0 ~ /dev/ {printf "%-18s | %8s %8s | %8s %8s\n", $1, $4, $5, $2, $3}' \
| sort -k 2,5

Example:

PV                 | VGID              | PVID
/dev/rdisk/disk8   |  1010101  1010101 |  1010101  1010101
/dev/rdisk/disk6   | 1e69dc32 4ad20b84 | 1e69dc32 4ad20b84
/dev/rdisk/disk7   | 1e69dc32 4ad25332 | 1e69dc32 4ad25312
/dev/rdisk/disk9   | 1e69dc32 4ad777e4 | 1e69dc32 4ad7841a
/dev/rdisk/disk10  |        0        0 | 1e69dc32 4b2fc49f

Alternate method to obtain the Volume Group VGID

The information can be found directly on the /etc/lvmtab binary file. To crate VGID list for every volume group, the following command can be used:

strings -t d /etc/lvmtab | grep /dev/[^d] | sort -k 2 | while read offset vg
do 
   xd -An -j$(($offset+1024)) -N8 -tuL /etc/lvmtab | read v1 v2 
   printf "%-15s %x%x\n" $vg $v1 $v2 
done 


Example:

# strings -t d /etc/lvmtab | grep /dev/[^d] | sort -k 2 | while read offset vg
> do
>    xd -An -j$(($offset+1024)) -N8 -tuL /etc/lvmtab | read v1 v2
>    printf "%-15s %x%x\n" $vg $v1 $v2
> done
/dev/vg00       1e69dc324ad20b84
/dev/vg01       1e69dc324ad25332

Reading PVID / VGID from the Volume Group Configuration File

If it is not possible to identify the PVID and VGID from a set of disks (in case that all of them are different), you can match this values with the information record on the Volume Group Configuration File located at the /etc/lvmconf directory:

for vg in $(ls /etc/lvmconf/*.conf)
do
echo $vg
xd -An -j1024 -N32 -tx $vg
done

Example:

# for vg in $(ls /etc/lvmconf/*.conf)
> do
> echo $vg
> xd -An -j1024 -N32 -tx $vg
> done
/etc/lvmconf/vg00.conf
                4c564d52        45433031        1e69dc32        4ad20b84
                1e69dc32        4ad20b84         21eb38f               0

/etc/lvmconf/vg01.conf
                4c564d52        45433031        1e69dc32        4ad25312
                1e69dc32        4ad25332         21eb38f               0

/etc/lvmconf/vg02.conf
                       0               0           20000               1
                       1           11050             440               0

/etc/lvmconf/vgms.conf
                4c564d52        45433031        1e69dc32        4ad77684
                1e69dc32        4ad777e4         21eb38f               0

/etc/lvmconf/vgoldroot.conf
                4c564d52        45433031        1e69dc32        4a65fbb2
                1e69dc32        4a65fcdd         21eb38f               0

Alternative, the xd command can be used for the same purpose:


for vg in $(ls /etc/lvmconf/*.conf)
do
echo $vg
xd $vg | grep 00004[01]0
echo
done

Example:

# for vg in $(ls /etc/lvmconf/*.conf)
> do
> echo $vg
> xd $vg | grep 00004[01]0
> echo
> done
/etc/lvmconf/vg00.conf
0000400 4c56 4d52 4543 3031 1e69 dc32 4ad2 0b84
0000410 1e69 dc32 4ad2 0b84 021e b38f 0000 0000

/etc/lvmconf/vg01.conf
0000400 4c56 4d52 4543 3031 1e69 dc32 4ad2 5312
0000410 1e69 dc32 4ad2 5332 021e b38f 0000 0000

/etc/lvmconf/vg02.conf
0000400 0000 0000 0000 0000 0002 0000 0000 0001
0000410 0000 0001 0001 1050 0000 0440 0000 0000

/etc/lvmconf/vgms.conf
0000400 4c56 4d52 4543 3031 1e69 dc32 4ad7 7684
0000410 1e69 dc32 4ad7 77e4 021e b38f 0000 0000

/etc/lvmconf/vgoldroot.conf
0000400 4c56 4d52 4543 3031 1e69 dc32 4a65 fbb2
0000410 1e69 dc32 4a65 fcdd 021e b38f 0000 0000

Authors

References

This page was last modified on 3 August 2011, at 19:39. This page has been accessed 2,790 times.