Skip to content

Instantly share code, notes, and snippets.

@thhart
Last active March 22, 2024 06:46
Show Gist options
  • Save thhart/35f6e4e715c70c2cbe7c5846311d1f9f to your computer and use it in GitHub Desktop.
Save thhart/35f6e4e715c70c2cbe7c5846311d1f9f to your computer and use it in GitHub Desktop.
Sample systemd setup to mount efi partitions and sync them in a service on shutdown
[Unit]
Description=Sync EFI partitions
[Service]
Type=oneshot
ExecStop=/usr/bin/sync-efi
[Install]
WantedBy=multi-user.target
#sample efi file to mount efi partitions and sync them in a service on shutdown
#UUID are different for each system of course, run blkid to see
UUID=EE08-63AC /boot/efi vfat utf8,nofail 0 2
UUID=D6DD-B604 /boot/efi2 vfat utf8,nofail 0 2
UUID=D725-1927 /boot/efi3 vfat utf8,nofail 0 2
UUID=D761-CCBA /boot/efi4 vfat utf8,nofail 0 2
!/bin/bash
# Find all EFI partitions and sync them
for partition in $(egrep "boot/efi[0-9]" /etc/fstab | awk '{ print $2 }'); do
echo "Syncing EFI partition: $partition"
rsync -a --delete /boot/efi $partition
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment