Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debian/files
9 changes: 5 additions & 4 deletions 50-siduction.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
#
# Name: /usr/lib/snapper/plugins/50-siduction.sh
# Part of siduction-btrfs
Expand Down Expand Up @@ -38,7 +38,7 @@ case "$1" in
"create-snapshot-post")
echo "$(date +%T) Plugin 50-siduction: Inside create-snapshot-post" >> /var/log/snapper.log
# If full apt-aktion is done, this script change snappers description.
/usr/share/siduction/snapshot-description.sh "$4" &
/usr/share/siduction-btrfs/snapshot-description.sh "$4" &
;;

# This section is for systemd-boot only.
Expand Down Expand Up @@ -84,7 +84,7 @@ case "$1" in
if [ -e /boot/grub/grub.cfg ] && [ -w /boot/grub/grub.cfg ]; then

echo "$(date +%T) Plugin 50-siduction: Forwarding to rollback-grub." >> /var/log/snapper.log
/usr/share/siduction/rollback-grub.sh "$new_sn" &
/usr/share/siduction-btrfs/rollback-grub.sh "$new_sn" &
wait
echo "$(date +%T) Plugin 50-siduction: Return from rollback-grub." >> /var/log/snapper.log
true
Expand All @@ -97,7 +97,7 @@ case "$1" in
# Create a menu entry for the rollback target.
echo "$(date +%T) Plugin 50-siduction: Forwarding to rollback-sd-boot." >> /var/log/snapper.log

/usr/share/siduction/rollback-sd-boot.sh "$new_sn" "$sd_boot_dir" "$entry_part" &
/usr/share/siduction-btrfs/rollback-sd-boot.sh "$new_sn" "$sd_boot_dir" "$entry_part" &
wait
echo "$(date +%T) Plugin 50-siduction: Return from rollback-sd-boot." >> /var/log/snapper.log

Expand Down Expand Up @@ -134,4 +134,5 @@ case "$1" in
fi
;;
esac
update-grub
exit 0
2 changes: 2 additions & 0 deletions 60-siduction-btrfs.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
disable snapper-boot.timer
disable snapper-timeline.timer
2 changes: 1 addition & 1 deletion 91-siduction-entry-key.install
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
set -e

# Only run if / is btrfs
if [ ! -e /usr/share/siduction/btrfs ]; then
if [ ! -e /usr/share/siduction-btrfs/btrfs ]; then
exit 0
fi

Expand Down
10 changes: 6 additions & 4 deletions Info.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ The ESP is mounted under */efi*, or in the absence of the XBOOTLDR under */boot*
and the scripts
*/usr/lib/snapper/plugins/50-siduction.sh*
*/usr/share/siduction/rollback-grub.sh*
*/usr/share/siduction/grub-menu-title.sh
*/usr/share/siduction/grub-menu-title.sh*
*/usr/share/siduction/rollback-sd-boot.sh*
*/usr/share/siduction/snapshot-description.sh*
*/usr/lib/systemd/system-preset/60-siduction-btrfs.preset*
*/usr/lib/kernel/install.d/91-siduction-entry-key.install*

### How the package works

As of version 0.3.0, siduction-btrfs uses the Snapper plugin directory.
There the script *50-siduction* listens to the Snapper actions in the root subvolume and executes the scripts *snapshot-description*, *rollback-grub*, *grub-menu-title*, or *rollback-sd-boot* if required.
To manage snapshots, snapper-gui is quite useful. However, a rollback requires a terminal with root rights.
The graphical program *btrfs-assistant* is very useful for managing snapshots. However, a rollback requires a terminal with root rights.

**When using the boot manager GRUB**
After a rollback, the file */boot/grub/grub.cfg* is recreated in the rollback target using chroot and GRUB is then reinstalled from the rollback target. This allows the user to access the rollback target directly with a simple reboot. All other subvolumes, including the previously used one, can be accessed via the *siduction snapshots* submenu.
Expand Down Expand Up @@ -88,16 +89,17 @@ Die ESP hängt man unter */efi*, oder bei Abwesenheit der XBOOTLDR unter */boot*
und die Skripte
*/usr/lib/snapper/plugins/50-siduction.sh*
*/usr/share/siduction/rollback-grub.sh*
*/usr/share/siduction/grub-menu-title.sh
*/usr/share/siduction/grub-menu-title.sh*
*/usr/share/siduction/rollback-sd-boot.sh*
*/usr/share/siduction/snapshot-description.sh*
*/usr/lib/systemd/system-preset/60-siduction-btrfs.preset*
*/usr/lib/kernel/install.d/91-siduction-entry-key.install*

