Thursday, 8 January 2009

OpenSolaris - ZFS and Zones

Today, just a quick note on setting up an OpenSolaris 10 system local zone.

Firstly, you need to ensure there's a suitable ZFS file system created for the zone, then you define and install the zone itself. The basic steps are quite simple, here's a basic example as a starter:

Note: Global zone means the default zone, the basic machine assuming no zones have been created yet. Local zone is a created zone within the global zone, as described here.


As root on the global zone:

Take a look at available pools:

global# rpool list

On my system, with one disk fully used, I have rpool already, but no other pools.

Creating a new ZFS filesystem under rpool as follows:

global# zfs create /rpool/zones

Now create a new zone configuration, here is a really basic minimal zone config with networking, taken from the zone FAQ.

global# zonecfg -z my-zone
global# zonecfg:my-zone> create
global# zonecfg:my-zone> set zonepath=/zones/zone_roots/my-zone
global# zonecfg:my-zone> add net
global# zonecfg:my-zone:net> set address=10.1.1.1
global# zonecfg:my-zone:net> set physical=hm0
global# zonecfg:my-zone:net> end
global# zonecfg:my-zone> commit
global# zonecfg:my-zone> exit

Install the zone (if this fails, check permissions, shown as *1 below)

global# zoneadm -z my-zone install

Boot the installation!

global# zoneadm -z my-zone boot


Login to the new zone:

global# zlogin -C my-zone

*1 change permissions on the dataset if necessary

global# chown root /rpool/zones/my-zone
global# chmod 700 /rpool/zones/my-zone


A more complete zone configuration, for reference:

create -b
set zonepath=/zones/dev1
set autoboot=true
add inherit-pkg-dir
set dir=/lib
end
add inherit-pkg-dir
set dir=/platform
end
add inherit-pkg-dir
set dir=/sbin
end
add inherit-pkg-dir
set dir=/usr
end
add inherit-pkg-dir
set dir=/opt/apache22
end
add inherit-pkg-dir
set dir=/opt/csw
end
add inherit-pkg-dir
set dir=/opt/mysql5
end
add inherit-pkg-dir
set dir=/opt/pgsql829
end
add inherit-pkg-dir
set dir=/opt/php5
end
add fs
set dir=/opt/SUNWspro
set special=/opt/SUNWspro
set type=lofs
add options ro
end
add net
set address=10.80.117.152
set physical=bge0
end


Resources:

ZFS: http://www.linuxdynasty.org/zfs-howto-howto-create-a-zfs-file-system.html

Zones: http://opensolaris.org/os/community/zones/faq/#sa_create


.

No comments: