Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,19 +945,20 @@ def setup_btrfs_snapshot(

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':
Expand Down Expand Up @@ -997,10 +998,17 @@ def _get_root(self) -> PartitionModification | LvmVolume | None:
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)
Expand All @@ -1011,9 +1019,9 @@ def _configure_grub_btrfsd(self) -> None:
"""
[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)
Expand Down