Sunday, July 16, 2006

How small can you make Open Solaris - Part 3

In this post I have decided to focus on installing Solaris directly without using the normal Solaris installer. If you are like me and forever installing the latest Solaris Nevada version, and would like to do this without rebooting and running the Solaris installer then the script below might be for you. If you are playing around to see what packages you can remove to shrink a Solaris installation, then a modified version of this script might be what you are looking for.

Solaris already has an excellent tool for upgrading your current system called live upgrade. The script below is different, as it does a totally fresh install. Hopefully the next version will also install directly onto a ZFS filesystem rather than a UFS partition.

To start off you need a Solaris X86 system (one which uses grub) with a free Solaris partition that has enough diskspace to hold the installation. Note, this script does no checking! It assumes you have configured the settings correctly, and have allocated enough space. You also have to have a DVD (or image) of Solaris (or maybe a jumpstart type installation directory).

Going through the script, at the beginning you will find some variables to may need to change to refect your setup. Since it uses the Solaris Meta Clusters you will need to define which one you want. The functions (which is most of the code), rattle through the cluster table of contents file and produces an order list of packages for the meta cluster you selected. Once it has a list a pkgadd is executed for each package.

After the packages have been installed, there are a few system configurations and device links that are required to get the system booted correctly. You can have the system automatically configure itself on reboot if you have a valid sysidcfg file in your current directory. Otherwise, the system will ask you many questions on reboot to configure hostnames, networking etc. If you are familiar with building zones, this will not be new.

Before you start, you should read through the script so you know exactly what it does. The is very little error/sanity checks in the script, and incorrect settings could be devastating as you will need to be root (or have the correct privs) to use it. When you have finish the installation you will need to modify grub to boot off the correct partition. Below the relevent section of my /boot/grub/menu.lst file.

## This function builds a list of packages in a cluster# If there is a cluster within a cluster, it will call itself to# resolve all the packages.## Before calling make sure you initialize pkgcnt to 0# Arg: $1 contains the cluster name# Affected vars: pkgs, pkgcnt#function get_pkg_list() { local IFS="=" local print_on=0 local cluster=$1

## Build an ordered list of packages from the Solaris installation image#printf "Building a list of packages "pkgcnt=0get_pkg_list ${METACLUSTER}echoprintf "Sorting packages into the correct order for installation "reorder_pkgsecho

## Copy links for disk partitions in /dev/dsk and /dev/rdsk# This is needed so the system can find the root partion on boot#( cd /dev && find dsk rdsk -depth | cpio -pdm /mnt/dev 2>/dev/null )

## Configure system to initialize identity on first boot# If there is a sysidcfg file in the current directory. This will# be copied across.#PROFILEDIR=/mnt/var/svc/profile[ -f ${PROFILEDIR}/${SVCPROFILE} ] && { if [ -f ./sysidcfg ]; then cp ./sysidcfg /mnt/etc else touch /mnt/etc/.UNCONFIGURED fi cp -p ${PROFILEDIR}/${SVCPROFILE} ${PROFILEDIR}/generic.xml}