Skip to content

About

Installs a systemd service that runs update-grub during shutdown and reboot.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

add_updategrub-service

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.


Features

  • Installs or refreshes a dedicated systemd shutdown service
  • Automatically regenerates the GRUB configuration before shutdown, reboot, or halt
  • Uses the distribution-neutral grub-mkconfig command
  • Works with existing grub-btrfs installations
  • Safe to rerun to refresh the installed helper and service
  • Self-contained with no installation package required

Requirements

  • Linux system using systemd
  • GRUB
  • grub-mkconfig
  • sudo

Usage

Run the script as your normal user.

chmod +x add_updategrub-service.sh

./add_updategrub-service.sh

Do not run the script with sudo.

The script requests elevated privileges only when required.


What Gets Installed

The utility installs or refreshes:

/opt/snapper/bin/update-grub-shutdown.sh

/etc/systemd/system/updategrub-shutdown.service

The service is enabled automatically.


Use Case

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.cfg

By updating the GRUB configuration during system shutdown, the latest snapshot entries are automatically available at the next boot without requiring any manual intervention.


Compatibility

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.

Verified test cases

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.


Architecture

See ARCHITECTURE.md for the installed components, systemd lifecycle, and compatibility model.


License

GPL-3.0-or-later

About

Installs a systemd service that runs update-grub during shutdown and reboot.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages