Script to create FLARs

This one will login to a list of servers and create a flar in a NFS share

#!/bin/ksh

for h in `cat hosts.txt`;do
        echo "----------------------- $h"
cat <<EOF  > /tmp/$h
mkdir -p /b; mount -F nfs 10.80.120.219:/space /b; ls /b
time flarcreate -n "$h" -c -S -R / /b/flars/$h.flar
umount /b
EOF
scp /tmp/$h $h:/tmp
ssh $h /tmp/$h
done

Rsync many solaris server’s non-OS filesystems in parallel

This one will run rsyncs in the background for each host it finds in hosts.txt, and save each host’s progress in a log.

#!/bin/ksh
for h in `cat hosts.txt`;do
 echo "----------------------- $h"
 (
 ssh $h df -k | egrep -v 'cdrom|^Filesystem|/$|/devices$|/system/contract$|/proc$|/etc/mnttab$|/etc/svc/volatile$|/system/object$|/etc/dfs/sharetab$|/dev/fd$|/tmp$|/var$|/var/run$|/dev/vx/dmp$|/dev/vx/rdmp$|/cores$|/var/crash$' | awk '{ print $NF }' | while read l;do
 mkdir -p /space/$h$l
 echo "rsync --progress -zrtva $h:$l/ /space/$h$l/"
 rsync --progress -zrtva $h:$l/ /space/$h$l/
 done
 ) 2>&1 > ${h}.log &
 done

Solaris Trusted Extensions

To disable:

– for each zone

zonecfg -z thezone export > thezone.zcfg
zoneadm -z thezone halt
zoneadm -z thezone detach
zonecfg -z thezone delete

– disable the labeld service

svcadm disable labeld

– reboot the server

– verify with the command “plabel”

– recreate the zones

zonecfg -z thezone -f thezone.zcfg
zoneadm -z thezone attach
zoneadm -z thezone boot

liveupgrade if you have SVM metadevices

if you have SVM (solaris volume manager,disk suite,metadevices), you can still liveupgrade….

consider this scenario, the OS lives in mirrored disks d0,d3,d4,d6:

root@myserver # df -h | grep -i md
/dev/md/dsk/d0 4.9G 3.2G 1.7G 66% /
/dev/md/dsk/d3 9.9G 4.1G 5.7G 42% /usr
/dev/md/dsk/d4 9.9G 3.4G 6.3G 35% /var
/dev/md/dsk/d6 101G 7.5G 93G 8% /opt
/dev/md/dsk/d5 4.9G 4.6G 336M 94% /spare

the metadevices look like this:

d0 -m d10 d20 1
d10 1 1 c1t0d0s0
d20 1 1 c1t1d0s0
d6 -m d16 d26 1
d16 1 1 c1t0d0s6
d26 1 1 c1t1d0s6
d5 -m d15 d25 1
d15 1 1 c1t0d0s5
d25 1 1 c1t1d0s5
d4 -m d14 d24 1
d14 1 1 c1t0d0s4
d24 1 1 c1t1d0s4
d3 -m d13 d23 1
d13 1 1 c1t0d0s3
d23 1 1 c1t1d0s3
d1 -m d11 d21 1
d11 1 1 c1t0d0s1
d21 1 1 c1t1d0s1

So we create two Boot Environments (BE), sol10u6(the current), and sol10u9(the one that will be upgraded)

lucreate -c sol10u6 -n sol10u9 
-m /:/dev/md/dsk/d40:ufs,mirror -m /:/dev/dsk/c1t0d0s0:detach,attach,preserve 
-m /usr:/dev/md/dsk/d43:ufs,mirror -m /usr:/dev/dsk/c1t0d0s3:detach,attach,preserve 
-m /var:/dev/md/dsk/d44:ufs,mirror -m /var:/dev/dsk/c1t0d0s4:detach,attach,preserve 
-m /opt:/dev/md/dsk/d46:ufs,mirror -m /opt:/dev/dsk/c1t0d0s6:detach,attach,preserve

Notice we create the alternate metadevices d40,d43,d44 and d46, to substitute d0,d3,d4 and d6 in the sol10u9 BE.

when we boot from the sol10u6 BE we will still see d0,d3,d4 and d6, when we boot the sol10u9 BE we will see  d40,d43,d44 and d46.

Next, we create the file to skip auto registration:

# echo "autoreg=disable" > /var/tmp/no-autoreg

Now we run the upgrade:

# luupgrade -k /var/tmp/no-autoreg -u -n sol10u9 -s /sol10u9

after the upgrade, we activate the sol10u9 BE

# luactivate sol10u9

Now, we restart the server, do not use “reboot”!

# init 6

Luckily the server comes up with sol10u9

install a solaris package non-interactively

create an “admin file” with these contents

mail=
instance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=nocheck
setuid=nocheck
conflict=nocheck
action=nocheck
networktimeout=60
networkretries=3
authentication=quit
keystore=/var/sadm/security
proxy=
basedir=default

then, install the package:

cd /var/tmp;pkgadd -a /var/tmp/adminfile.txt -d ./pkgutil.pkg CSWpkgutil