Initial Setup and Info
This guide uses Openstack's Diskimage-builder tool for generation of images, while you can use this for Openstack, you can also create generic images with it.
Setting up Diskimage-builder is fairly simple, when you use it, it does expect to be run as root.
All you need to do is follow this guide, at it's simplest it's just a couple of git clones and PATH
setup.
You will need app-emulation/qemu
for generation of qcow2 files.
The current setup utilizes the stage4 images being generated, see this link for more details.
There are currently only 4 profiles supported, however I hope to support musl and selinux profiles 'soon'.
default/linux/amd64/13.0
default/linux/amd64/13.0/no-multilib
hardened/linux/amd64
hardened/linux/amd64/no-multilib
Generating an Openstack image
To use a profile other than default/linux/amd64/13.0
set the GENTOO_PROFILE
environment variable to one of the other supported profiles.
disk-image-create -a amd64 -t qcow2 --image-size 2 gentoo simple-init growroot vm
is all you need to start. It will output a file named image.qcow2
.
For openstack there are two ways you could go for initial setup (post-vm start). The first and most common is cloud-init, but that includes a few python deps that I don't think are really needed. The other is simple-init (glean), which is more limited, but as it's name suggests, simple.
Here is a link to glean (simple-init) for those wanting more info glean
Generating a Generic Image You Can Log Into
Using the devuser
element you can set up custom users. You will need to set up some more environment variables though.
Docs can be found here
An example invocation follows, simple-init may be needed so that interfaces get dhcp addresses, though you may wat to set that up manually, your choice.
DIB_DEV_USER_PASSWORD=foobar DIB_DEV_USER_USERNAME=gentoo DIB_DEV_USER_PWDLESS_SUDO=yes DIB_DEV_USER_AUTHORIZED_KEYS=/dev/null disk-image-create -a amd64 -t qcow2 --image-size 2 gentoo simple-init growroot devuser vm