2017-08-29 18:01:51 +00:00
= Make Alpine Linux VM Image
2017-08-29 22:54:42 +00:00
:script-name: alpine-make-vm-image
2019-08-14 21:17:31 +00:00
:script-sha1: 979de8f0ae8646ae1b6738e039e9dd0555628d60
2017-10-22 14:59:00 +00:00
:gh-name: alpinelinux/{script-name}
2019-08-14 21:17:31 +00:00
:version: 0.5.0
2017-08-29 22:54:42 +00:00
ifdef::env-github[]
image:https://travis-ci.org/{gh-name}.svg?branch=master["Build Status", link="https://travis-ci.org/{gh-name}"]
endif::env-github[]
2019-12-22 14:36:06 +00:00
This project provides a script for making customized https://alpinelinux.org/[Alpine Linux] disk images for virtual machines.
2017-10-11 19:36:32 +00:00
It’ s quite simple (250 LoC of shell), fast (~40 seconds on Travis CI including Travis VM initialization) and requires minimum dependencies (QEMU and filesystem tools).
2017-08-29 22:54:42 +00:00
2017-10-13 17:10:23 +00:00
TIP: Don’ t need VM, just want to chroot into Alpine Linux (e.g. on CI)?
2017-10-11 19:56:03 +00:00
Try https://github.com/alpinelinux/alpine-chroot-install[alpine-chroot-install]!
2017-08-29 22:54:42 +00:00
== Requirements
2017-10-11 19:28:44 +00:00
* Linux system with common userland (Busybox or GNU coreutils)
2017-08-29 22:54:42 +00:00
* POSIX-sh compatible shell (e.g. Busybox ash, dash, Bash, ZSH)
2017-10-11 17:48:03 +00:00
* qemu-img and qemu-nbd (automatically installed by the script if running on Alpine)
* e2fsprogs (for ext4), btrfs-progs (for Btrfs), or xfsprogs (for XFS) (automatically installed by the script if running on Alpine)
2017-08-29 22:54:42 +00:00
== Usage
Read documentation in link:{script-name}[{script-name}].
See link:.travis.yml[.travis.yml] for Travis example.
You can copy link:{script-name}[{script-name}] into your repository or download it on demand, e.g.:
[source, sh, subs="+attributes"]
wget https://raw.githubusercontent.com/{gh-name}/v{version}/{script-name} \
&& echo '{script-sha1} {script-name}' | sha1sum -c \
|| exit 1
2017-10-22 14:55:00 +00:00
== Pitfalls
=== Creating Image for VMware (ESXi)
VMware and disk images (virtual disks) is one big mess.
2019-12-22 14:36:06 +00:00
You can find that VMware uses the VMDK format, but the problem is that this is not a single format.
2017-10-22 14:55:00 +00:00
Actually it has many subformats with very different structure and various (in)compatibility with VMware hypervisors.
2019-12-22 14:36:06 +00:00
When I’ ve created a disk image using `qemu-img create -f vmdk` or converted Qcow2 to VMDK using `qemu-img convert -O vmdk`, vSphere client loaded this image without any problem, but the data was corrupted.
2017-10-22 14:55:00 +00:00
Eventually I found in some old documentation that ESXi does not support “sparse” disks…
So after many trials I found out that the least bad and functional solution is to create Qcow2 image and then convert it to VMDK using:
[source, sh]
qemu-img convert -f qcow2 -O vmdk -o adapter_type=lsilogic,subformat=monolithicFlat alpine.qcow2 alpine.vmdk
2019-12-22 14:36:06 +00:00
Unfortunately, this creates a “thick” image, i.e. its size equals the “provisioned space”, not actually used space as in Qcow2.
2017-10-22 14:55:00 +00:00
However, you can compress it with gzip to avoid transferring multiple gigabytes of zeros over network.
2017-08-29 22:54:42 +00:00
== License
This project is licensed under http://opensource.org/licenses/MIT/[MIT License].
For the full text of the license, see the link:LICENSE[LICENSE] file.