Skip to main content
This guide shows you how to build bootable Azure Linux images from precompiled RPMs in the Azure Linux package repository.

Prerequisites

Before building images, ensure you have the required build tools installed. See the Prerequisites documentation for detailed setup instructions. For Ubuntu 22.04, the quick setup is:
# Install prerequisites
sudo make -C toolkit install-prereqs

# Create Go symlinks
sudo ln -sf /usr/lib/go-1.23/bin/go /usr/bin/go
sudo ln -sf /usr/lib/go-1.23/bin/gofmt /usr/bin/gofmt

# Configure Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
After configuring Docker, you’ll need to log out and log back in for the user group changes to take effect.

Clone Azure Linux Repository

1

Clone the repository

git clone https://github.com/microsoft/azurelinux.git
cd azurelinux
2

Checkout stable build

# Sync to the latest stable build
git checkout 3.0-stable
3

Navigate to toolkit

cd toolkit

Build VHD or VHDX Images

Azure Linux supports both VHD (Generation 1) and VHDX (Generation 2) image formats. These images are built from precompiled RPMs at https://packages.microsoft.com/azurelinux/3.0/prod/.
No user account is provisioned by default in VHD/VHDX images. You must build and attach the meta-user-data.iso image to provision user accounts via cloud-init.

Build VHDX Image (Generation 2 / UEFI)

# Image is placed in ../out/images/core-efi
sudo make image -j8 REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/core-efi.json

Build VHD Image (Generation 1 / Legacy BIOS)

# Image is placed in ../out/images/core-legacy
sudo make image -j8 REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/core-legacy.json
The -j8 flag uses 8 parallel jobs. Adjust this based on your system’s CPU cores for optimal build performance.

Build ISO Image

The following builds a bootable ISO image:
# Image is placed in ../out/images/full
sudo make iso -j8 REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/full.json

Create Virtual Machine

After building your image, copy it to your VM host machine.

Create VHD(X) Virtual Machine with Hyper-V

1

Create New Virtual Machine

From Hyper-V, select Action → New → Virtual Machine.
2

Configure VM Name

Provide a name for your VM and press Next >.
3

Select Generation

  • For VHD: select Generation 1
  • For VHDX: select Generation 2
Press Next >.
4

Configure Memory

Change memory size if desired, then press Next >.
5

Configure Network

Select a virtual switch, then press Next >.
6

Attach Existing Disk

  1. Select Use an existing virtual hard disk
  2. Browse and select your VHD(X) file
  3. Press Finish

Configure Boot Options (Generation 2 / VHDX Only)

1

Open VM Settings

Right-click your virtual machine from Hyper-V Manager and select Settings….
2

Configure Security

Select Security and under Template: select Microsoft UEFI Certificate Authority.
3

Add DVD Drive

  1. Select the SCSI Controller from the Hardware panel
  2. Select DVD Drive and press Add
4

Apply Changes

Select Apply to apply all changes.

Mount the Meta-User-Data ISO

You must mount the meta-user-data.iso image to provision user accounts. See the Cloud-init Configuration guide for details on building this image.
1

Open VM Settings

Right-click your virtual machine from Hyper-V Manager and select Settings….
2

Select DVD Drive

  • For Gen1/VHD: Select DVD Drive nested under IDE Controller 1
  • For Gen2/VHDX: Select DVD Drive nested under SCSI Controller
3

Attach ISO

  1. Select Image File:
  2. Browse to the meta-user-data.iso file
  3. Select Apply to apply all changes

Boot and Sign In

1

Connect to VM

Right-click your VM and select Connect….
2

Start VM

Select Start.
3

Sign In

Wait for Azure Linux to boot to the login prompt, then sign in with the username and password you provisioned in the meta-user-data.iso.

Build Parameters

Common Make Parameters

  • REBUILD_TOOLS=y - Rebuilds the build tools from source
  • REBUILD_PACKAGES=n - Uses precompiled packages from the Azure Linux repository instead of building from source
  • CONFIG_FILE - Specifies the image configuration file to use
  • -j8 - Number of parallel build jobs (adjust based on your CPU cores)

Available Image Configs

  • core-efi.json - VHDX image with UEFI boot (Generation 2)
  • core-legacy.json - VHD image with legacy BIOS boot (Generation 1)
  • full.json - Full ISO installer image

Build docs developers (and LLMs) love