Tuesday 19 March 2013

AIX Makes Renaming Devices Easy

“The easy way to get network adapters and disk names to match between systems would be to run something like:
# chdev –l old_name –n new_name
Except, this command option does NOT exist.”
Since then, I’ve been on the look out for an easy way to rename devices in AIX. Particularly in large, clustered environments, it’s sometimes important to have the same disk and network device names in sync, across all nodes in a cluster. And besides, it’s a lot easier to verify a cluster configuration if the hdisk names are all the same.
Matching PVIDs works, but it requires a lot more effort! For example, knowing that hdisk123 is the same device on all nodes makes life easier than scanning lspv output for a PVID like 00f6048868b4gead. Of course, you can script things to make this easier, but it would be better if you could rename devices as needed, without resorting to unsupported methods.

A Better Approach

Well, this is no longer an issue for AIX. Starting with AIX 7.1 (and AIX 6.1 TL6), you can easily rename devices. A new command called rendev was introduced to allow administrators to rename devices as required. From the main page:
“The rendev command enables devices to be renamed.
...the rendev command must unconfigure the device before renaming it.
This functionality was required to help simplify cluster device configuration with the new Cluster Aware AIX (CAA) feature in AIX 7.1.
Here are some examples of using the rendev command on AIX 7.1 (GA) system. In the first example, I will rename hdisk3 to hdisk300. Note: hdisk3 is not in use (busy). If the disk had been allocated to a volume group, I would have needed to varyoff the volume group first.
# lspv
hdisk0    00f61ab2f73e46e2    rootvg
active
hdisk1    00f61ab20bf28ac6     None
hdisk2    00f61ab2202f7c0b     None
hdisk4    00f61ab20b97190d     None
hdisk3    00f61ab2202f93ab     None

# rendev -l hdisk3 -n hdisk300

# lspv
hdisk0    00f61ab2f73e46e2     rootvg
active
hdisk1    00f61ab20bf28ac6     None
hdisk2    00f61ab2202f7c0b     None
hdisk4    00f61ab20b97190d     None
hdisk300  00f61ab2202f93ab     None



Easy! Next, I’ll rename a virtual SCSI adapter. I renamed vscsi0 to vscsi2 and placed the adapter, vscsi0, in a Defined state before renaming the device:
# rmdev -Rl vscsi0

# lsdev -Cc adapter
ent0   Available   Virtual I/O Ethernet Adapter (l-lan)
ent1   Available   Virtual I/O Ethernet Adapter (l-lan)
vsa0   Available   LPAR Virtual Serial Adapter
vscsi0   Defined     Virtual SCSI Client Adapter
vscsi1   Available   Virtual SCSI Client Adapter

# rendev -l vscsi0 -n vscsi2

# lsdev -Cc adapter
ent0   Available   Virtual I/O Ethernet Adapter (l-lan)
ent1   Available   Virtual I/O Ethernet Adapter (l-lan)
vsa0   Available   LPAR Virtual Serial Adapter
vscsi1   Available   Virtual SCSI Client Adapter
vscsi2   Defined     Virtual SCSI Client Adapter

Now, I’ll rename a network adapter from ent0 to ent10. I bring down the interface before changing the device name:
# lsdev -Cc adapter
ent0   Available   Virtual I/O Ethernet Adapter (l-lan)
ent1   Available   Virtual I/O Ethernet Adapter (l-lan)
vsa0   Available   LPAR Virtual Serial Adapter
vscsi1   Available   Virtual SCSI Client Adapter
vscsi2   Defined     Virtual SCSI Client Adapter

# ifconfig en0
en0:
flags=1e080863,480< UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,
GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN >
    inet 10.1.20.19 netmask 0xffff0000 broadcast
10.153.255.255
    tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1

# ifconfig en0 down detach

# rendev -l ent0 -n ent10

# lsdev -Cc adapter
ent1    Available   Virtual I/O Ethernet Adapter (l-lan)
ent10   Available   Virtual I/O Ethernet Adapter (l-lan)
vsa0    Available   LPAR Virtual Serial Adapter
vscsi1  Available   Virtual SCSI Client Adapter
vscsi2  Defined     Virtual SCSI Client Adapter

# rendev -l en0 -n en10

# chdev -l en10 -a state=up
en10 changed

# ifconfig en10
en10:
flags=1e080863,480< UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST
,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN >
    inet 10.1.20.19 netmask 0xffff0000 broadcast
