Friday, June 01, 2018

Tribblix - creating zones from images

One of the things I've done with Tribblix is try and hide some of the complexity around managing zones - rather than having to mess around with zonecfg and zoneadm and all that, just have one simple command that creates a zone correctly.

Tribblix also has the capability to drop an alternative illumos distribution into a zone - so called alien zones.

The OmniTribblix variant has LX zones, so you can run Linux in a zone.

Up to now, you've had to manually download the appropriate image, save it somewhere, and then install the zone from that image.

Wouldn't it be much easier to have Tribblix do that for you? Well, as of the m20.4 release, it can!

So, for example, OmniOS have images as zfs send streams available for download - the .zfs.bz2 files. So you can now build an OmniOS zone on Tribblix like so:

zap create-zone -z omnios -t alien -i -I omnios:r151026

That's it.

And, if you're running OmniTribblix you could create an Ubuntu zone like so:

zap create-zone -z ubuntu -t lx -x -I ubuntu

or, if you want Alpine (and this is really quick)

zap create-zone -z alpine -t lx -x -I proxmox:alpine

The images are downloaded and cached, so creating subsequent zones will be much quicker.

It's a proof of concept at this point, and needs fleshing out a bit more to make it even more friendly, but it shows that it's possible and useful.


casaubon said...

where can one check the available images for this?

Peter Tribble said...

On the system, you can look at the file


which is the script that runs behind the scenes when you request an image.

But basically, it knows about ubuntu cloud images and proxmox.

casaubon said...

thanks man. however, it fails..

# zap create-zone -z BAALZLX01 -t lx -x -I ubuntu:18.04
Downloading ubuntu:18.04
Using downloaded image /var/zap/images/ubuntu-18.04-server-cloudimg-amd64.tar.gz for ubuntu:18.04
A ZFS file system has been created for this zone.
zone 'BAALZLX01': /export/zones/BAALZLX01/root/etc is not a directory
zone 'BAALZLX01': /export/zones/BAALZLX01/root/etc/mnttab is not a valid mount point
zone 'BAALZLX01': unable to mount filesystems
zoneadm: zone 'BAALZLX01': call to zoneadmd failed

should i open a github issue about this?

casaubon said...

when i try to do it manually (zonecfg and zoneadm instead if zap) it fails on boot like this:

# zoneadm -z BAALZLX01 boot
zone 'BAALZLX01': mount of /proc failed: Invalid argument
zone 'BAALZLX01': unable to mount filesystems
zoneadm: zone 'BAALZLX01': call to zoneadmd failed

i checked /usr/lib/brand/lx/platform.xml but everything seems to be fine, even diff'd it with the one on omnios's github source repo.. it's the same.

what should i try next?

Peter Tribble said...

It doesn't seem happy. Let me have a chance to try this, it was working last time I tried it (although that was probably m20.5).

Peter Tribble said...

The unable to mount /proc error is due to a missing dependency:

zap install TRIBdrv-inotify

ought to fix that.

You can fix the Ubuntu image problem with:

sed -i s:server-cloudimg-amd64:server-cloudimg-amd64-root: /usr/lib/zap/retrieve

Thanks for the feedback, these fixes are all checked in for the next release.

casaubon said...

thanks again :)

actually the file is /usr/lib/zap/retrieve-image (probably just a typo) and root images are .tar.xz not gz, so i changed the $DLSUFFIX to ".tar.xz".

however, there is still an error about resolv.conf somewhere:

# zap create-zone -z BAALZLX02 -t lx -x -I ubuntu:18.04
Using cached image /var/zap/images/ubuntu-18.04-server-cloudimg-amd64-root.tar.xz for ubuntu:18.04
A ZFS file system has been created for this zone.
cp: cannot create /export/zones/BAALZLX02/root/etc/resolv.conf: No such file or directory

tried with 16.04 to see if this is only a problem with the image, but got the same error, so i tried to find the offending command but with no luck:
find /usr/lib/brand/lx -type f -name \* -exec grep "resolv" {} /dev/null \; | grep cp
find /usr/lib/zap -type f -name \* -exec grep "resolv" {} /dev/null \; | grep cp

what should i check?

Peter Tribble said...

Yes, I've changed the DLSUFFIX at source too - 18.04 is only available as xz, earlier ones had both xz and gz archives.

The resolv.conf thing is unavoidable - I might just hide the error from the user. The thing is that many modern Linux distros have resolv.conf dynamically managed by systemd, so it's a symbolic link pointing to somewhere that doesn't exist at the point I'm poulating the image.

casaubon said...

yay for systemd.. not. thanks a lot for your help. looking forward to the next release.