systemd-gpt-auto-generator creates efi.automounts unit in BIOS based system

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 9

Issue

  • What is systemd-gpt-auto-generator?

  • A system in BIOS mode has a /boot/efi entry in /etc/fstab. Commenting out this entry and rebooting results in the /efi partition being automatically mounted.

    • The /boot/efi entry in /etc/fstab has been commented out:

      # cat /etc/fstab | grep efi          
      #UUID=7B77-95E7  /boot/efi  vfat   defaults,uid=0,gid=0,umask=077,shortname=winnt    0   2
      
    • The /efi partition is automatically mounted post-reboot:

      # lsblk
      NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
      nvme0n1     259:0    0   70G  0 disk
      ├─nvme0n1p1 259:9    0    1M  0 part
      ├─nvme0n1p2 259:10   0  200M  0 part /efi            <------- Automatically mounted
      ├─nvme0n1p3 259:11   0  500M  0 part /boot 
      

Resolution

What is systemd-gpt-auto-generator?

  • The systemd-gpt-auto-generator is a systemd utility that automatically mounts partitions based on the GUID Partition Table (GPT) layout. It identifies partitions by their type GUIDs and assigns appropriate mount points, such as /boot/efi, for UEFI systems. However, in BIOS mode, the generator may still detect the GPT layout and mount partitions like /efi if no explicit entry exists in /etc/fstab

Given this behavior, there are two possible approaches to address the problem:

  • Prevent the systemd-gpt-auto-generator from automatically mounting the partition by adding the following argument to the kernel command line:

    # grubby --update-kernel=ALL --args=systemd.gpt_auto=no
    
  • Since the system is operating in BIOS mode, the /boot/efi partition is unnecessary. You can destroy the partition and remove its entry from /etc/fstab to avoid any confusion.

These steps ensure that the /efi partition is no longer automatically mounted and the system operates without unnecessary partitions in BIOS mode.

Root Cause

The automatic mounting of /efi is triggered by the systemd-gpt-auto-generator. This generator creates entries in /run/systemd/generator.late because there is no /boot/efi partition specified in /etc/fstab. In BIOS mode:

  • The generator behavior is expected since it detects the presence of an EFI partition layout but lacks the /boot/efi entry in /etc/fstab.

  • On UEFI based systems, /boot/efi is used as the default mount point, while /efi is not utilized. The generator misinterprets the absence of /boot/efi as a reason to mount /efi instead.

Diagnostic Steps

  • Install a system in BIOS mode with "EFI ready" partitioning.

    ignoredisk --only-use=vda
    clearpart --all --initlabel
    zerombr
    part biosboot --fstype="biosboot" --size=1
    part /boot --fstype=xfs --size=1024
    part /boot/efi --fstype=efi --size=200
    part pv.00 --size=1 --grow
    volgroup vg0 pv.00
    logvol /              --name=root --vgname=vg0 --size=10240 --fstype=xfs
    logvol swap           --name=swap --vgname=vg0 --size=1024
    
  • Comment out the /boot/efi entry in /etc/fstab.

    #UUID=7B77-95E7 /boot/efi   vfat    defaults,uid=0,gid=0,umask=077,shortname=winnt  0   2
    
  • Reboot the system and verify the behavior of the /efi partition.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments