Thursday 8 August 2013

Rename Disks-IBM AIX OS

Renaming Disks AIX OS

Scenario 1:

Sometimes disks will drop into the server in an unsatisfactory manner.  That is to say, the naming of the disks will not be ideal.  Let's look at neatening that up.

A reliable way to avoid this is to shutdown VIOS1 and physically remove the disks that you want assigned to it.  That way, there's no way VIOS2 can see them when you bring it up.

You're working on a shiny new 9117-MMC in a dual VIOS (we'll call them VIOS1 and VIOS2) configuration.  You've installed VIOS1 from DVD and are now installing VIOS2.  You have already assigned the DVD drive to the VIOS2 but, in doing so, have revealed the disks from VIOS1 to VIOS2.  When the install is complete and you remove the adapter(s) which enabled VIOS2 to see the disks and DVD drive in VIOS1, you will be left with a configuration similar to below:

# lsdev -Cc disk
hdisk0 Defined 00-08-00 SAS Disk Drive
hdisk1 Defined 00-08-00 SAS Disk Drive
hdisk2 Available 00-08-00 SAS Disk Drive
hdisk3 Available 00-08-00 SAS Disk Drive
hdisk4 Available 00-08-00 SAS Disk Drive
hdisk5 Available 00-08-00 SAS Disk Drive

hdisk0 and hdisk1 are clearly the remnants of the disks from VIOS1 detected during the install of VIOS2.  We'll want to remove them so we're left with:
# lsdev -Cc disk
hdisk2 Available 00-08-00 SAS Disk Drive
hdisk3 Available 00-08-00 SAS Disk Drive
hdisk4 Available 00-08-00 SAS Disk Drive
hdisk5 Available 00-08-00 SAS Disk Drive
And then we can work on renumbering the disks.

Scenario 2:

In particular in large clustered environments where it is sometimes very 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 lspvoutput for a PVID like 00f6048868b4gead.  Of course you can script things to make this easier but it would be great if you didn’t need to do this and that there was a way to rename devices as needed, without resorting to unsupported methods.

There are two different ways for this depending upon the operating system version.

Prior AIX 7.1v Procedure

Let's remove hdisk0 and hdisk1:
# rmdev -l hdisk0 -dR
# rmdev -l hdisk1 -dR

We would now be left with:
# lspv
hdisk2          00c5538409a99b66                   rootvg          active
hdisk3
hdisk4
hdisk5

In order to put these names straight, we need to remove these disks also.  It's worth nothing here that inevitably one of these four disks will be your root volume.  You can't remove or rename that one just yet.
# rmdev -l hdisk3 -dR
# rmdev -l hdisk4 -dR
# rmdev -l hdisk5 -dR

So now:
# lspv
hdisk2          00c5538409a99b66                   rootvg          active

Run cfgmgr:
# cfgmgr
# lspv
hdisk0          00c55384341c6e62                    None      
hdisk1          00cd55a4ae6b676f                    None      
hdisk2          00c5538409a99b66                    rootvg         active
hdisk3          00c553844356f733                    None      

Now you can mirror hdisk2 to hdisk0:
# extendvg rootvg hdisk0
# exit
$ mirrorios -defer hdisk0

When that completes:
# lspv
hdisk0          00c55384341c6e62                    rootvg         active
hdisk1          00cd55a4ae6b676f                    None    
hdisk2          00c5538409a99b66                    rootvg         active
hdisk3          00c553844356f733                    None

Further Juggling and Dump Movement

Sometimes you may want hdisk0 and hdisk1 to be in rootvg.  Here's how to accomplish that.
$ unmirrorios hdisk2

# lspv
hdisk0          00c55384341c6e62                    rootvg         active
hdisk1          00cd55a4ae6b676f                    None    
hdisk2          00c5538409a99b66                    rootvg    
hdisk3          00c553844356f733                    None

hdisk2 is now not mirrored so we can remove it from rootvg:
# reducevg rootvg hdisk2
<error>

This will fail because the sysdumpdev is still set to a volume on hdisk2.  We need to remove this and set it back up later on.

Check the size of the current dump space:
# lsvg -l rootvg | grep sysdump
lg_dumplv           sysdump    4       4       1    open/syncd    N/A

