Build smartos lx images from userland tar files.
smartos-lx-img-builder
will take a tar of a Linux root filesystem and convert
it into a SmartOS image. The tar files typically are generated by
lx-images, but in theory could be any tar image (e.g., images provided by
LXC should work, but this has not yet been tested). The lx-images repo
generates images automatically via the github workflow, which will automatically
create a release tag and publish the images to github.
This is experimental and a work in progress. The goal is to take generic Linux userland tarballs and kick out a zfs dataset and manifest that can be used on a SmartOS host.
This is intended to run on SmartOS, but any OS that has ZFS will probably work.
On SmartOS, this is typically run in a zone. Using this in a zone requires a delegated dataset.
The files in ./guest will be copied into into the image root.
Note: /native
is not part of the image, it comes from the running SmartOS
system and is always present in running zones.
- First obtain one or more images. Typically use an image from https://github.com/TritonDataCenter/lx-images/releases.
- Clone this repo and
cargo build
. - Create your image(s).
- Upload your image to an image server, or see
imgadm(8)
for installing local images to SmartOS.
The following command line options are available.
smartos-lx-img-builder 0.1.0
USAGE:
smartos-lx-img-builder [OPTIONS] --tar <tar>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-d, --description <description> text to append to the description of the image as it would appear in the manifest
[default: ]
-k, --kernel <kernel> the kernel version [default: 5.10.0]
-m, --min <min_platform> the minimum platform required for the image [default: 20210826T002459Z]
-t, --tar <tar> lx userland tar file
-u, --url <url> the url to information about the image as it would appear in the manifest
[default: https://docs.tritondatacenter.com/public-cloud/instances/infrastructure/images]
-z, --zfs-parent <zfs_parent> the parent zfs dataset to use when creating our temporary image [default: ]
$ pfexec target/debug/smartos-lx-img-builder \
--description "testing image creation"
--kernel 4.3 \
--min 20210106T005452Z \
--tar /var/tmp/lx-ubuntu-20.04-2020-11-27_15-44-08.tar.xz
--url "https://images.smartos.org" \
--zfs-parent zones/$(zonename)/data/build
created dataset build/lx-ubuntu-20.04-20210305
creating dir /build/lx-ubuntu-20.04-20210305/root
set permissions for /build/lx-ubuntu-20.04-20210305/root to owner: 0 group: 0 mode: 755
created zroot /build/lx-ubuntu-20.04-20210305/root
extracted /var/tmp/lx-ubuntu-20.04-2020-11-27_15-44-08.tar.xz into /build/lx-ubuntu-20.04-20210305/root
creating dir /build/lx-ubuntu-20.04-20210305/root/native/dev
set permissions for /build/lx-ubuntu-20.04-20210305/root/native/dev to owner: 0 group: 0 mode: 755
creating dir /build/lx-ubuntu-20.04-20210305/root/native/etc/default
set permissions for /build/lx-ubuntu-20.04-20210305/root/native/etc/default to owner: 0 group: 0 mode: 755
creating dir /build/lx-ubuntu-20.04-20210305/root/native/etc/svc/volatile
set permissions for /build/lx-ubuntu-20.04-20210305/root/native/etc/svc/volatile to owner: 0 group: 0 mode: 755
creating dir /build/lx-ubuntu-20.04-20210305/root/native/lib
set permissions for /build/lx-ubuntu-20.04-20210305/root/native/lib to owner: 0 group: 0 mode: 755
creating dir /build/lx-ubuntu-20.04-20210305/root/native/proc
set permissions for /build/lx-ubuntu-20.04-20210305/root/native/proc to owner: 0 group: 0 mode: 755
creating dir /build/lx-ubuntu-20.04-20210305/root/native/tmp
set permissions for /build/lx-ubuntu-20.04-20210305/root/native/tmp to owner: 0 group: 0 mode: 755
creating dir /build/lx-ubuntu-20.04-20210305/root/native/usr
set permissions for /build/lx-ubuntu-20.04-20210305/root/native/usr to owner: 0 group: 0 mode: 755
creating dir /build/lx-ubuntu-20.04-20210305/root/native/var
set permissions for /build/lx-ubuntu-20.04-20210305/root/native/var to owner: 0 group: 0 mode: 755
set permissions for /build/lx-ubuntu-20.04-20210305/root/native/tmp to owner: 0 group: 0 mode: 1777
creating file /build/lx-ubuntu-20.04-20210305/root/etc/fstab
creating symlink from /native/usr/sbin/mdata-get to /build/lx-ubuntu-20.04-20210305/root/usr/sbin/mdata-get
/build/lx-ubuntu-20.04-20210305/root/usr/sbin/mdata-get changed ownership to owner: 0 group: 0
creating symlink from /native/usr/sbin/mdata-put to /build/lx-ubuntu-20.04-20210305/root/usr/sbin/mdata-put
/build/lx-ubuntu-20.04-20210305/root/usr/sbin/mdata-put changed ownership to owner: 0 group: 0
creating symlink from /native/usr/sbin/mdata-delete to /build/lx-ubuntu-20.04-20210305/root/usr/sbin/mdata-delete
/build/lx-ubuntu-20.04-20210305/root/usr/sbin/mdata-delete changed ownership to owner: 0 group: 0
creating symlink from /native/usr/sbin/mdata-list to /build/lx-ubuntu-20.04-20210305/root/usr/sbin/mdata-list
/build/lx-ubuntu-20.04-20210305/root/usr/sbin/mdata-list changed ownership to owner: 0 group: 0
copying guest/etc/profile.d/native_manpath.sh to /build/lx-ubuntu-20.04-20210305/root/etc/profile.d/native_manpath.sh
set permissions for /build/lx-ubuntu-20.04-20210305/root/etc/profile.d/native_manpath.sh to owner: 0 group: 0 mode: 744
creating dir /build/lx-ubuntu-20.04-20210305/root/lib/smartdc
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/common.lib to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/common.lib
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/common.lib to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/debian to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/debian
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/debian to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/mdata-execute to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/mdata-execute
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/mdata-execute to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/void to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/void
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/void to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/set-provision-state to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/set-provision-state
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/set-provision-state to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/joyent_rc.local to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/joyent_rc.local
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/joyent_rc.local to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/mount-zfs to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/mount-zfs
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/mount-zfs to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/redhat to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/redhat
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/redhat to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/mdata-fetch to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/mdata-fetch
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/mdata-fetch to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/alpine to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/alpine
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/alpine to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/mdata-image to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/mdata-image
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/mdata-image to owner: 0 group: 0 mode: 755
copying guest/lib/smartdc/archlinux to /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/archlinux
set permissions for /build/lx-ubuntu-20.04-20210305/root/lib/smartdc/archlinux to owner: 0 group: 0 mode: 755
detected distro as Debian
copying guest/lib/smartdc/joyent_rc.local to /build/lx-ubuntu-20.04-20210305/root/etc/rc.local
set permissions for /build/lx-ubuntu-20.04-20210305/root/etc/rc.local to owner: 0 group: 0 mode: 755
snapshot created: build/lx-ubuntu-20.04-20210305@final
created zfs gzip at lx-ubuntu-20.04-20210305.zfs.gz
created manifest at lx-ubuntu-20.04-20210305.json
destroyed dataset build/lx-ubuntu-20.04-20210305
========== Output ==========
filesystem: /home/mike/src/img-builder/lx-ubuntu-20.04-20210305.zfs.gz
manifest: /home/mike/src/img-builder/lx-ubuntu-20.04-20210305.json