I recently got an email from Dan Aldridge with some information about a very handy AIX command, "chdef". I wasn't familiar with this command before, and it is super-useful, so I thought I would write a quick post about it..
When AIX devices are created (or re-created) they take on default values for the device attributes. For example, an HBA (fcs) device has "fc_err_recov" and "dyntrk" attributes. The default values for these attributes are almost certainly not what you want to have set. Normally you have to manually set the attributes to what you want for a FCS adapter (normally "fc_err_recov=fast_fail" / "dyntrk=yes"). If you forget to set these right when the devices are created/re-created it can be a big pain because it requires the device to not be in use for a lot of settings like this to be changed, so you generally have to reboot.
Even if you go through all your servers and change attributes like "fc_err_recov" and "dyntrk" to what you want, these settings tend to slowly revert back to their original, default AIX values because any time the devices are deleted/re-created they inherit their default values. So if you set "fc_err_recov" and "dyntrk" and then another SA did maintenance on the server and happened to delete/re-create these devices then the settings would get reverted back to the AIX defaults. Or if you added in some extra HBA devices they would automatically get the AIX default attribute values.
Now, there has always been the possibility of hacking the AIX ODM directly (PdAt) to change the default values, but this is not straight forward at all and you can easily mess things up badly if you are messing around with the ODM.
Recently AIX introduced a new command named "chdef" that allows you to change default attribute values. This way, anytime you delete/re-create devices, or add new devices to AIX, they will automatically have the attribute values you want.
In addition, if you change an attributes default value with chdef, all of the current devices will take on this default value unless you had specifically set them to have a value (if they used the default before, and you change the default with chdef, then all current devices inherit the new default). The only "gotcha" here is that if it is an attribute that requires a reboot to take effect you need to reboot for the new default attribute to become active for all the current devices (even though "lsattr" will lie and appear to show that it is active even though you need a reboot, similar to what "chdev -P" causes. You can use "lsattr -P" to see this if running very new AIX versions). If you had specifically set a device to have a value for one of their attributes, it will not be changed when you use "chdev" to change the default.
The syntax for "chdef" is:
-a attribute=value -c <Class> -s <subclass> -t <type>
For example, to change the default value for the "hcheck_interval" attribute to "60", run:
chdef -a hcheck_interval=60 -c disk -s vscsi -t vdisk
If you run "chdef" by itself it will list out all of the default attribute values that have been set with the "chdef" command.
Now, your next question is probably "How do I figure out the Class, Subclass, and Type of a device so I can change its default values with chdef???". Well, luckily we can easily find this with some flags on "lsdev":
# lsdev -H -F "name class subclass type" | grep hdisk
hdisk0 disk vscsi vdisk
hdisk1 disk vscsi vdisk
hdisk2 disk vscsi vdisk
So in this example we can see that these hdisks have a class of "disk", a subclass of "vscsi", and a type of "vdisk". You can grep for different devices other than hdisks to find their information, for example vscsi:
# lsdev -H -F "name class subclass type" | grep ^vscsi
vscsi0 adapter vdevice IBM,v-scsi
vscsi1 adapter vdevice IBM,v-scsi
vscsi2 adapter vdevice IBM,v-scsi
"chdef" is really an awesome feature in AIX. If your orginization has standards for what attributes get set, then you should use "chdef" to set these default values. This will make your job much easier, help you achieve higher compliance levels across all your servers, and reduce the number of times you need to reboot servers to change out of compliant attributes.
Here are a couple more examples:
Chage default vscsi_path_to to 30:
# chdef -a vscsi_path_to=30 -c adapter -s vdevice -t IBM,v-scsi
Change default vscsi_err_recov to fast_fail:
# chdef -a vscsi_err_recov=fast_fail -c adapter -s vdevice -t IBM,v-scsi