• Stars
    star
    293
  • Rank 141,034 (Top 3 %)
  • Language
    Shell
  • License
    MIT License
  • Created about 7 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make customized Alpine Linux disk image for virtual machines

Make Alpine Linux VM Image

Build Status

This project provides a script for making customized Alpine Linux disk images for virtual machines. It’s quite simple (300 LoC of shell), fast (~32 seconds on GitHub Actions) and requires minimum dependencies (QEMU and filesystem tools).

Tip
Don’t need VM, just wanna chroot into Alpine Linux? Try alpine-chroot-install! Or do you want to create a custom rootfs? Then alpine-make-rootfs is for you!

Requirements

  • Linux system with common userland (Busybox or GNU coreutils)

  • POSIX-sh compatible shell (e.g. Busybox ash, dash, Bash, ZSH)

  • qemu-img and qemu-nbd

  • rsync (needed only for --fs-skel-dir)

  • sfdisk (needed only for --partition)

  • mdev or udevadm (needed only for --partition when device hotplug doesn’t work)

  • e2fsprogs (for ext4), btrfs-progs (for Btrfs), or xfsprogs (for XFS)

All dependencies except the first two are automatically installed by the script when running on Alpine.

Usage

Read documentation in alpine-make-vm-image. See .github/workflows/ci.yml for GitHub Actions example.

You can copy alpine-make-vm-image into your repository or download it on demand, e.g.:

wget https://raw.githubusercontent.com/alpinelinux/alpine-make-vm-image/v0.11.1/alpine-make-vm-image \
    && echo '0d5d3e375cb676d6eb5c1a52109a3a0a8e4cd7ac  alpine-make-vm-image' | sha1sum -c \
    || exit 1

Or, if you are on Alpine Linux, you can simply install the alpine-make-vm-image package.

Pitfalls

Creating Image for VMware (ESXi)

VMware and disk images (virtual disks) is one big mess. You can find that VMware uses the VMDK format, but the problem is that this is not a single format. Actually it has many subformats with very different structure and various (in)compatibility with VMware hypervisors.

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. 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:

qemu-img convert -f qcow2 -O vmdk -o adapter_type=lsilogic,subformat=monolithicFlat alpine.qcow2 alpine.vmdk

Unfortunately, this creates a “thick” image, i.e. its size equals the “provisioned space”, not actually used space as in Qcow2. However, you can compress it with gzip to avoid transferring multiple gigabytes of zeros over network.

License

This project is licensed under MIT License. For the full text of the license, see the LICENSE file.

More Repositories

1

docker-alpine

Official Alpine Linux Docker image. Win at minimalism!
Lua
1,067
star
2

aports

[MIRROR] Alpine packages build scripts
Shell
634
star
3

alpine-chroot-install

Install Alpine Linux in chroot with a breeze. Build ARM on Travis CI or any other x86_64 CI.
Shell
285
star
4

alpine-make-rootfs

Make customized Alpine Linux rootfs (base image) for containers
Shell
178
star
5

apk-tools

[MIRROR] Alpine package manager
C
164
star
6

alpine-conf

[MIRROR] Alpine configuration management scripts
Shell
67
star
7

abuild

[MIRROR] Build script to build Alpine packages
Shell
59
star
8

mkinitfs

[MIRROR] Tool to create initramfs images
Shell
54
star
9

awall

[MIRROR] Alpine firewall configuration tool
Lua
46
star
10

alpine-secdb

[MIRROR] Alpine Linux security database
Lua
40
star
11

aports-turbo

[MIRROR] Alpine Linux package database
Lua
24
star
12

docker-abuild

WARNING This project has moved to Alpine Linux GitLab instance
Shell
19
star
13

linux-stable-grsec

grsecurity backports for linux-stable branches
C
17
star
14

alpine-iso

Alpine ISO image generation scripts (mirror)
Makefile
16
star
15

alpine-docker-gitlab

[MIRROR] Gitlab docker image based on Alpine Linux
Shell
14
star
16

turbo-paste

[MIRROR] Turbo paste
Lua
13
star
17

alpine-netboot

Alpine netboot (mirror)
CSS
9
star
18

ca-certificates

Mirror of git://git.alpinelinux.org/ca-certificates
Perl
9
star
19

alpine-wiki

Alpine Linux wiki
HTML
8
star
20

alpine-backup

Alpine Remote Backup (mirror)
Shell
6
star
21

alpine-baselayout

[MIRROR] Alpine boot scripts
Makefile
6
star
22

lua-aports

[MIRROR] Aports tools written in Lua
Lua
6
star
23

dmvpn-tools

[MIRROR] Userland tools to setup and manage DMVPN
Shell
4
star
24

alpine-mksite

[MIRROR] Website for alpinelinux.org
CSS
3
star
25

alpine-drone-ci

Build Alpine Linux packages with drone CI
Shell
2
star
26

alpine-mirror-status

[MIRROR] Scripts to generate Alpine mirror statistics
Lua
2
star
27

alpine_bootstrap

Alpine Linux bootstrap theme for drupal
CSS
1
star
28

build-server-status

[MIRROR] Web page for Alpine Linux build servers
Go
1
star