Topics: AIX, Storage, System Admin

Working with disks

With the passing time, some devices are added, and some are removed from a system. AIX learns about hardware changes when the root user executes the cfgmgr command. Without any attributes, it scans all buses for any attached devices. Information acquired by cfgmgr is stored in the ODM (Object Database Manager). Cfgmgr only discovers new devices. Removing devices is achieved with rmdev or odmdelete. Cfgmgr can be executed in the quiet (cfgmgr) or verbose (cfgmgr -v) mode. It can be directed to scan all or selected buses.

The basic command to learn about disks is lspv. Executed without any parameters, it will generate a listing of all disks recorded in the ODM, for example:

# lspv
hdisk0     00c609e0a5ec1460         rootvg     active
hdisk1     00c609e037478aad         rootvg     active
hdisk4     00c03c8a14fa936b         abc_vg     active
hdisk2     00c03b1a32e50767         None
hdisk3     00c03b1a32ee4222         None
hdisk5     00c03b1a35cdcdf0         None
Each row describes one disk. The first column shows its name followed by the PVID and the volume group it belongs to. "None" in the last column indicates that the disk does not belong to any volume group. "Active" in the last column indicates, that the volume group is varied on. Existence of a PVID indicates possibility of presence of data on the disk. It is possible that such disk belongs to a volume group which is varied off.

Executing lspv with a disk name generates information only about this device:
# lspv hdisk4
PHYSICAL VOLUME:   hdisk4                 VOLUME GROUP:    abc_vg
PV IDENTIFIER:     00c03c8a14fa936b       VG IDENTIFIER:   00c03b1a000
PV STATE:          active
STALE PARTITIONS:  0                      ALLOCATABLE:     yes
PP SZE:           16 megabyte(s)         LOGICAL VOLUMES: 2
TOTAL PPs:         639 (10224 megabytes)  VG DESCRIPTORS:  2
FREE PPs:          599 (9584 megabytes)   HOT SPARE:       no
USED PPs:          40 (640 megabytes)     MAX REQUEST:     256 kb
FREE DISTRIBUTION: 128..88..127..128..128
USED DISTRIBUTION: 00..40..00..00..00
In the case of hdisks, we are able to determine its size, the number of logical volumes (two), the number of physical partitions in need of synchronization (Stale Partitions) and the number of VGDA's. Executing lspv against a disk without a volume group membership does nothing useful:
# lspv hdisk2
0516-304: Unable to find device id hdisk2 in the Device 
configuration database
How do you establish the capacity of a disk that does not belong to a volume group? The next command provides this in megabytes:
# bootinfo -s hdisk2
10240
The same (and much more) information can be retrieved by executing lsattr -El hdisk#:
# lsattr -El hdisk0
PCM             PCM/scsiscsd      Path Control Module   False
algorithm       fail_over         Algorithm             True
dist_err_pcnt   0                 Distributed Error %   True
dist_tw_width   50                Sample Time           True
hcheck_interval 0                 Health Check Interval True
hcheck_mode     nonactive         Health Check Mode     True
max_transfer    0x40000           Maximum TRANSFER Size True
pvid            00c609e0a5ec1460  Volume identifier     False
queue_depth     3                 Queue DEPTH           False
reserve_policy  single_path       Reserve Policy        True
size_in_mb      73400             Size in Megabytes     False
unique_id       26080084C1AF0FHU  Unique identifier     False
The last command can be limited to show only the size if executed as shown:
# lsattr -El hdisk0 -a size_in_mb
size_in_mb 73400 Size in Megabytes False
A disk can get a PVID in one of two ways: by the virtue of membership in a volume group (when running extendvg or mkvg commands) or as the result of execution of the chdev command. Command lqueryvg helps to establish if there is data on the disk or not.
# lqueryvg -Atp hdisk2
0516-320 lqueryvg: hdisk2 is not assigned to a volume group.
Max LVs:        256
PP Size:        26
Free PPs:       1117
LV count:       0
PV count:       3
Total VGDAs:    3
Conc Allowed:   0
MAX PPs per PV  1016
MAX PVs:        32
Quorum (disk):  1
Quorum (dd):    1
Auto Varyon ?:  1
Conc Autovaryo  0
Varied on Conc  0
Physical:       00c03b1a32e50767   1   0
                00c03b1a32ee4222   1   0
                00c03b1a9db2f183   1   0
Total PPs:      1117
LTG size:       128
HOT SPARE:      0
AUTO SYNC:      0
VG PERMISSION:  0
SNAPSHOT VG:    0
IS_PRIMARY VG:  0
PSNFSTPP:       4352
VARYON MODE:    ???????
VG Type:        0
Max PPs:        32512
This disk belongs to a volume group that had three disks:
PV count: 3
Their PVIDs are:
Physical:       00c03b1a32e50767   1   0
                00c03b1a32ee4222   1   0
                00c03b1a9db2f183   1   0
