How to Configure Automatic GPT Partition Mounting in Ubuntu Using systemd-gpt-auto-generator

In traditional Linux server administration, mounting local block storage devices requires explicitly defining each partition inside the static /etc/fstab configuration file or generating custom systemd mount units. However, modern declarative operating system architectures favour auto-discovery models where disk partitions self-identify their role, mount target, and encryption requirements. In Ubuntu, systemd-gpt-auto-generator implements the upstream Discoverable Partitions Specification (DPS). During system boot, this generator scans local GUID Partition Tables (GPT) on the root block device and automatically constructs native systemd mount units for the root filesystem, /home, /srv, /var, /var/tmp, and swap space without requiring manual entries in /etc/fstab.

How systemd-gpt-auto-generator Discovers Partitions via GPT GUIDs

The Discoverable Partitions Specification assigns standardised Type GUIDs to specific operating system mount roles across various hardware architectures. When systemd-gpt-auto-generator runs during early userspace initialisation (both inside the initramfs and immediately after pivoting to the real rootfs), it inspects the partition table of the primary storage drive containing the active root partition.

When the generator identifies partitions tagged with standardised type GUIDs, it dynamically synthesises systemd unit files inside ephemeral runtime directories (/run/systemd/generator/):

  • Root Partition (/): Evaluates architectural GUIDs such as 4f68bce3-e8cd-4db1-96e7-fbcaf984b709 (x86-64) or 69dad710-2ce4-4e3c-b16c-21a1d49abed3 (ARM64). The generator creates the mount unit ensuring the root filesystem mounts with appropriate read-write flags.
  • Home Partition (/home): Partition type GUID 933ac4e1-2eb4-4f13-b844-0e14e2aef915. Generates home.mount, binding the partition to /home.
  • Server Data Partition (/srv): Partition type GUID 3b8f8425-20e0-4f3b-907f-1a25a76f98e8. Generates srv.mount.
  • Variable Data Partition (/var): Partition type GUID 4d21b016-b534-45c2-a9fb-5c16e091fd2d. Generates var.mount.
  • Temporary Variable Storage (/var/tmp): Partition type GUID 7ec6f557-3bc5-4aca-b293-16ef5693d8e3. Generates var-tmp.mount.
  • Swap Space: Partition type GUID 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f. Generates dev-disk-by\...swap units and automatically registers swap activation.

Auditing Existing GPT Partition Type GUIDs on Ubuntu

To determine whether your current storage drives leverage discoverable partition types or generic Linux filesystem GUIDs (0fc63daf-8483-4772-8e79-3d69d8477de4), inspect your disk layout using fdisk or lsblk:

# Inspect disk partitions, mountpoints, and partition type GUIDs
lsblk -o NAME,SIZE,FSTYPE,PARTTYPE,PARTTYPENAME,MOUNTPOINTS /dev/sda

# Inspect partition GUID details using fdisk
sudo fdisk -l /dev/sda

If partitions display generic descriptions such as “Linux filesystem”, systemd-gpt-auto-generator ignores them, leaving mounting responsibilities entirely to /etc/fstab. Setting specific type GUIDs enables automatic generator handling.

Setting Discoverable Partition Types Using fdisk or sgdisk

To convert an existing partition to use declarative discoverability, update its GPT type code. Using sgdisk provides an efficient command-line approach without entering interactive prompts:

# Install gdisk utilities if not already available
sudo apt update && sudo apt install -y gdisk

# Set partition 2 on /dev/sda as Discoverable Linux /home
sudo sgdisk -t 2:933ac4e1-2eb4-4f13-b844-0e14e2aef915 /dev/sda

# Set partition 3 on /dev/sda as Discoverable Linux /srv
sudo sgdisk -t 3:3b8f8425-20e0-4f3b-907f-1a25a76f98e8 /dev/sda

# Set partition 4 on /dev/sda as Linux Swap
sudo sgdisk -t 4:0657fd6d-a4ab-43c4-84e5-0933c84b4f4f /dev/sda

Alternatively, open interactive fdisk /dev/sda, press t, select the partition number, and enter the respective type shortcut (such as Linux /home or Linux swap).

Inspecting Generated Mount Units in Runtime Storage

Whenever systemd reloads or during system boot, generators execute before standard unit files are processed. Inspect the units dynamically created by systemd-gpt-auto-generator within the volatile runtime tree:

# List units produced by the GPT auto-generator
ls -la /run/systemd/generator/ | grep -E "home|srv|var|swap"

# Inspect the auto-generated home mount definition
cat /run/systemd/generator/home.mount

Notice how the generated unit automatically establishes proper dependencies, ensuring the mount depends on the underlying block device device-mapper or SCSI node and orders itself before local-fs.target.

Handling Automatic LUKS Encrypted Partition Discovery

If a partition conforming to DPS GUID standards is encrypted with Linux Unified Key Setup (LUKS), systemd-gpt-auto-generator detects the encryption header and dynamically generates a [email protected] unit alongside the mount unit:

  • The generator invokes systemd-cryptsetup to unlock the volume during boot.
  • If the partition utilizes TPM2 enrollment via systemd-cryptenroll, the volume unlocks automatically without prompting for a passphrase.
  • Once unlocked, the decrypted block device in /dev/mapper/ is bound directly to its intended target (such as /home or /var).

Controlling and Disabling GPT Auto-Mounting

Under specific deployment workflows—such as complex high-availability clusters or multi-boot configurations—you may wish to override or disable auto-generator behaviour:

  • /etc/fstab Precedence: Any explicit mount entry defined inside /etc/fstab overrides the GPT auto-generator. If /home is declared in /etc/fstab, systemd prioritises the fstab configuration and suppresses the auto-generated unit.
  • Kernel Command Line Overrides: Disable the generator entirely during boot by passing systemd.gpt_auto=0 in the GRUB kernel parameters (/etc/default/grub).
  • Root Only Mode: To allow auto-discovery of the root filesystem while disabling secondary partition mounts, pass systemd.gpt_auto=root-only.

Adopting discoverable partitions eliminates configuration drift, simplifies bare-metal image replication, and allows disk images to self-assemble during initial boot across modern Ubuntu deployments.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.