OpenSolaris

Discussions Communities Projects Download Source Browser

Home » OpenSolaris Forums » zones » discuss

Thread: question about zones

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Last Post: Feb 5, 2007 10:37 AM by: jeffv
Krzys
krzys@perfekt.net
question about zones
Posted: Feb 5, 2007 9:39 AM

  Click to reply to this thread Reply

hello, I just got into zones and I have few questions:

is there any way to create zone with some additional customizations?

here is what I did:
# zonecfg -z titan1
titan1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:titan1> create
zonecfg:titan1> set zonepath=/zones/titan1
zonecfg:titan1> set autoboot=true
zonecfg:titan1> add net
zonecfg:titan1:net> set address=192.168.1.82
zonecfg:titan1:net> set physical=bge0
zonecfg:titan1:net> end
zonecfg:titan1> info
zonecfg:titan1> verify
zonecfg:titan1> commit
zonecfg:titan1> exit


Ok, so that created my zone. Now I have to login and changethe following:
passwd file to point to new root home directory: /root/
add users.
change syslog.conf settings
make appriopriate changes in /etc/hosts file.
make changes to /etc/mail/sendmail.cf

is there any way to automate it? I did create only 10 zones and its not to crazy
to login to each of them and do all those different config changes etc, but I
was wondering if there was any easier way of doing all of them at the creation
time by scripts. I did setup scripts to do most of the stuff with zone creation,
to allocate resources per zones, and to zreate zfs for each zone with all the
settings that I needed but I was wondering if I can automate it even more.

Thanks for any help or pointers that you could give to me...

Chris

_______________________________________________
zones-discuss mailing list
zones-discuss at opensolaris dot org



stw

Posts: 441
From:

Registered: 9/21/05
Re: question about zones
Posted: Feb 5, 2007 9:57 AM   in response to: Krzys

  Click to reply to this thread Reply

Hi Krzys,

Krzys wrote On 02/05/07 12:39,:
> hello, I just got into zones and I have few questions:
>
> is there any way to create zone with some additional customizations?
>
> here is what I did:
> # zonecfg -z titan1
> titan1: No such zone configured
> Use 'create' to begin configuring a new zone.
> zonecfg:titan1> create
> zonecfg:titan1> set zonepath=/zones/titan1
> zonecfg:titan1> set autoboot=true
> zonecfg:titan1> add net
> zonecfg:titan1:net> set address=192.168.1.82
> zonecfg:titan1:net> set physical=bge0
> zonecfg:titan1:net> end
> zonecfg:titan1> info
> zonecfg:titan1> verify
> zonecfg:titan1> commit
> zonecfg:titan1> exit
>
>
> Ok, so that created my zone. Now I have to login and changethe following:
> passwd file to point to new root home directory: /root/
> add users.
> change syslog.conf settings
> make appriopriate changes in /etc/hosts file.
> make changes to /etc/mail/sendmail.cf
>
> is there any way to automate it? I did create only 10 zones and its not
> to crazy to login to each of them and do all those different config
> changes etc, but I was wondering if there was any easier way of doing
> all of them at the creation time by scripts. I did setup scripts to do
> most of the stuff with zone creation, to allocate resources per zones,
> and to zreate zfs for each zone with all the settings that I needed but
> I was wondering if I can automate it even more.

Cloning in 11/06 and NV copies over a lot of things, including SMF repository, from what I
experienced. Your /etc/inet/hosts file will probably still be unique and need to be customized after
install/clone, and possibly before first boot. I have a script that does a lot of the sysidcfg
stuff, in addition to the sysidcfg file.

# cat zoneXcreate.sh
#!/bin/sh

. ./zoneXlocal.include

while [ $I -le $M ]
do
echo "$I \c"

HOST=`expr ${HOSTBASE} + ${I}`

# Configure the zone
sed -e "s%X%${HOST}%g" zoneX${ZONETYPE}.cfg | \
sed -e "s%ZONEPATH%${ZONEROOT}%g" > /tmp/zone${HOST}
zonecfg -z zone${HOST} -f /tmp/zone${HOST}
rm /tmp/zone${HOST}

# Install the zone from a master, if it exists
S=`zoneadm -z ${ZONEMASTER} list > /dev/null 2>&1`
if [ $? -eq 0 ]
then
zoneadm -z zone${HOST} clone ${ZONEMASTER}
else
zoneadm -z zone${HOST} install
fi

