solaris script to create and delete a zone

1. create a filesystem and install a zone
then snapshot the filesystem and use it
for cloning at zonecreation

zonecfg -z basezone
create
set zonepath=/zonepool/basezone
exit
zoneadm -z base install

zfs snapshot zonepool/basezone@base

script:
zcreate
==========================================
#!/usr/bin/bash

if test $# -lt 1
then
echo "usage : zcreate zonename "
exit
fi

#put config in place
zfs clone zonepool/basezone@base zonepool/$1
zonecfg -z $1 < /etc/zones/index.new
cat /etc/zones/index.orig /etc/zones/index.new > /etc/zones/index

zoneadm -z $1 boot
=============================================

script:
rzone
==============================================
cp /etc/zones/index.orig /etc/zones/index
rm /etc/zones/${1}.xml
zfs destroy zonepool/${1}

==============================================

This entry was posted in solaris. Bookmark the permalink.

Comments are closed.