Install or refresh a systemd shutdown service that regenerates the GRUB configuration immediately before shutdown, reboot, or halt.
Version 1.0.1
When used with grub-btrfs, newly created Snapper snapshots may not be incorporated into the complete GRUB menu until grub-mkconfig is executed. This utility automates that step so newly created snapshot boot entries are available after the next reboot.
- Installs or refreshes a dedicated systemd shutdown service
- Automatically regenerates the GRUB configuration before shutdown, reboot, or halt
- Uses the distribution-neutral
grub-mkconfigcommand - Works with existing
grub-btrfsinstallations - Safe to rerun to refresh the installed helper and service
- Self-contained with no installation package required
- Linux system using systemd
- GRUB
grub-mkconfigsudo
Run the script as your normal user.
chmod +x add_updategrub-service.sh
./add_updategrub-service.shDo not run the script with sudo.
The script requests elevated privileges only when required.
The utility installs or refreshes:
/opt/snapper/bin/update-grub-shutdown.sh
/etc/systemd/system/updategrub-shutdown.service
The service is enabled automatically.
This utility is intended for systems using grub-btrfs.
Whenever a new Snapper snapshot is created, the corresponding GRUB boot entry may not appear in the complete menu until grub-mkconfig has been executed.
The installed helper runs:
grub-mkconfig -o /boot/grub/grub.cfgBy updating the GRUB configuration during system shutdown, the latest snapshot entries are automatically available at the next boot without requiring any manual intervention.
Tested on Debian, Ubuntu, Kubuntu, and CachyOS. The utility is designed for Debian/Ubuntu-based and Arch-based systems using systemd, GRUB, Snapper, and grub-btrfs.
| Distribution | Test case | Result |
|---|---|---|
| Debian | Installed and enabled the service; verified full GRUB regeneration during shutdown/reboot | Passed |
| Ubuntu | Installed, enabled, and executed the shutdown helper | Passed |
| Kubuntu | Installed, enabled, and executed the shutdown helper | Passed |
| CachyOS | Installed alongside grub-btrfsd and the Pacman GRUB hook; verified full shutdown regeneration |
Passed |
Version 1.0.1 was regression-tested on Debian and CachyOS after replacing the Debian-specific update-grub wrapper with grub-mkconfig -o /boot/grub/grub.cfg.
See ARCHITECTURE.md for the installed components, systemd lifecycle, and compatibility model.
GPL-3.0-or-later