# Set configuration information prior to initial boot
sed -e "s/X/${HOST}/g" zoneX.sysidcfg > $ZONEROOT/zone${HOST}/root/etc/sysidcfg
echo "${NETBASE}.${HOST}/${NETMASKSIZE}" > \
${ZONEROOT}/zone${HOST}/root/etc/hostname.vnic${HOST}
echo "\n${NETBASE}.${HOST} zone${HOST}" >> ${ZONEROOT}/zone${HOST}/root/etc/hosts
echo "\n${NETBASE}.0 ${NETMASK}" >> ${ZONEROOT}/zone${HOST}/root/etc/netmasks
echo "$DEFROUTER" >> ${ZONEROOT}/zone${HOST}/root/etc/defaultrouter
echo "zone${HOST}" >> ${ZONEROOT}/zone${HOST}/root/etc/nodename

zoneadm -z zone${HOST} boot

I=`expr $I + 1`

done
echo

# cat zoneXlocal.include
### To be customized per host

M=4 ; I=1

NETBASE="10.1.14"
NETMASK="255.255.255.192"
NETMASKSIZE=26
HOSTBASE=150
INTERFACE=e1000g2
MAC="0:3:ba:d8:50"
DEFROUTER="10.1.14.129"

ZONEROOT=/export/zones
ZONEMASTER=zoneX
ZONETYPE=exclusive
#ZONETYPE=shared


Steffen

reply-to set to: zones-discuss at opensolaris dot org

>
> Thanks for any help or pointers that you could give to me...
>
> Chris
>
> _______________________________________________
> zones-discuss mailing list
> zones-discuss at opensolaris dot org
_______________________________________________
zones-discuss mailing list
zones-discuss at opensolaris dot org



jeffv

Posts: 409
From:

Registered: 6/16/05
Re: question about zones
Posted: Feb 5, 2007 10:37 AM   in response to: Krzys

  Click to reply to this thread Reply

Krzys wrote:
> hello, I just got into zones and I have few questions:
>
> is there any way to create zone with some additional customizations?
>
> here is what I did:
> # zonecfg -z titan1
> titan1: No such zone configured
> Use 'create' to begin configuring a new zone.
> zonecfg:titan1> create
> zonecfg:titan1> set zonepath=/zones/titan1
> zonecfg:titan1> set autoboot=true
> zonecfg:titan1> add net
> zonecfg:titan1:net> set address=192.168.1.82
> zonecfg:titan1:net> set physical=bge0
> zonecfg:titan1:net> end
> zonecfg:titan1> info
> zonecfg:titan1> verify
> zonecfg:titan1> commit
> zonecfg:titan1> exit
>
>
> Ok, so that created my zone. Now I have to login and changethe following:
> passwd file to point to new root home directory: /root/
> add users.
> change syslog.conf settings
> make appriopriate changes in /etc/hosts file.
> make changes to /etc/mail/sendmail.cf

Because the global zone has access to the files under <zonepath>, a script can
be run in the global zone which manipulates files "in" the non-global zone.

For example, titan1 has a file called /etc/inet/hosts. The same file can be
accessed from the global zone with a different name:
/zones/titan1/root/etc/inet/hosts.

One precaution: after a zone has been booted for the first time, do not trust
the contents of its files. A sufficiently-privileged user of a non-global
zone may, accidentally or deceptively, modify a file in the non-global zone.


> is there any way to automate it? I did create only 10 zones and its not
> to crazy to login to each of them and do all those different config
> changes etc, but I was wondering if there was any easier way of doing
> all of them at the creation time by scripts. I did setup scripts to do
> most of the stuff with zone creation, to allocate resources per zones,
> and to zreate zfs for each zone with all the settings that I needed but
> I was wondering if I can automate it even more.
>
> Thanks for any help or pointers that you could give to me...
>
> Chris
>
> _______________________________________________
> zones-discuss mailing list
> zones-discuss at opensolaris dot org

--
--------------------------------------------------------------------------
Jeff VICTOR Sun Microsystems jeff.victor @ sun.com
OS Ambassador Sr. Technical Specialist
Solaris 10 Zones FAQ: http://www.opensolaris.org/os/community/zones/faq
--------------------------------------------------------------------------
_______________________________________________
zones-discuss mailing list
zones-discuss at opensolaris dot org






Terms of Use | Privacy | Trademarks | Copyright Policy | Site Guidelines
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.
Copyright © 1995-2005 Sun Microsystems, Inc.