At this time, it does not have any logical volumes:
LV count: 0
It is easy to notice that a disk belongs to a volume group. Logical volume names are the best proof of this. To display data stored on a disk you can use the command lquerypv.

A PVID can be assigned to or removed from a disk if it does not belong to a volume group, by executing the command chdev.
# chdev -l hdisk2 -a pv=clear
hdisk2 changed
lspv | grep hdisk2
hdisk2          none         None
Now, let's give the disk a new PVID:
# chdev -l hdisk2 -a pv=yes
hdisk2 changed
# lspv | grep hdisk2
hdisk2          00c03b1af578bfea    None
At times, it is required to restrict access to a disk or to its capacity. You can use command chpv for this purpose. To prevent I/O to access to a disk:
# chpv -v r hdisk2
To allow I/O:
# chpv -v a hdisk2
I/O on free PPs is not allowed:
# chpv -a n hdisk2
I/O on free PPs is allowed:
# chpv -a y hdisk2
AIX was created years ago, when disks were very expensive. I/O optimization, the decision what part of data will be read/written faster than other data, was determined by its position on the disk. Between I/O, disk heads are parked in the middle. Accordingly, the fastest I/O takes place in the middle. With this in mind, a disk is divided into five bands called: outer, outer-middle, center, inner and inner-edge. This method of assigning physical partitions (logical volumes) as the function of a band on a disk, is called the intra-physical policy. This policy and the policy defining the spread of logical volume on disks (inter-physical allocation policy) gains importance while creating logical volumes.

Disk topology, the range of physical partitions on each band is visualized with command lsvg -p vg_name and lspv hdisk#. Note the last two lines of the lspv:
FREE DISTRIBUTION:  128..88..127..128..128
USED DISTRIBUTION:  00..40..00..00..00
The row labeled FREE DISTRIBUTION shows the number of free PPs in each band. The row labeled USED DISTRIBUTION shows the number of used PPs in each band. As you can see, some bands of this disk have no data. Presently, this policy lost its meaning as even the slowest disks are much faster then their predecesors. In the case of RAID or SAN disks, this policy has no meaning at all. For those who still use individual SCSI or SSA disks, it is good to remember that the data closer to the outer edge is read/written the slowest.

To learn what logical volumes are located on a given disk, you can execute command lspv -l hdisk#. The reversed relation is established executing lslv -M lv_name.

It is always a good idea to know what adapter and what bus any disk is attached to. Otherwise, if one of the disks breaks, how will you know which disk needs to be removed and replaced? AIX has many commands that can help you. It is customary to start from the adapter, to identify all adapters known to the kernel:
# lsdev -Cc adapter | grep -i scsi
scsi0   Available 1S-08    Wide/Ultra-3 SCSI I/O Controller
scsi1   Available 1S-09    Wide/Ultra-3 SCSI I/O Controller
scsi2   Available 1c-08    Wide/Fast-20 SCSI I/O Controller
The last command produced information about SCSI adapters present during the last execution of the cfgmgr command. This output allows you to establish in what drawer the adapter is located as well. The listing, tells us that there are three SCSI adapters. The second colums shows the device state (Available: ready to be used; Defined: device needs further configuration). The next column shows its location (drawer/bus). The last column contains a short description. Executing the last command against a disk from rootvg produces:
# lsdev -Cc disk -l hdisk0
hdisk0 Available 1S-08-00-8,0 16 Bit LVD SCSI Disk Drive
From both outputs we can determine what SCSI adapter controls this disk - scsi0. Also, we see that disk has SCSI ID 8,0. How to determine the type/model/capacity/part number, etc?
# lscfg -vl hdisk0
  hdisk0  U0.1-P2/Z1-A8  16 Bit LVD SCSI Disk Drive (36400 MB)

        Manufacturer................IBM
        Machine Type and Model......IC35L036UCDY10-0
        FRU Number..................00P3831
        ROS Level and ID............53323847
        Serial Number...............E3WP58EC
        EC Level....................H32224
        Part Number.................08K0293
        Device Specific.(Z0)........000003029F00013A
        Device Specific.(Z1)........07N4972
        Device Specific.(Z2)........0068
        Device Specific.(Z3)........04050
        Device Specific.(Z4)........0001
        Device Specific.(Z5)........22
        Device Specific.(Z6)........
You can get more details by executing command: lsattr -El hdisk0.



If you found this useful, here's more on the same topic(s) in our blog:


UNIX Health Check delivers software to scan Linux and AIX systems for potential issues. Run our software on your system, and receive a report in just a few minutes. UNIX Health Check is an automated check list. It will report on perfomance, capacity, stability and security issues. It will alert on configurations that can be improved per best practices, or items that should be improved per audit guidelines. A report will be generated in the format you wish, and the report includes the issues discovered and information on how to solve the issues as well.

Interested in learning more?