# sysdumpdev -e
0453-041 Estimated dump size in bytes: 233413017

Check the location of the dump device:
# sysdumpdev -l
primary              /dev/lg_dumplv
secondary            /dev/sysdumpnull
copy directory       /var/adm/ras
forced copy flag     TRUE
always allow dump    FALSE
dump compression     ON
type of dump         traditional

This shows us that there is a primary dump device called /dev/lg_dumplv and no secondary dump device.  Since that is the case, we will also add a second boot device in case the primary is not available.

Let's clear the dump configuration:
# sysdumpdev -Pp /dev/sysdumpnull
# sysdumpdev -Ps /dev/sysdumpnull

Check that:
# sysdumpdev -l
primary              /dev/sysdumpnull
secondary            /dev/sysdumpnull
copy directory       /var/adm/ras
forced copy flag     TRUE
always allow dump    FALSE
dump compression     ON
type of dump         traditional

Now we can remove hdisk2 from rootvg.  This may warn you that there is a volume on this device.  The volume will most likely be the dump volume.  If that's the case, you can carry on and remove it.  If it is any other volume then stop and find out what it is.

# reducevg rootvg hdisk2

Create two new volumes for sysdumps:
# mklv -t sysdump -y sysdump1 rootvg 4 hdisk0
# mklv -t sysdump -y sysdump2 rootvg 4 hdisk1

Configure the new dump devices:
# sysdump -Pp /dev/sysdump1
# sysdump -Ps /dev/sysdump2

Check that:
# sysdumpdev -l
primary              /dev/sysdump1
secondary            /dev/sysdump2
copy directory       /var/adm/ras
forced copy flag     TRUE
always allow dump    FALSE
dump compression     ON
type of dump         traditional

Now we want to add hdisk1 into rootvg and mirror:
# extendvg rootvg hdisk1
$ mirrorios -defer hdisk1

Set boot list:
$ bootlist -mode normal hdisk0 hdisk1

Since we have been deferring the restart, do it now:
$ shutdown -restart

Hopefully everything should come up fine and you should have this:
# lspv
hdisk0          00c55384341c6e62                    rootvg         active
hdisk1          00cd55a4ae6b676f                    rootvg         active    
hdisk2          00c5538409a99b66                    None    
hdisk3          00c553844356f733                    None

2. Renaming devices in AIX 7.1

Well, this is no longer an issue for AIX.

Starting with AIX 7.1, you can now easily rename devices. A new command called rendev was introduced to allow AIX administrators to rename devices as required.

From the man page:

The rendev command enables devices to be renamed. The device to be renamed, is specified with the -l flag, and the new desired name is specified with the -n flag.

The new desired name must not exceed 15 characters in length. If the name has already been used or is present in the /dev directory, the operation fails. If the name formed by appending  the new name after the character r is already used as a device name, or appears in the /dev directory, the operation fails.

 If the device is in the Available state, the rendev command must unconfigure the device before renaming it. This is similar to the operation performed by the rmdev -l Name command. If the unconfigure operation fails, the renaming will also fail. If the unconfigure succeeds, the rendev command will configure the device, after renaming it, to restore it to the Available state. The -u flag may be used to prevent the device from being configured again after it is renamed.

 Some devices may have special requirements on their names in order for other devices or applications to use them. Using the rendev command to rename such a device may result in the device being unusable. Note: To protect the configuration database, the rendev command cannot be interrupted once it has started. Trying to stop this command before completion, could result in a corrupted database.

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.
Note: I 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

# mkdev -l inet0
inet0 Available

# 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

If you want to be creative you can rename devices to anything you like (as long as it’s not more than 15 characters). For example 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 in the last example 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. This will fail otherwise.
# rmdev -Rl vscsi1
vscsi1 Defined

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

Now we 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

That was easy enough. 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

Now 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. 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

Reference:

Please refer to the AIX 7.1 command reference for more information on this new command:
http://publib.boulder.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.cmds/doc/aixcmds4/rendev.htm
IBM AIX Version 7.1 Differences Guide:
http://www.redbooks.ibm.com/Redbooks.nsf/RedpieceAbstracts/sg247910.html?Open

www.unixmantra.com

0 blogger-disqus:

Post a Comment