[OpenIndiana-discuss] copying a reference installation to other hosts

Udo Grabowski (IMK) udo.grabowski at kit.edu
Tue Mar 5 09:48:33 UTC 2013


On 05/03/2013 09:47, Hans J. Albertsson wrote:
> Suppose one has several machines, all intended to run exactly the same
> software.
> Suppose one gets one of them absolutely perfect, and one wants all the
> other, electronically identical, machines to have exactly the same
> software installed: What is the easiest way?
>
> Generate a list of packages and config details ( how to do that???
> getting a list of packages is straight-forward, but config details?? )
> and install from that list after a bit of editing and scripting it?
>
> Do a replication of the rpool to a disk intended for another system??
> Uggh. I want a way that doesn't include opening up a server.
>
> Or some third way??

We found that none of the official ways (flar,auto-install, etc.)
does exactly this, so we use a replication scheme which works
along the lines below (adapt to your needs, depending on software,
there may be more places where a hostname must be changed, e.g.,
webmin, or crypto keys have to be exchanged, etc.).
This scheme also works when replicating to different
hardware, so you can essentially run a quasi one-image policy.
You can also embed this (better automated) script into the boot-archive
to implement a variant of auto-install, we use this to install our
blade farm.
Beware, that script constantly has to be adapted, it usually
never works at once (e.g., disk number always is different)....
(Note that there are some unintended line breaks below from the mailer)

#!/bin/bash
# STATUS: ug 05-Mar-2013
# install machine <name> with single <ip>
# start from running live DVD
#
if [ -z "$1" -o -z "$2" ]; then
   echo "Usage:install_script <name> <ip>"
   exit 1
fi
# config
export HOME=/root
export PATH=/usr/bin:/usr/X11/bin:/usr/sbin:/sbin
DEV=e1000g0
IP_BASE=192.168.1.
SOURCE_IP=<your_source_ip_in_$IPBASE>
SOURCE_FS=rpool/ROOT/openindiana-7
DEF_ROUT=<your_gateway_ip>
DOMAIN=<yourdomain>
DISK=c5t0d0p0
#===================================================
IP=${IP_BASE}$2
NAME=$1
echo $NAME>/etc/hostname.$DEV
echo $NAME>/etc/test
mv /etc/test /etc/nodename
hostname $NAME
#
# prepare a bare minimum hosts file
# for network to reach source machine
#
cat >/etc/hosts<<EOT
::1        localhost
127.0.0.1  localhost
$IP $NAME $NAME.$DOMAIN loghost
$SOURCE_IP $SOURCE
EOT
#
# prepare network
#
echo $DEF_ROUT>/etc/defaultrouter
svcadm disable nwam
svcadm enable svc:/network/physical:default
ifconfig ${DEV} unplumb
ifconfig ${DEV} plumb
ifconfig ${DEV} ${IP} netmask 255.255.255.0 broadcast ${IP_BASE}255 up
fi
svcadm restart network/physical:default
# Wait for network up
ifconfig -a
while ! ping $SOURCE 1; do sleep 2;echo ;echo "ping $SOURCE...">/dev/console; done
echo "starting installation">/dev/console
#
# format disk
#
devfsadm
echo "formatting disk ${DISK}">/dev/console
fdisk -B ${DISK}
format ${DISK}
prtvtoc /dev/rdsk/${DISK}
DISK=`echo ${DISK}|sed 's/p0/s0/'`
#
# copy rpool from source machine (passwords needed!)
#
zpool create -f rpool ${DISK}
echo "copying rpool to ${DISK}, wait ...">/dev/console
ssh -p 24 -c blowfish-cbc rootcsh@$SOURCE "zfs send ${SOURCE_FS}@install"|zfs 
receive -d rpool
echo "rpool copied">/dev/console
zfs set canmount=on rpool/ROOT
zfs set mountpoint=/rpool/ROOT rpool/ROOT
zfs set canmount=on ${SOURCE_FS}
zfs set mountpoint=/${SOURCE_FS} ${SOURCE_FS}
sleep 20
cd /${SOURCE_FS}/
#
# delete source machines devices and copy devs
# generated from live DVD below present devs
# This works over different hardware
#
mount -F lofs -o nosub / /mnt
rm -rf dev devices
(cd /mnt;tar cvf - devices dev)|tar xf -
umount /mnt
cp /etc/path_to_inst etc
#
# overwrite source machines name,ID,key entries
#
echo $NAME > etc/nodename
rm -f etc/hostname.*
rm etc/hostid
echo $NAME > etc/hostname.${DEV}
cp /etc/inet/hosts etc/inet/
dbus-uuidgen>var/lib/dbus/machine-id
rm etc/ssh/ssh_host*
ssh-keygen -N '' -P '' -b 1024 -t rsa -f etc/ssh/ssh_host_rsa_key
ssh-keygen -N '' -P '' -b 2048 -t dsa -f etc/ssh/ssh_host_dsa_key
svcadm restart ssh
#
# prepare grub, some swap and dump space
#
cp /etc/zfs/zpool.cache etc/zfs/
scp -r -P 24 ${SOURCE}:/rpool/boot /rpool
zpool set bootfs=${SOURCE_FS} rpool
zfs create -V 4g rpool/swap
zfs create -V 2g rpool/dump
bootadm update-archive -R /${SOURCE_FS}
installgrub boot/grub/stage1 boot/grub/stage2 /dev/rdsk/${DISK}
touch reconfigure
cd
#
# set required zfs properties for rpool
#
zfs set mountpoint=/ ${SOURCE_FS}
zfs set canmount=noauto ${SOURCE_FS}
zfs mountpoint=legacy rpool/ROOT
zfs set canmount=off rpool/ROOT
zfs set org.opensolaris.caiman:install=ready rpool
zfs set primarycache=all ${SOURCE_FS}
zfs set secondarycache=all ${SOURCE_FS}
echo "installation done">/dev/console

#init 6


-- 
Dr.Udo Grabowski    Inst.f.Meteorology a.Climate Research IMK-ASF-SAT
www.imk-asf.kit.edu/english/sat.php
KIT - Karlsruhe Institute of Technology            http://www.kit.edu
Postfach 3640,76021 Karlsruhe,Germany  T:(+49)721 608-26026 F:-926026



More information about the OpenIndiana-discuss mailing list