Renaming hdisk on AIX

From MyWiki

Jump to: navigation, search

This was taken from Karsten Seresse email:

> Is there any possibility to rename hdisks in AIX 5.2 ?
> I do not want to rename the rootvg, but external harddisks.
> I know that the System is working with PVID and the hdisk name does not matter, but for administration reasons it would be useful for me.
>
> Any hints are welcome.

If you want to do it by the book, you need to remove the
disks inquestion, create dummy disks with mkdev and then
let cfgmgr "find" the disks again and assign them the new
numbers.

However, there is a more, let's say, direct approach for
the not so faint at heart. ;-)

DISCLAIMER: USE AT YOUR OWN RISK, NO WARRANTIES! I have
tested this on my 43P test box and it worked, but it
may still lead to some issues in a production
evironment! Handle with care!

Having said that: if you want to rename the disks in a
VG which is varyoff at the moment, here's how to do it.
In this case, we have hdisk1 in the testvg, currently
not active, which needs to be changed to hdisk9:

# lspv
hdisk0     004b559ad50d68af    rootvg          active
hdisk1     004b559a5b094213    testvg

We need the CuDv and CuAt stanzas for that disk from the
ODM:

# odmget -q 'name = hdisk1' CuAt > CuAt.hdisk1
# odmget -q 'name = hdisk1' CuDv > CuDv.hdisk1
# cat *.hdisk1

CuAt:
        name = "hdisk1"
        attribute = "unique_id"
        value = "1E0868269AAD07DGHS09U03IBMscsi"
        type = "R"
        generic = ""
        rep = "nl"
        nls_index = 79

CuAt:
        name = "hdisk1"
        attribute = "pvid"
        value = "004b559a5b0942130000000000000000"
        type = "R"
        generic = "D"
        rep = "s"
        nls_index = 2
.....

We copy the stanzas and edit them so every instance of
hdisk1 is changed to hdisk9:

# cp CuAt.hdisk1 CuAt.hdisk9
# cp CuDv.hdisk1 CuDv.hdisk9
# # now :%s/hdisk1/hdisk9/ in *.hdisk9

Now we change the ODM entries:

# odmchange -o CuDv -q 'name = hdisk1' CuDv.hdisk9
# odmchange -o CuAt -q 'name = hdisk1' CuAt.hdisk9

Checking that the changes are correct:

# odmget -q 'name like hdisk*' CuDv

CuDv:
        name = "hdisk0"
        status = 1
        chgstatus = 2
        ddins = "scdisk"
        location = "10-60-00-8,0"
        parent = "scsi0"
        connwhere = "8,0"
        PdDvLn = "disk/scsi/scsd"

CuDv:
        name = "hdisk9"
        status = 1
        chgstatus = 2
        ddins = "scdisk"
        location = "10-60-00-9,0"
        parent = "scsi0"
        connwhere = "9,0"
        PdDvLn = "disk/scsi/scsd"
# odmget -q 'name like hdisk*' CuAt
.....

You'll see that all hdisk1 entries were changed to hdisk9.
Now we change the device files to the correct name:

# mv /dev/hdisk1 /dev/hdisk9
# mv /dev/rhdisk1 /dev/rhdisk9

(yes, you can do that, it works) and we need to save
the ODM changes to the bootblock:

# bosboot -ad /dev/hdisk0

bosboot: Boot image is 18004 512 byte blocks.

In theorie, you could varyon the testvg now. But to make
sure the changes are permanent, we restart the system:

# shutdown -Fr
.....
# lspv
hdisk0          004b559ad50d68af                    rootvg          active
hdisk9          004b559a5b094213                    testvg          active
#

Voila! :-)

Have fun ...

   Andreas

-- 
Dipl.-Phys. Andreas Leibl
IBM Certified Advanced Technical Expert
IBM Business Services GmbH, External Contractor
Personal tools