Preconfiguring Zones
In the Zones blog I posted a few weeks back, a couple of the steps required interactive configuration. In this entry I'm going to create the same zone, however in a much streamlined manner.
Step 1: Create the Zone
In this step we can pass a series of settings to the zonecfg command, bypassing the interactive prompts. I've created a file called myzone.config that contains the following:
bleonard@opensolaris:~$ cat myzone.config create set zonepath=/zones/myzone set ip-type=shared add net set address=10.0.1.25/24 set physical=e1000g0 end
Using that file I can quickly create the zone as follows:
pfexec zonecfg -z myzone -f myzone.config
Confirm its configuration:
bleonard@opensolaris:~$ zonecfg -z myzone info zonename: myzone zonepath: /zones/myzone brand: ipkg autoboot: false bootargs: pool: limitpriv: scheduling-class: ip-type: shared hostid: net: address: 10.0.1.25/24 physical: e1000g0 defrouter not specified bleonard@opensolaris:/zones$ zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared - myzone configured /zones/myzone ipkg shared
Step 2: Install the Zone
bleonard@opensolaris:/zones$ pfexec zoneadm -z myzone install
Publisher: Using opensolaris.org (http://pkg.opensolaris.org/release/).
Image: Preparing at /zones/myzone/root.
Cache: Using /var/pkg/download.
Sanity Check: Looking for 'entire' incorporation.
Installing: Core System (output follows)
DOWNLOAD PKGS FILES XFER (MB)
Completed 20/20 3021/3021 42.55/42.55
PHASE ACTIONS
Install Phase 5747/5747
Installing: Additional Packages (output follows)
DOWNLOAD PKGS FILES XFER (MB)
Completed 37/37 5598/5598 32.52/32.52
PHASE ACTIONS
Install Phase 7332/7332
Note: Man pages can be obtained by installing SUNWman
Postinstall: Copying SMF seed repository ... done.
Postinstall: Applying workarounds.
Done: Installation completed in 171.102 seconds.
Next Steps: Boot the zone, then log into the zone console
(zlogin -C) to complete the configuration process
bleonard@opensolaris:/zones$ zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- myzone installed /zones/myzone ipkg shared
Steps 3 & 4: Boot and Configure
This is where things really improve for the better. If you look at the original Zones blog, there were a fair amount of steps involved in configuring the system. Like with creating the zone itself, the settings for these configuration steps can be placed in a file that the zone will read on first boot. The file must be named sysidcfg. Here's a version that matches the configuration settings from the original Zones blog:
bleonard@opensolaris:~$ cat sysidcfg
system_locale=C
terminal=xterms
network_interface=PRIMARY {hostname=myzone}
security_policy=none
name_service=NONE
nfs4_domain=dynamic
timezone=US/Eastern
root_password=fto/dU8MKwQRI
Note, the root_password is supposed to be set to a value from your /etc/shadow file. However, beware of the following issue: Zone Preconfiguration Fails with root_password keyword set. The workaround is to use a value from either Solaris 10 or SXCE. The root password used above is 'abc123', so you can just use that and then change it to whatever you like. Or you can just leave out the root_password keyword and you will be prompted to set one.
To further customize the sysidcfg file, see the sysidcfg man page.
The sysidcfg file must be placed in the zone's /etc directory. The zone must first be readied before its file system can be accessed:
pfexec zoneadm -z myzone ready
Now copy the sysidcfg file:
pfexec cp sysidcfg /zones/myzone/root/etc/.
Now, log into the zone and wait for it to boot:
bleonard@opensolaris:~$ pfexec zlogin -C myzone [Connected to zone 'myzone' console]
Open a 2nd terminal window and boot the zone:
pfexec zoneadm -z myzone boot
Then back in the 1st terminal window you'll see the following:
[NOTICE: Zone booting up] SunOS Release 5.11 Version snv_111b 64-bit Copyright 1983-2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Hostname: myzone Loading smf(5) service descriptions: 69/69 Reading ZFS config: done. Mounting ZFS filesystems: (5/5) Creating new rsa public/private host key pair Creating new dsa public/private host key pair Configuring network interface addresses: e1000g0. myzone console login:
You can log in as root. If you used the the root_password setting above, the password is abc123.
myzone console login: root Password: Jul 8 11:09:38 myzone login: ROOT LOGIN /dev/console Sun Microsystems Inc. SunOS 5.11 snv_111b November 2008 root@myzone:~#
Thanks! Very nice info!
Posted by .coder on July 14, 2009 at 05:28 AM GMT #