### Wie das Paket arbeitet

Ab Version 0.3.0 verwendet siduction-btrfs das Snapper Plugin Verzeichnis.
Dort lauscht das Skript *50-siduction* auf die Snapper Aktionen im root Subvolumen und führt bei Bedarf die Skripte *snapshot-description*, *rollback-grub*, *grub-menu-title* oder *rollback-sd-boot* aus.
Um Schnappschüsse zu verwalten, ist snapper-gui ganz nützlich. Ein Rollback jedoch erfordert ein Terminal mit root Rechten.
Zur Verwaltung von Snapshots ist das graphische Programm *btrfs-assistant* sehr nützlich. Ein Rollback jedoch erfordert ein Terminal mit root Rechten.

**Bei Verwendung des Bootmanagers GRUB**
Nach einem Rollback wird im Rollbackziel mittels chroot die Datei */boot/grub/grub.cfg* neu erstellt und anschließend aus dem Rollbackziel heraus GRUB neu installiert. Dadurch gelangt der User mit einem einfachen Reboot direkt in das Rollbackziel. Alle anderen Subvolumen, auch das zuvor verwendete, sind über das Untermenü *siduction snapshots* erreichbar.
Expand Down
2 changes: 2 additions & 0 deletions btrfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DO NOT REMOVE THIS FILE!
It is required by the siduction_btrfs systemd units.
61 changes: 61 additions & 0 deletions configs/home
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# subvolume to snapshot
SUBVOLUME="/home"

# filesystem type
FSTYPE="btrfs"


# btrfs qgroup for space aware cleanup algorithms
QGROUP=""


# fraction or absolute size of the filesystems space the snapshots may use
SPACE_LIMIT="0.5"

# fraction or absolute size of the filesystems space that should be free
FREE_LIMIT="0.2"


# users and groups allowed to work with config
ALLOW_USERS=""
ALLOW_GROUPS=""

# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
# directory
SYNC_ACL="yes"


# start comparing pre- and post-snapshot in background after creating
# post-snapshot
BACKGROUND_COMPARISON="yes"


# run daily number cleanup
NUMBER_CLEANUP="yes"

# limit for number cleanup
NUMBER_MIN_AGE="1800"
NUMBER_LIMIT="20"
NUMBER_LIMIT_IMPORTANT="5"


# create hourly snapshots
TIMELINE_CREATE="yes"

# cleanup hourly snapshots after some time
TIMELINE_CLEANUP="yes"

# limits for timeline cleanup
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="11"
TIMELINE_LIMIT_DAILY="6"
TIMELINE_LIMIT_WEEKLY="1"
TIMELINE_LIMIT_MONTHLY=""
TIMELINE_LIMIT_YEARLY=""


# cleanup empty pre-post-pairs
EMPTY_PRE_POST_CLEANUP="yes"

# limits for empty pre-post-pair cleanup
EMPTY_PRE_POST_MIN_AGE="1800"
61 changes: 61 additions & 0 deletions configs/root
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# subvolume to snapshot
SUBVOLUME="/"

# filesystem type
FSTYPE="btrfs"


# btrfs qgroup for space aware cleanup algorithms
QGROUP=""


# fraction or absolute size of the filesystems space the snapshots may use
SPACE_LIMIT="0.5"

# fraction or absolute size of the filesystems space that should be free
FREE_LIMIT="0.2"


# users and groups allowed to work with config
ALLOW_USERS=""
ALLOW_GROUPS=""

# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
# directory
SYNC_ACL="yes"


# start comparing pre- and post-snapshot in background after creating
# post-snapshot
BACKGROUND_COMPARISON="yes"


