All entries for Tuesday 17 September 2013

September 17, 2013

Having fun with Oracle's Solaris 11.1 Automated Installer

I thought I'd provide a complete script that will derive a manifest. This one will create a swap that is the size of the memory of the machine and create a mirrored root with a spare disk:

#!/bin/ksh93 -vx
# Create a mirrored root pool plus a spare disk in the pool for all the disks on the machine
# (apart from the annoying USB disk)
# Mount some filesystems


MFST=/tmp/base_manifest.xml
cat <<HERE >${MFST}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE auto_install SYSTEM "file:///usr/share/install/ai.dtd.1">
<auto_install>
<ai_instance name="orig_default" auto_reboot="false">
<software type="IPS">
<destination>
<image>
<!-- Specify locales to install -->
<facet set="false">facet.locale.*</facet>
<facet set="true">facet.locale.en</facet>
<facet set="true">facet.locale.en_GB</facet>
</image>
</destination>
<source>
<publisher name="solaris">
<origin name="http://servername/solaris"/>
</publisher>
</source>
<!--
By default the latest build available, in the specified IPS
repository, is installed. If another build is required, the
build number has to be appended to the 'entire' package in the
following form:

<name>pkg:/entire@0.5.11-0.build#</name>
-->
<software_data action="install">
<name>pkg:/entire@latest</name>
<name>pkg:/group/system/solaris-large-server</name>
</software_data>
</software>
</ai_instance>
</auto_install>
HERE

SCRIPT_SUCCESS=0
SCRIPT_FAILURE=1

function handler
{
exit $SCRIPT_FAILURE
}

trap handler ERR

/usr/bin/aimanifest load ${MFST}

donotuse=1 # don't want to pick up built in usb disk
set -A filesystem_name_arr export export/home zones
no_filesystems=2
set -A mountpoint_arr \/export \/export\/home \/zones
K=1024
let G=${K}*${K}*${K}
let mem_size=${SI_MEMSIZE}/${G}

/usr/bin/aimanifest add -r target/logical@nodump false
/usr/bin/aimanifest set target/logical@noswap false

/usr/bin/aimanifest add -r target/logical/zpool@name rpool
/usr/bin/aimanifest set target/logical/zpool[@name=rpool]@is_root true

vdev=$(/usr/bin/aimanifest add -r target/logical/zpool[@name=rpool]/vdev@name rpool_vdev)
/usr/bin/aimanifest set ${vdev}@redundancy mirror

zvol=$(/usr/bin/aimanifest add -r target/logical/zpool[@name=rpool]/zvol@name swap)
/usr/bin/aimanifest set ${zvol}@action create
/usr/bin/aimanifest set ${zvol}@use swap
/usr/bin/aimanifest add ${zvol}/size@val ${mem_size}gb

vdev=$(/usr/bin/aimanifest add -r target/logical/zpool[@name=rpool]/vdev@name rpool_vdev_spare)
/usr/bin/aimanifest set ${vdev}@redundancy spare

for ((j=0;j<=$no_filesystems;j++)) ; do
filesys=$(/usr/bin/aimanifest add -r target/logical/zpool[@name=rpool]/filesystem@name ${filesystem_name_arr[$j]})
/usr/bin/aimanifest set ${filesys}@mountpoint ${mountpoint_arr[$j]}
done

/usr/bin/aimanifest add -r target/logical/zpool[@name=rpool]/be@name solaris

vdev_name=rpool_vdev

for ((i=1;i<=$SI_NUMDISKS-$donotuse;i++)) ; do

# doesn't work as described in the oracle notes, but this does
eval temp_disk="$"SI_DISKNAME_${i}
eval curr_disk=$temp_disk

if [[ $i -eq $SI_NUMDISKS-$donotuse ]]; then
vdev_name=rpool_vdev_spare
fi

disk=$(/usr/bin/aimanifest add -r target/disk@in_vdev ${vdev_name})
/usr/bin/aimanifest set ${disk}@whole_disk true
/usr/bin/aimanifest set ${disk}@in_zpool rpool

disk_name=$(/usr/bin/aimanifest add -r ${disk}/disk_name@name ${curr_disk})
/usr/bin/aimanifest set ${disk_name}@name_type ctd

done

exit $SCRIPT_SUCCESS

September 2013

Mo Tu We Th Fr Sa Su
|  Today  | Oct
                  1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30                  

Search this blog

Tags

Galleries

Most recent comments

  • hello. i am from poland. i uwielbiam was! by on this entry
  • Hello, It was more for internal consumption, I will check it over and send you a version, can you em… by Maria MacCallum on this entry
  • Hello Maria, i don't see the script setup–zone.sh, can you post it ? I'am looking too for an example… by FRANCISCO on this entry
  • Solaris 11.2 returns the value of SI_MEMSIZE in Mb's now by Maria MacCallum on this entry

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXIX