JET handoff to N1SPS / N1SM / DI...

The system side of things looks fairly good at this point. We have created our pile of packages to install, patched everything, decided on a disk configuration, tested it, and bundled the installation scripts into the system image "flar" that the N1SPS/N1SM folks are going to use in provisioning our target servers. Not bad.

Now is the time that we expect little problems and conflicts to creep in. The first one is expected, and (fortunately) we had a little time to play around to find out what would and wouldn't work. Simple problem, we needed to create and mount all of those filesystems as part of the installation of the global zone, but didn't know what the zone names would be. Since tradition puts the "zonepath" at /zones/[zonename], we will need to do some juggling. It turns out that N1SPS and N1SM think that, by default, zones will have a zonepath that is /zones/[zonename], our choices are to either re-write a bunch of tested local, supported, and standard SPS/SM goodies to deal with this dilemma, or fix it on the system side before SPS/SM come into play.

We first tried using "ln" and "ln -s" style links. These broke things in very interesting ways (as suspected, but it was worth a try). The zonecfg/zoneadm utilities were unable to figure out where the disk space was coming from, and how much of it there was to use. Oops. My next brainstorm was to use "lofs". The lofs "loopback filesystem" allows you to do lots of tricky things like mount ISO images of CDs and DVDs. It also allows you to "mount" directory trees of stuff from one place onto another "mount point". This functionality is leveraged by zones themselves to create the filesystems in your zone config (especially noticeable with full root and multi-filesystem zones).

Pretty simple solution, and rather elegant. As a pre-install task for any zone (let's call ours "myzone"), we mount the zone disk space that we created earlier (let's use ZONE123 for this example):

myhost#  ./zonelink myzone ZONE123
Mounting /zones/ZONE123/ROOT  on /zones/myzone
myhost#  

And here is the quick and dirty zonelink script. In retrospect, I would have mounted the soft partitions someplace other than /zones. This would have made good separation of "mountpoints" from a global zone perspective and "zonepaths" and zone filesystems. Something like /zonespace would have made life neater and cleaner in the long run. Live and learn.

#!/bin/sh
#
#  zonelink 
#  1.0 - Bill Walker < bill.walker@sun.com>
#
#  Use lofs (7fs) to mount the zone space on the zonepath
#
###########################################################
#
BN=`/usr/bin/basename ${0}`
#
#  Check Args, do Usage...
#
if [ $# -ne 2 ]
then
    echo "${BN} : Usage : "
    echo "     ${BN} [ZONENAME] [ZONENUMBER]"
    exit 111
else
    #  Collect args into vars
    #
    ZONENAME=${1}
    ZONENUMBER=${2}
    #
    #  Make sure that the mountpoint exists...
    #
    if [ ! -d /zones/${ZONENAME} ]
    then
        echo "Making mountpoint /zones/${ZONENAME}"
        mkdir /zones/${ZONENAME}
    fi
    #
    #  Make sure the source dir exists...
    #
    if [ -d /zones/${ZONENUMBER}/ROOT ]
    then
        #
        #  Use lofs to mount zone space on /zones/[zonename]
        #
        echo "Mounting /zones/${ZONENUMBER}/ROOT  on /zones/${ZONENAME}"
        /usr/sbin/mount -F lofs /zones/${ZONENUMBER}/ROOT /zones/${ZONENAME}
    else
        echo "No such source ROOT /zones/${ZONENUMBER}/ROOT ..."
        exit 112
    fi
fi

I could get alot fancier with this and add a bunch more error checking. I really should check to see if the zone space is already being used before I try to lofs it to the zonepath. Something like:

#
#  Count the number of times that the ZONENUMBER/ROOT is in 
#    the output of /usr/sbin/mount
#
MNTLINES=`/usr/sbin/mount | grep "/zones/${ZONENUMBER}/ROOT" | wc -l`
#
#  Make sure that there is only one entry for ZONENUMBER/ROOT
#    in the output of /usr/bin/mount, or error and exit
#
if [ ${MNTLINES} -gt 1 ]
then
    echo "${BN} : /zones/${ZONENUMBER}/ROOT already mounted somewhere?"
    exit 113
fi
if [ ${MNTLINES} -lt 1 ]
then
    echo "${BN} : /zones/${ZONENUMBER}/ROOT not a mounted FS?"
    exit 114
fi

OK, that snippet is off the top of my head and totally untested, but I am using it as an example of the myriad of things that could go awry in this part of the process. There are a ton of dependencies, but since we own the platform, and we presume that it is under our control (no one has been mucking with it), and it is more than likely only a few minutes or hours since a fresh installation... We can probably take a few relatively safe shortcuts at this point.

The rest of the filesystems in our zones will be configured using zonecfg, and just work. The root filesystem was the only one that caused weirdness. Once the root filesystem is mounted in the right place, zonecfg takes care of all of the rest of the lofs filesystem mounts for us and "just works".


bill.


Comments:

Post a Comment:
Comments are closed for this entry.
About

mrbill

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
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
   
       
Today