Snapshots Fix Snapper-Grub (#3930)

* pr1

* pr2

* pr3

* pr3-2

* pr3-3

* pr3-4

* pr4

* Revert hardware.py to original state on snapshots branch

* Revert genfstab and pacstrap command changes
This commit is contained in:
HADEON 2025-11-16 11:40:38 +01:00 committed by GitHub
parent 6bdb756650
commit 375d64a600
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 11 deletions

View File

@ -945,19 +945,20 @@ class Installer:
self.enable_service('snapper-timeline.timer')
self.enable_service('snapper-cleanup.timer')
elif snapshot_type == SnapshotType.Timeshift:
debug('Setting up Btrfs timeshift')
self.pacman.strap('cronie')
self.pacman.strap('timeshift')
self.enable_service('cronie.service')
if bootloader and bootloader == Bootloader.Grub:
self.pacman.strap('grub-btrfs')
self.pacman.strap('inotify-tools')
self._configure_grub_btrfsd()
self.enable_service('grub-btrfsd.service')
if bootloader and bootloader == Bootloader.Grub:
debug('Setting up grub integration for either')
self.pacman.strap('grub-btrfs')
self.pacman.strap('inotify-tools')
self._configure_grub_btrfsd(snapshot_type)
self.enable_service('grub-btrfsd.service')
def setup_swap(self, kind: str = 'zram') -> None:
if kind == 'zram':
@ -997,10 +998,17 @@ class Installer:
return root
return None
def _configure_grub_btrfsd(self) -> None:
# See https://github.com/Antynea/grub-btrfs?tab=readme-ov-file#-using-timeshift-with-systemd
debug('Configuring grub-btrfsd service')
def _configure_grub_btrfsd(self, snapshot_type: SnapshotType) -> None:
if snapshot_type == SnapshotType.Timeshift:
snapshot_path = '--timeshift-auto'
elif snapshot_type == SnapshotType.Snapper:
snapshot_path = '/.snapshots'
else:
raise ValueError('Unsupported snapshot type')
debug('Configuring grub-btrfsd service for {snapshot_type} at {snapshot_path}')
# Works for either snapper or ts just adpating default paths above
# https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#id-1.14.3
systemd_dir = self.target / 'etc/systemd/system/grub-btrfsd.service.d'
systemd_dir.mkdir(parents=True, exist_ok=True)
@ -1011,9 +1019,9 @@ class Installer:
"""
[Service]
ExecStart=
ExecStart=/usr/bin/grub-btrfsd --syslog --timeshift-auto
ExecStart=/usr/bin/grub-btrfsd --syslog {snapshot_path}
"""
)
).format(snapshot_path=snapshot_path)
override_conf.write_text(config_content)
override_conf.chmod(0o644)