dermotbradley / create-alpine-disk-image

Create cloud-init enabled Alpine disk images for physical machines (PCs & RPIs), VMs, and Cloud servers
GNU General Public License v2.0
93 stars 11 forks source link
alpine alpine-linux cloud-init qemu raspberry-pi virtualbox

create-alpine-disk-image

A Shell script designed for easily creating cloud-init enabled, server oriented, disk images of Alpine Linux. The script, and the secondary script it creates, can be run on Alpine, Debian, or Ubuntu host machines - you do not need a machine running Alpine to create a disk image.

The script itself, create-alpine-disk-image, is designed to be run as any user - it does not need root privileges - as all that it actually does is to create another, secondary, script which is tailored to produce the required disk image when run.

The (created) secondary script must be run with 'root' privileges (whether via doas/su/sudo or directly as 'root' user) as it requires privileges in order to create loopback devices, partitions disk images, etc.


NOTE: This script is a work-in-progress and not yet stable. The initial aim is to fully test QEMU VM and Raspberry Pi disk images and then a few Cloud provider images.


The script is based on an Ansible playbook which I've developed over the past 12+ months for creating tailored Alpine disk images for use with QEMU VMs, physical PCs, and Raspberry Pis.

Features:

More information regarding specific features can be found here: Features

Host packages required

Alpine:

Debian / Ubuntu:

Cloud images

The generic cloud disk image works with multiple cloud providers.

Individual cloud provider specific images (with provider-specific tools built-in) can also be built for:

Resultant disk images then need to be imported into whichever Clouds using cloud-specific method(s). More information on this is detailed in individual READMEs in the Cloud directory.

Physical machine images

Can create disk images for the follow machines:

VM images

Can create disk images for the following hypervisors:

Resultant disk images can then be converted using qemu-img convert to the required format for the hypervisor, i.e. OVA, QCOW2.

Examples

The only mandatory option to specify is --script-filename to indicate the name of the secondary script to be created. With no other options specified the default is to build a x86_64 image running Alpine Edge for use with the QEMU hypervisor:

create-alpine-disk-image --script-filename create.sh
su -c ./create.sh

Build a generic x86_64 Cloud image running Alpine 3.13 that can be used with multiple Cloud Providers:

create-alpine-disk-image --cloud generic --release 3.13 --script-filename create.sh
sudo ./create.sh

Build a AWS x86_64 image running Alpine 3.13:

create-alpine-disk-image --cloud aws --release 3.13 --script-filename create.sh
sudo ./create.sh

Build a AWS aarch64 image running Alpine Edge:

create-alpine-disk-image --cloud aws --aarch aarch64 --script-filename create.sh
su -c create.sh

Build a Raspberry Pi 4 aarch64 image running Alpine 3.13:

create-alpine-disk-image --physical rpi4 --release 3.13 --script-filename create.sh
sudo ./create.sh

Build a Raspberry Pi 3 armv7 image running Alpine Edge:

create-alpine-disk-image --physical rpi3 --arch armv7 --script-filename create.sh
sudo ./create.sh