AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
  • 1.  AIX mksysb - changing hostname and IP address with a customization script ?

    Posted Tue July 21, 2009 04:25 PM

    Originally posted by: SystemAdmin


    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 !


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

    Posted Tue July 21, 2009 05:24 PM

    Originally posted by: orphy


    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


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

    Posted Tue July 21, 2009 07:19 PM

    Originally posted by: dukessd


    And don't forget the recfgct to get the RMC key updated for DLPAR, etc.


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

    Posted Wed July 22, 2009 03:24 AM

    Originally posted by: Montecarlo


    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


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

    Posted Thu July 23, 2009 11:10 AM
      |   view attached

    Originally posted by: 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 "


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

    Posted Thu July 23, 2009 12:50 PM

    Originally posted by: orphy


    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


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

    Posted Wed February 27, 2013 12:11 PM

    Originally posted by: 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' ) &