Monday, May 20, 2013

Creating a sparse-root zone

As of the 0m6 prerelease, Tribblix supports sparse-root zones. In these, the bulk of the OS is loopback mounted read-only from the global zone, so the zone has exactly the same software as the global zone but its own copy of /etc and /var.

To create a sparse-root zone, use the zonecfg command to create the configuration.

# zonecfg -z z1
z1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:z1> create -t TRIBsparse
zonecfg:z1> set zonepath=/export/z1
zonecfg:z1> verify
zonecfg:z1> commit
^D


All you're doing here is defining it as a sparse-root zone (the -t flag to create tells it which template to use) and where the zone should live on the filesystem. Note that you need to create the parent of the zonepath, as a zfs dataset, before you can install the zone.

(For whole-root zones,  simply create -t TRIBwhole.)

In a real configuration, you would add a network interface - that works the same way as other zones, so I'm not going to cover it here.

Then you can install the zone.

# zoneadm -z z1 install
A ZFS file system has been created for this zone.
       Image: Preparing at /export/z1/root.
5408 blocks
592 blocks
59568 blocks
 Postinstall: Copying SMF seed repository ... done.
 Postinstall: Applying workarounds.
/usr/lib/brand/sparse-root/pkgcreatezone[272]: /usr/sbin/sysidconfig: not found [No such file or directory]
        Done: Installation completed in 2.184 seconds.

  Next Steps: Boot the zone, then log into the zone console (zlogin -C)
              to complete the configuration process.


Note how quick the install is. The first sparse-root zone you create will take a little longer, as there is some initial configuration. Yes, there are some errors, the present implementation concentrates on working rather than being pretty.

And all that remains is to boot the zone.

# zoneadm -z z1 boot

After several seconds (it seems to take about 30s for SMF to initialize itself) the zone will be up and running.

No comments:

Post a Comment

Post a Comment