This Hint and Tips document discusses how to get the partition number on AIX partitions. In a partitioned environment, AIX system administrators sometimes need to distinguish several partitions on a single partitioning-capable pSeries server to automatically customize system settings, such as host name, IP address, and so on, using a shell script.
The uname command has been enhanced to show the partition number using the -L option. If you run uname -L on an AIX partition, you will see the following output:
1 lpar01
Where:
1 Partition number (unique for each partition)
lpar01 Partition name
If you run this command on AIX that is not running in a partitioned environment, you will see the following output:
NULL host_name
If you need to write a shell script to determine the partition number, it is advised that you use the following code fraction example:
LANG=C uname -Ls | \
read junk partition_number partition_name
The -L option of the uname command only returns the partition number and partition name on AIX 5L Version 5.2 or AIX 5L Version 5.1 Recommended Maintenance Level 5100-03 or later, but it returns one additional string ("AIX") on AIX 5L Version 5.1 Recommended Maintenance Level 5100-02, as shown in the following example:
AIX 1 lpar01
Therefore, if you add the -s option of uname, it ensures that you always receive the consistent output from uname, regardless of the AIX maintenance level.
No comments:
Post a Comment