Skip to content

Arch Linux Automate EFI Partition Updates

Automate updating of the EFI system partition (ESP) when a kernel update or mkinitcpio executes.

Note

This is only required when using alternative ESP path or using a boot loader (Arch Wiki).

Basic Configuration

  1. Create a Systemd path unit file.
    # nano /etc/systemd/system/efistub-update.path
    
    [Unit]
    Description=Copy EFISTUB Kernel to UEFI System Partition
    
    [Path]
    PathChanged=/boot/initramfs-linux-fallback.img
    
    [Install]
    WantedBy=multi-user.target
    WantedBy=system-update.target
    
  2. Create Systemd service unit file.
    # nano /etc/systemd/system/efistub-update.service
    
    [Unit]
    Description=Copy EFISTUB Kernel to UEFI System Partition
    
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/cp -f /boot/vmlinuz-linux /boot/EFI/arch/vmlinuz-linux
    ExecStart=/usr/bin/cp -f /boot/initramfs-linux.img /boot/EFI/arch/initramfs-linux.img
    ExecStart=/usr/bin/cp -f /boot/initramfs-linux-fallback.img /boot/EFI/arch/initramfs-linux-fallback.img
    
  3. Enable and start the path unit service.
    # systemctl enable efistub-update.path
    
    # systemctl start efistub-update.path
    

Windows Configuration

Note

It is assumed the environment is multi booting Windows and Linux on the same system.

Note

For this configuration to work the Windows' EFI system partition (ESP) must be used.

Note

Repeat these steps on each operating system except Windows.

  1. Boot into Linux.
  2. Create a Windows EFI system partition (ESP) mount point directory.
    # mkdir /boot/WIN
    
  3. Find the Windows EFI system partition (ESP) UUID.
    $ lsblk -f
    
    NAME   FSTYPE FSVER LABEL          UUID                                 FSAVAIL FSUSE% MOUNTPOINT
    sda                                                                                    
    ├─sda1 ntfs         Recovery       EA5672C356729055                                    
    ├─sda2 vfat   FAT32 WIN EFI        DAB8-549A                             430.3M    21%
    ├─sda3                                                                                 
    └─sda4 ntfs                        081E33AE1E3393A2                                    
    sdb                                                                                    
    ├─sdb1 vfat   FAT32                07ED-7884                                           
    └─sdb2 ext4   1.0   archlinux-test 0f43d7db-ce0c-4d12-a71f-7af646a1305b                
    sdc                                                                                    
    ├─sdc1 vfat   FAT32                5352-AC6C                             376.9M    24% /boot
    └─sdc2 btrfs        ArchLinux      cce03871-dc3b-4418-90f9-87ca427d4223  114.8G    51% /srv
    
  4. Mount the Windows EFI system partition (ESP).
    # mount -U DAB8-549A /boot/WIN
    
  5. Create a directory for Linux boot files.
    # mkdir /boot/WIN/EFI/arch
    
  6. Create Systemd path unit file.
    # nano /etc/systemd/system/efistub-update.path
    
    [Unit]
    Description=Copy EFISTUB Kernel to UEFI System Partition
    
    [Path]
    PathChanged=/boot/initramfs-linux-fallback.img
    
    [Install]
    WantedBy=multi-user.target
    WantedBy=system-update.target
    
  7. Create Systemd service unit file.
    # nano /etc/systemd/system/efistub-update.service
    
    [Unit]
    Description=Copy EFISTUB Kernel to UEFI System Partition
    
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/mount -U DAB8-549A /boot/WIN/
    ExecStart=/usr/bin/cp -f /boot/vmlinuz-linux /boot/WIN/EFI/arch/vmlinuz-linux
    ExecStart=/usr/bin/cp -f /boot/initramfs-linux.img /boot/WIN/EFI/arch/initramfs-linux.img
    ExecStart=/usr/bin/cp -f /boot/initramfs-linux-fallback.img /boot/WIN/EFI/arch/initramfs-linux-fallback.img
    ExecStart=/usr/bin/umount /boot/WIN/
    
  8. Enable and start the path unit service.
    # systemctl enable efistub-update.path
    
    # systemctl start efistub-update.path