# run daily number cleanup
NUMBER_CLEANUP="yes"

# limit for number cleanup
NUMBER_MIN_AGE="1800"
NUMBER_LIMIT="20"
NUMBER_LIMIT_IMPORTANT="5"


# create hourly snapshots
TIMELINE_CREATE="no"

# cleanup hourly snapshots after some time
TIMELINE_CLEANUP="yes"

# limits for timeline cleanup
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY=""
TIMELINE_LIMIT_DAILY="6"
TIMELINE_LIMIT_WEEKLY="2"
TIMELINE_LIMIT_MONTHLY="1"
TIMELINE_LIMIT_YEARLY=""


# cleanup empty pre-post-pairs
EMPTY_PRE_POST_CLEANUP="yes"

# limits for empty pre-post-pair cleanup
EMPTY_PRE_POST_MIN_AGE="1800"
6 changes: 3 additions & 3 deletions debian/README.Debian
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Optimizes the boot menu and the description in Snapper
After a rollback with Snapper, siduction-btrfs sets the default boot entry to
the rollback target.
When using Grub:
The default boot entry points to the new default subvolume.
After rebooting into the new default subvolume, grub is installed from there.
After a rollback, the file /boot/grub/grub.cfg is recreated in the rollback
target using chroot and then GRUB is reinstalled from the rollback target.
When using systemd-boot:
siduction-btrfs generates new menu entries. All kernels present in the
rollback target are taken into account. After deleting subvolumes,
Expand All @@ -19,4 +19,4 @@ based on Debian SID.

The functionality of grub-btrfs remains unaffected.

-- Axel Konrad <ak-li@siduction.org> Sun, 26 Jul 2024 19:30:07 +0200
-- Axel Konrad <ak-li@siduction.org> Thu, 25 Jun 2026 14:12:32 +0200
8 changes: 8 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
siduction-btrfs (0.4.1-1) unstable; urgency=medium

* add preconfigs for root and home
* fix paths /usr/share/siduction/ => /usr/share/siduction-btrfs/
* use debhelper for systemd-units

-- Torsten Wohlfarth <tux@siductioncomputers.com> Mon, 22 Jun 2026 10:20:01 +0200

siduction-btrfs (0.4.0-3) unstable; urgency=medium

[Axel Konrad]
Expand Down
7 changes: 5 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ Build-Depends: debhelper-compat (= 13)
Standards-Version: 4.6.2
Homepage: https://github.com/siduction/siduction-btrfs
Rules-Requires-Root: no
#Vcs-Git: https://salsa.debian.org/debian/siduction-btrfs.git
#Vcs-Browser: https://salsa.debian.org/debian/siduction-btrfs
Vcs-Git: https://github.com/siduction/siduction-btrfs
Vcs-Browser: https://github.com/siduction/siduction-btrfs

Package: siduction-btrfs
Architecture: all
Depends: btrfs-progs,
snapper,
ucf,
${misc:Depends},
${shlibs:Depends}
Recommends: grub-btrfs,
btrfs-assistant
Description: Optimizes the boot menu and the description in Snapper
After a rollback with Snapper, siduction-btrfs sets the default boot
entry to the rollback target.
Expand Down
5 changes: 3 additions & 2 deletions debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ Upstream-Name: siduction-btrfs
Upstream-Contact: ak-li@siduction.org
Source: https://github.com/siduction/siduction-btrfs