10.153.255.255
    tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1




You can even get creative and rename devices to anything you like (as long as it’s not more than 15 characters). I’ll rename vscsi2 to myvscsiadapter:
# rendev -l vscsi2 -n myvscsiadapter
# lsdev -Cc adapter
ent1        Available   Virtual I/O Ethernet Adapter (l-lan)
myadapter   Available   Virtual I/O Ethernet Adapter (l-lan)
myvscsiadapter   Defined   Virtual SCSI Client Adapter
vsa0        Available   LPAR Virtual Serial Adapter
vscsi1      Available   Virtual SCSI Client Adapter

And finally, I’ll demonstrate changing virtual SCSI adapter device names on a live system. This is single disk system (hdisk0), with two vscsi adapters:
# lspv
hdisk0    00f6048868b4deee     rootvg
active

# lspath
Enabled hdisk0 vscsi0
Enabled hdisk0 vscsi1


# lsdev -Cc adapter
ent0    Available   Virtual I/O Ethernet Adapter (l-lan)
ent1    Available   Virtual I/O Ethernet Adapter (l-lan)
vsa0    Available   LPAR Virtual Serial Adapter
vscsi0  Available   Virtual SCSI Client Adapter
vscsi1  Available   Virtual SCSI Client Adapter
We ensure the adapter is in a Defined state before renaming it, otherwise it will fail:
# rmdev -Rl vscsi1
vscsi1 Defined
# lsdev -Cc adapter | grep vscsi
vscsi0    Available    Virtual SCSI Client Adapter
vscsi1    Defined      Virtual SCSI Client Adapter
We then rename the adapter vscsi1 to vscsi3:
# rendev -l vscsi1 -n vscsi3

# lsdev -Cc adapter | grep vscsi
vscsi0    Available    Virtual SCSI Client Adapter
vscsi3    Defined      Virtual SCSI Client Adapter
Now, I need to bring the adapter and path online with cfgmgr. The lspath output displays an additional path to vscsi3:
# lspath
Enabled hdisk0 vscsi0
Defined hdisk0 vscsi1

# cfgmgr
Method error (/etc/methods/cfgscsidisk -l hdisk0 ):
0514-082 The requested function could only be performed for some of the specified paths.

# lspath
Enabled hdisk0 vscsi0
Defined hdisk0 vscsi1
Enabled hdisk0 vscsi3



Next, I need to remove the old path to vscsi1. The path to vscsi3 is now Enabled. The adapter, vscsi3, is in an Available state. All is good.
# rmpath -l hdisk0 -p vscsi1 -d
path Deleted

# lspath
Enabled hdisk0 vscsi0
Enabled hdisk0 vscsi3

# lsdev -Cc adapter | grep vscsi
vscsi0   Available   Virtual SCSI Client Adapter
vscsi3   Available   Virtual SCSI Client Adapter

The same steps need to be repeated for the vscsi0 adapter. This is renamed to vscsi2.
# rmdev -Rl vscsi0
vscsi0 Defined
# lsdev -Cc adapter | grep vscsi
vscsi0   Defined    Virtual SCSI Client Adapter
vscsi3   Available  Virtual SCSI Client Adapter

# rendev -l vscsi0 -n vscsi2

# lsdev -Cc adapter | grep vscsi
vscsi2   Defined     Virtual SCSI Client Adapter
vscsi3   Available   Virtual SCSI Client Adapter

# lspath
Defined hdisk0 vscsi0
Enabled hdisk0 vscsi3

# cfgmgr
Method error (/etc/methods/cfgscsidisk -l hdisk0 ):
0514-082 The requested function could only be performed for some of the specified paths.

# lspath
Defined hdisk0 vscsi0
Enabled hdisk0 vscsi2

Enabled hdisk0 vscsi3

# rmpath -l hdisk0 -p vscsi0 -d
path Deleted

# cfgmgr
# lspath
Enabled hdisk0 vscsi2
Enabled hdisk0 vscsi3
That’s it. Both adapters have been renamed while the system was in use with no downtime required.
# lsdev -Cc adapter | grep vscsi
vscsi2   Available    Virtual SCSI Client Adapter
vscsi3   Available    Virtual SCSI Client Adapter

# lspath
Enabled hdisk0 vscsi2
Enabled hdisk0 vscsi3

References

For more on this new command, see the AIX 7.1 command reference:

No comments:

Post a Comment