azure-ephemeral-disk-setup - Man Page

detect, validate, format, and mount Azure ephemeral local disks (NVMe or SCSI) with optional RAID aggregation

Synopsis

azure-ephemeral-disk-setup

Description

azure-ephemeral-disk-setup is a systemd-managed one-shot initialization service for Microsoft Azure virtual machines that prepares ephemeral (temporary) disks for use. It supports both NVMe and SCSI ephemeral disks and is capable of aggregating multiple NVMe devices into a RAID-0 array using mdadm.

The service is opt-in and should be configured through /etc/azure-ephemeral-disk-setup.conf. It runs early in the boot process and aims to be idempotent, safe, and compatible with existing tools such as cloud-init and WALinuxAgent.

Logs are printed to stderr and are accessible via journalctl if using the systemd service:

journalctl -u azure-ephemeral-disk-setup.service

Configuration

Configuration is loaded from:

The following environment variables are supported:

Operation

The service performs the following steps:

1. Load and Validate Configuration

  • Configuration is read via filtered source /etc/azure-ephemeral-disk-setup.conf, allowing only safe environment-style assignments.
  • If invalid values are detected, the service exits with error.
  • Required tools (mkfs.${AZURE_EPHEMERAL_DISK_SETUP_FS_TYPE}, mdadm) must be available.

2. Check for Existing Mounts

If the mount point is already configured:

  • with a matching /etc/fstab line containing the comment comment=azure-ephemeral-disk-setup, the service will wait for mount to complete.

    • if mount succeeds, service exits with success.
    • if mount does not complete, this service will check if the ephemeral disks have been reallocated and reconfigure them via the standard detection/validation process below.
  • by cloud-init and source is /dev/disk/cloud/azure_resource-part1:

    • if AZURE_EPHEMERAL_DISK_SETUP_SCSI_RESOURCE=false, the service exits with success allowing cloud-init to manage the disk.
    • if AZURE_EPHEMERAL_DISK_SETUP_SCSI_RESOURCE=true, the service exits with error as the entry is either stale or conflicting.
  • by other tools/services/configuration, the service exits with error.

3. Detect and Validate Disks

NVMe disks are detected via:

  • Model names:

    • Microsoft NVMe Direct Disk
    • Microsoft NVMe Direct Disk v2

SCSI resource disk is detected and validated if AZURE_EPHEMERAL_DISK_SETUP_SCSI_RESOURCE=true and no ephemeral NVMe disks are detected.

See Safety and Validation section for more details on how disks are validated to ensure no data is lost.

4. Disk Setup

Each candidate disk is checked to ensure:

  • It is a block device
  • It is not mounted
  • It is not partitioned (unless NTFS resource disk)
  • It has no existing filesystem (unless NTFS resource disk)

If any disk fails these checks, the service aborts with a detailed error.

5. Aggregation with RAID-0 For VMs with Multiple local NVMe Disks

If more than one NVMe disk is found and aggregation is enabled with mdadm:

mdadm --create "/dev/md/${AZURE_EPHEMERAL_DISK_SETUP_MDADM_NAME}_0" \
  --level=0 \
  --raid-devices=N \
  --metadata=1.2 \
  --chunk="$AZURE_EPHEMERAL_DISK_SETUP_MDADM_CHUNK" \
  --name="$AZURE_EPHEMERAL_DISK_SETUP_MDADM_NAME" \
  ${DISKS[@]}

Configuration is not written to /etc/mdadm/mdadm.conf in favor of kernel auto-detection.

6. Format Filesystem

  • Formats target device (either RAID device or single disk) directly without partitioning
  • Uses mkfs.ext4 [-F] -L AzureEphmDsk ... or mkfs.xfs [-f] -L AzureEphmDsk ... with the force flag only if it is reformatting the SCSI resource disk

7. Persistenting Mount

If /etc/fstab is writable:

  • Previous entries with comment=azure-ephemeral-disk-setup are removed
  • New entry added:

    LABEL=AzureEphmDsk <mount_point> <fs_type> defaults,nofail,comment=azure-ephemeral-disk-setup 0 2

If /etc/fstab is read-only or does not exist, it will not be updated. It will be mounted by this service on every boot.

8. Mounting

For persistent mounts:

  • Tries to mount using systemd (systemctl start <mount.unit>)
  • Falls back to direct mount call if mount unit fails to start

For non-persitent mounts, a mount call is used.

Safety and Validation

This service only formats NVMe disks that are:

SCSI resource disks are only reformatted if it:

Calls to mkfs and mdadm do not use --force for formatting or mdadm array creation unless reformatting validated NTFS SCSI disk.

Exit Status

Fstab Strategy

The following values are used when generating an /etc/fstab entry for the ephemeral disk:

Avoiding Conflicts with Cloud-Init

If AZURE_EPHEMERAL_DISK_SETUP_SCSI_RESOURCE=false, this service will exit with success if cloud-init is managing the SCSI resource disk at the same mount point. Given the widespread usage of cloud-init for managing the SCSI resource disk, this is the default case.

If AZURE_EPHEMERAL_DISK_SETUP_SCSI_RESOURCE=true, cloud-init management of the resource disk must be disabled. There are two options for disabling cloud-init’s management of SCSI resource disk:

Disabling cloud-init management of SCSI resource disk via udev rules

Disable udev rules responsible for creating the /dev/disk/cloud symlinks:

ln -sf /dev/null /etc/udev/rules.d/66-azure-ephemeral.rules

If cloud-init doesn’t detect the device, it will not attempt to format/mount it.

Disabling cloud-init management of SCSI resource disk via cloud-init configuration (cloud-init >= 25.3)

Work is ongoing to introduce a flag to the Azure datasource to control behavior. See pull request (https://github.com/canonical/cloud-init/pull/6323).

This is expected to be available in cloud-init 25.3.

Avoiding Conflicts with Walinuxagent

WALinuxAgent must be configured with ResourceDisk.Format=n.

If AZURE_EPHEMERAL_DISK_SETUP_SCSI_RESOURCE=true, this service will exit with error if /etc/waagent.conf sets ResourceDisk.Format=y.

Examples

Basic usage:

sudo azure-ephemeral-disk-setup

Enable management of SCSI resource disk:

# /etc/azure-ephemeral-disk-setup.conf
AZURE_EPHEMERAL_DISK_SETUP_SCSI_RESOURCE=true

Files

Service Ordering

DefaultDependencies=no to avoid typical service dependencies as we want to start early.

After:

Before:

Debugging

All logs are written to stderr and accessible with:

journalctl -u azure-ephemeral-disk-setup.service

See Also

mdadm(8), mount(8), cloud-init(8), waagent(8)

Project Home: <https://github.com/Azure/azure-vm-utils>

Info

August 08, 2025 azure-ephemeral-disk-setup 0.7.0-1.fc44 User Manual