Tuesday 26 March 2013

Physical Volume


PV (Physical Volume)

When a disk drive is initially added to the system it is not yet accessible for operations. To be made accessible, it has to be assigned to a volume group, which means changing from a disk to a physical volume. The disk drive is assigned an identifier that is called the physical volume identifier (PVID).

The PVID is a combination of the machine's serial number and the date the PVID was generated and it is written on the first block of the device. The AIX LVM uses this number to identify specific disks. When a volume group is created, the member devices are simply a list of PVIDs.

The PVID for each device is stored in the ODM when the device is configured. The configuration program tries to read the first block of the device. If it succeeds and the first block contains a valid PVID, the PVID value is saved as an attribute in the ODM for that device. Once the PVID is set in the ODM, it can be seen in the output of the lspv command. (The LVM expects the PVIDs to be saved in the ODM, and it uses the ODM attribute when determining which device to open.)

In a configuration with multiple paths to the same logical devices, multiple hdisks show the same PVID in the output of lspv. When the LVM needs to open a device, it selects the first hdisk in the list with the matching PVID.

-----------------------------

Physical Volume states (not device states!):

active  - If a disk can be accessed during a varyonvg it gets a PV state of active.

missing - If a disk can not be accessed during a varyonvg, but quorum is available the failing disk gets a PV state missing.
          (after repairing it varyonvg wil bring it to active state)

removed - If a disk cannot be accessed during a varyonvg and the quorum of disks is not available you can issue varyonvg -f VGname
          (Before varyonvg -f always check the reason of the failure. If the pv appears to be permanently damaged use a forced varyonvg.)
          All physical volumes that are missing during this forced vary on will be changed to physical volume state removed.
          This means that all the VGDA and VGSA copies will be removed from these physical volumes.
          (After repiring the disk, first chpv -va diskname, it will bring back to active state and then varyonvg is needed for sync.)

The opposite of chpv -va is chpv -vr which brings the disk into the removed state. This works only when all logical volumes have been closed on the disk that will be defined as removed. Additionally, chpv -vr does not work when the quorum will be lost in the volume group after removing the disk

------------------------------


lsdev -Pc disk            displays supported storage
chdev -l hdisk7 -a pv=yes changes the disk device to a physical volume by assigning a PVID
                          (The command has no effect if the disk is already a physical volume)
chdev -l hdisk7 -a pv=clear    clears the PVID from the physical volume

lspv                      displays all physical volumes (vpath, hdisk), their PVIDs, their volume groups...
lspv hdisk0               detailed information about a phys. vol. (vg, pp size, free pp, logical volumes number)
lspv -l hdisk1            list of all the logical volumes on the physical volume
lspv -p hdisk2            displays a map of all physical partitions located on hdisk1
lspv -M hdisk1            shows which physical partitions are being used for specific logical volumes

bootinfo -s hdisk0        shows the size of a pv in MB

chpv -vr hdisk3           makes hdisk3 unavailable (pv state will be removed)
chpv -va hdisk3           makes hdisk3 available
chpv -c hdisk1            clears the bootrecord on hdisk1

The allocation permission for a physical volume determines if physical partitions located on that physical volume, which have not been allocated to a logical volume yet, can be allocated to logical volumes:
chpv -ay hdisk2           turns on the allocation permission
chpv -an hdisk2           turns off the allocation permission

migratepv hdisk1 hdisk5   migrates the data from hdisk1 to hdisk5 (moves all lvs, it can be done during normal system activity)
migratepv -l testlv hdisk1 hdisk5 migrates only testlv from hdisk1 to hdisk5

migratelp testlv/1/2 hdisk5/123 migrates the data from the second copy of the lp number 1 of lv to hdisk5 on pp 123
!!!check if lvmstat is enabled before running migratepv, migratelp, reorgvg, the command to check:lvmstat -v <vgname>!!!!
!!!because if it is, the system may crash, so before running those commands disable it: lvmstat -v <vgname> -d !!!!

lquerypv -h /dev/hdiskX   shows the disk header
lquerypv -M hdisk0        shows the LTG size for a physical disk
LTG size: Logical track group size is the maximum allowed transfer size for an I/O disk operation.

replacepv hdisk1 hdisk6   replace physical volume hdisk1 to hdisk6

mkdev -c disk -t 1200mb -s scsi -p scsi0 -w 6,0 -d creates a dummy hdisk (if it is needed to correct the sequence numbers)
mkdev -l hdiskX -p dummy -c disk -t hdisk -w 0000  the same as above (will give error, but creates it)

------------------------------

SAVING DISK HEADER:
at offset 128 the pvid starts.

To prevent a loss of the first 512 byte of the raw disk ( if something goes wrong with the chdev) use the following command to save
the current state of the sector “dd if=/dev/hdiskX of=hdiskX.header bs=512 count=1” if a command overwrites this sector you can
restore this sector with “dd if=hdiskX.header of=/dev/hdiskX bs=512 count=1” but if you make the copy be shure that the asm is
stopped, because the asm could make updates in this sector during shutdown.

------------------------------

Migrating a partition to another disk:

1.root@aix1: /root # lspv -M hdisk2
    hdisk2:1-14
    hdisk2:15       bblv1:1:1
    hdisk2:16       bblv1:2:1
    hdisk2:17       bblv1:3:1    <--we want to move bblv1:number 3 lp: first copy (the lv is mirrored, second copy is on another disk)
    hdisk2:18-67
2.root@aix1: /root # lspv -M hdisk4
    hdisk4:1-14
    hdisk4:15       loglv00:1
    hdisk4:16-67                 <--we want to move it to hdisk4 on physical partition 16
3.root@aix1: /root # migratelp bblv1/3/1 hdisk4/16
    migratelp: Mirror copy 1 of logical partition 3 of logical volume
      bblv1 migrated to physical partition 16 of hdisk4.
4.root@aix1: /root # lspv -M hdisk2
    hdisk2:1-14
    hdisk2:15       bblv1:1:1
    hdisk2:16       bblv1:2:1
    hdisk2:17-67                  <--physical partition 17 is free now
5.root@aix1: /root # lspv -M hdisk4
    hdisk4:1-14
    hdisk4:15       loglv00:1
    hdisk4:16       bblv1:3:1     <--it is here now
    hdisk4:17-67

No comments:

Post a Comment