Topic
6 replies Latest Post - ‏2013-02-27T17:10:32Z by SystemAdmin
SystemAdmin
SystemAdmin
6908 Posts
ACCEPTED ANSWER

Pinned topic AIX mksysb - changing hostname and IP address with a customization script ?

‏2009-07-21T20:25:02Z |
Hello,

I'm trying to configure a mksysb with a customization script in order to change the hostname and the ethernet configuration after the mksysb restore.
I have a lpar1 (in production, always up) and I need to configure a lpar2 with a mksysb from lpar1, the problem is there will be conflicts with the same hostname and same IP address.
I wonder if I can use a customization script for changing the hostname to "lpar2" and the ethernet configuration after the mksysb restore.
I didn't found any example on the web.

Configuration :
OSlevel : AIX 5200-08-00

Thank you for your help !
Updated on 2013-02-27T17:10:32Z at 2013-02-27T17:10:32Z by SystemAdmin
  • orphy
    orphy
    480 Posts
    ACCEPTED ANSWER

    Re: AIX mksysb - changing hostname and IP address with a customization script ?

    ‏2009-07-21T21:24:24Z  in response to SystemAdmin
    Do you have physical access to the LPAR? If so, you could make unplugging the RJ-45 as part of the restore procedure. Depending on how many restores you have to do, you might or might not want to spend all that time on the customization. In any case, you could always do something like this:

    • unplug RJ-45(s)
    • restore mksysb
    • run script (manually or through inittab)
    • plug back RJ-45(s)

    Now, if you do SEAS and other setup, things would get more complex.
    Orphy
    • dukessd
      dukessd
      337 Posts
      ACCEPTED ANSWER

      Re: AIX mksysb - changing hostname and IP address with a customization script ?

      ‏2009-07-21T23:18:33Z  in response to orphy
      And don't forget the recfgct to get the RMC key updated for DLPAR, etc.
  • Montecarlo
    Montecarlo
    51 Posts
    ACCEPTED ANSWER

    Re: AIX mksysb - changing hostname and IP address with a customization script ?

    ‏2009-07-22T07:23:55Z  in response to SystemAdmin
    If your target for the mksysb restore is defined to the nim master, then leaving the default "yes" to Remain NIM client after install? will result in the target lpar host name and ip address being reset to the NIM defined hostname and ip address.
    Regards, Simon
  • SystemAdmin
    SystemAdmin
    6908 Posts
    ACCEPTED ANSWER

    Re: AIX mksysb - changing hostname and IP address with a customization script ?

    ‏2009-07-23T15:09:41Z  in response to SystemAdmin
    Hello,

    Thanks for your answers,
    We can't unplug the RJ45, and I tried different options on the HCM, it doesn't change anything.
    I tried again with a customization script, the script worked ("touch" test files, changing the "hostname" and the "enX")
    But the mksysb restore recover the configuration with the step "Copying Cu* to disk"
    So, impossible to change the hostname and ethernet configuration automatically after a mksysb restore.

    "After installing the backup image, the installation program reconfigures the Object Data Manager (ODM) on the target system. If the target system does not have exactly the same hardware configuration as the source system, the program might modify device attributes in the following target system files:

    • All files in /etc/objrepos beginning with Cu

    • All files in the /dev directory "
    • orphy
      orphy
      480 Posts
      ACCEPTED ANSWER

      Re: AIX mksysb - changing hostname and IP address with a customization script ?

      ‏2009-07-23T16:50:24Z  in response to SystemAdmin
      In that case, you might want to look at rc.boot to see if you can stick your own script there to fix the network setup prior to finishing up the 1st boot after a restore. Another way might be to add an entry of install_assist back in inittab prior to creating the mksysb but don't forget to rmitab it when the mksysb is done! If you decide to play with rc.boot, you must be very very careful since any oops could render your production not to boot up the next time!
      Orphy
  • SystemAdmin
    SystemAdmin
    6908 Posts
    ACCEPTED ANSWER

    Re: AIX mksysb - changing hostname and IP address with a customization script ?

    ‏2013-02-27T17:10:32Z  in response to SystemAdmin
    This is only 4 years late, but encase others come here looking for an answer.

    One method to accomplish this is to change the source network adapter to be 'down' in the ODM.

    # chdev -l en0 -a state='down' '-P'

    You can then setup a first boot script or some rc.local script (setup in the inittab before rc.tcpip). Below is a sample of a script I wrote to boot a DR LPAR with a different IP if it's on the production vlan. In our environment the production vlans are 3 digits and the test bubble vlans are 4 digits.

    Note that the last thing the scripts does is to reset the adapter to 'down' in the ODM.

    The adapter has to be down because when rc.boot calls cfgmgr the ODM setting are used to configure the adapter and if it's up you can get a duplicate IP error.

    If you're running on dedicated hardware you can key off the serial number. and set the IP via a case statement.
    Good luck with this and I hope the script helps,
    Allan

    • SCRIPT /etc/rc.dr ---
    #! /usr/bin/ksh -x

    export PATH=/usr/bin:/etc:/usr/sbin:/sbin:/usr/ccs/bin:.

    uname -L | read ID LPAR

    HOSTNAME="$(hostname -s | perl -pe 's/.*_//; s/-.*//;' )"
    DNS="-n172.30.105.61 -dfossil.com"
    GW="$( lsattr -El inet0 -a route -F value | awk -F, '{print $NF}' )"
    IP="$( grep -wi "${HOSTNAME}" /etc/hosts | egrep -v "dr_|-dr" | awk '{print $1}' | cut -f1-3 -d\. )"

    for ENT in $( lsdev -Cc adapter | awk '/^ent/{print $1}' )
    do
    EN="$( echo ${ENT} | sed 's/t//' )"
    IP="$( lsattr -El ${EN} -a netaddr -F value | grep ^${IP:-'172'} )"
    [ -n ${IP} ] && break
    done

    NETMASK="$( lsattr -El ${EN} -a netmask -F value )"
      • If this is a test dr lpar then check if we are in a bubble. (VLANS 2248 and 2101)
    if echo ${LPAR} | grep -qi ^drtst
    then

    #-- Isolate from DNS in Norm because we can't reach it in Prod so we don't use it
    mv /etc/resolv.conf /etc/resolv.drtst

    #-- Get the etherchannel adapters as these are the ones that we'll be configuring
    entstat -d ${ENT} > /tmp/${ENT}.out

    #-- Check to see if there's a 3 digit vlan if so then assume we're on the production network not a bubble
    PROD=$( perl -ne 'chomp;if(/port\s+vlan\s+id:\s+(\d+.*)|vlan\s+tag\s+ids:\s(\d+.*)/i){print "$1 "}' /tmp/${ENT}.out |
    perl -ne 'if( /\b\d\d\d\b/ ){print "1"} else {print "0"}' )

    if (( PROD ))
    then
    #-- Ok so we in a TEST DR LPAR on the production network - RESET EVERYTHING
    IP="$( grep -wi "${HOSTNAME}-dr" /etc/hosts | awk '{print $1}' )"
    DNS=""

    #-- Make sure cron and TSM are off
    perl -i -pe 'if( /^(cron|dsm|errreporter|db|ora)/ ){s/^/:/}' /etc/inittab
    else
    perl -i -pe 'if( /^(cron|dsm|errreporter|db|ora|rcnfs)/ ){s/^/:/}' /etc/inittab
    fi

    telinit q
    mkdev -l iocp0
    chdev -l iocp0 -P -a autoconfig='available'
    fi

      • Setup the network based on the discovered environment
    /usr/sbin/mktcpip -h"${HOSTNAME}" -a"${IP:-8.8.8.8}" -m"${NETMASK:-255.255.255.0}" -i"${EN}" ${DNS} -g"${GW}" -A'no' -t'N/A'
    chdev -l ${EN} -a state='up' '-P'

    ( sleep 300 && startsrc -s sshd ) &
    ( sleep 300 && chdev -l ${EN} -a state='down' '-P' ) &