Files: debian/*
Files: configs/*
debian/*
50-siduction.sh
60-siduction-btrfs.preset
91-siduction-entry-key.install
grub-menu-title.sh
rollback-grub.sh
rollback-sd-boot.sh
rolling
siduction_btrfs.path
siduction_btrfs.service
siduction_btrfs.timer
Expand Down
1 change: 0 additions & 1 deletion debian/files

This file was deleted.

23 changes: 14 additions & 9 deletions debian/install
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
50-siduction.sh /usr/lib/snapper/plugins/
91-siduction-entry-key.install /usr/lib/kernel/install.d/
rollback-grub.sh /usr/share/siduction/
rollback-sd-boot.sh /usr/share/siduction/
snapshot-description.sh /usr/share/siduction/
grub-menu-title.sh /usr/share/siduction/
siduction_btrfs.service /usr/lib/systemd/system/
siduction_btrfs.path /usr/lib/systemd/system/
rolling /usr/share/snapper/config-templates/
50-siduction.sh /usr/lib/snapper/plugins/
91-siduction-entry-key.install /usr/lib/kernel/install.d/
btrfs /usr/share/siduction-btrfs/
rollback-grub.sh /usr/share/siduction-btrfs/
rollback-sd-boot.sh /usr/share/siduction-btrfs/
snapshot-description.sh /usr/share/siduction-btrfs/
grub-menu-title.sh /usr/share/siduction-btrfs/
configs/* /usr/share/snapper/config-templates/
siduction_btrfs.service /usr/lib/systemd/system/
siduction_btrfs.path /usr/lib/systemd/system/
60-siduction-btrfs.preset /usr/lib/systemd/system-preset/
Info.md /usr/share/docs/siduction-btrfs/
LICENSE /usr/share/docs/siduction-btrfs/
README.md /usr/share/docs/siduction-btrfs/
55 changes: 53 additions & 2 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,60 @@

set -e

exec $(systemctl daemon-reload)
case "$1" in
configure)
if ! snapper list-configs | grep -q "^root " 2>/dev/null; then
echo "Create snapper-configuration for root..."
snapper --no-dbus create-config -f btrfs / || true
rm -f /etc/snapper/configs/root
Comment thread
ak-li marked this conversation as resolved.
fi
if ! snapper list-configs | grep -q "^home " 2>/dev/null; then
echo "Create snapper-configuration for home..."
if [ -d /home ]; then
snapper --no-dbus -c home create-config -f btrfs /home || true
rm -f /etc/snapper/configs/home
fi
fi
# register existing snapper configs with UCF
if [ -x "/usr/bin/ucf" ]; then
echo "check for existing snapper-configurations..."
ucf --three-way /usr/share/siduction-btrfs/configs/root /etc/snapper/configs/root
ucf --three-way /usr/share/siduction-btrfs/configs/home /etc/snapper/configs/home

ucfr siduction-btrfs /etc/snapper/configs/root
ucfr siduction-btrfs /etc/snapper/configs/home
else
# Fallback force copy default configs
cp -an /usr/share/siduction-btrfs/configs/root /etc/snapper/configs/root
cp -an /usr/share/siduction-btrfs/configs/home /etc/snapper/configs/home
fi
# checking chroot
if systemd-detect-virt --chroot >/dev/null 2>&1; then
echo "Running in chroot. Force deactivating snapper-timera ..."
rm -f /etc/systemd/system/timers.target.wants/snapper-boot.timer
rm -f /etc/systemd/system/timers.target.wants/snapper-timeline.timer

if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper disable snapper-boot.timer >/dev/null 2>&1 || true
deb-systemd-helper disable snapper-timeline.timer >/dev/null 2>&1 || true
fi
else
if [ -d /run/systemd/system ]; then
echo "Set siduction systemd-presets for snapper ..."
systemctl --system daemon-reload || true
systemctl --system preset snapper-boot.timer || true
systemctl --system preset snapper-timeline.timer || true
fi
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;

exec $(systemctl enable --now siduction_btrfs.path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die systemd Unit müsste auch aktiviert werden. Sonst können keine Booteinträge erstellt werden.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

siduction_btrfs.path ist enabled, wenn man dieses Paket installiert, dafür sogt der Debhelper.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Einzig, wenn man von 0.4.0 auf dieses Paket upgraden würde, ist das danach nicht anabled (auf Grund des alten codes).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wie wäre es mit diesen Code innerhalb 'configure)' um ein Upgrade von 0.4.0 sicher zu gestalten?

if [ "$(systemctl is-active siduction_btrfs.path)" = "inactive" ]; then
    if [ "$(systemctl is-enabled siduction_btrfs.path)" = "disabled" ]; then
        systemctl enable --now siduction_btrfs.path &>/dev/null
    else
        systemctl start siduction_btrfs.path
    fi
fi

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

#DEBHELPER#

Expand Down
Loading